Modul:Breadcrumb: Unterschied zwischen den Versionen

Aus Stadtsprachen
Wechseln zu:Navigation, Suche
Die Seite wurde neu angelegt: „local p = {} function p.breadcrumb(frame) local args = frame.args local categoryLink = args["CategoryLink"] or "" local categoryName = args["CategoryName"] or "" local pageName = args["PAGENAME"] or "" local html = [[ <div aria-label="breadcrumb"> <ol class="breadcrumb bg-transparent p-0 m-0 d-flex align-items-center" style="list-style: none;"> <li class="breadcrumb-item d-flex align-items-center border-0 p-0"> <a href="/…“
 
Keine Bearbeitungszusammenfassung
 
(10 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 6: Zeile 6:
     local categoryName = args["CategoryName"] or ""
     local categoryName = args["CategoryName"] or ""
     local pageName = args["PAGENAME"] or ""
     local pageName = args["PAGENAME"] or ""
   
    -- Create the html container
    local html = mw.html.create('html')
   
    -- Create the main container
    local div = html:tag('div')
        :attr('aria-label', 'breadcrumb')
   
    local ol = div:tag('ol')
        :addClass('breadcrumb bg-transparent p-0 m-0 d-flex align-items-center')
        :css('list-style', 'none')
   
    -- Home item
    local li1 = ol:tag('li')
        :addClass('breadcrumb-item d-flex align-items-center border-0 p-0')
   
    local homeLink = li1:tag('a')
        :attr('href', '/')
        :addClass('text-dark d-flex align-items-center')
        :css('text-decoration', 'none')
        :css('font-size', '0.875rem')
        :css('font-weight', 'normal')
        :css('transition', 'font-weight 0.2s')


     local html = [[
     homeLink:wikitext([[
<div aria-label="breadcrumb">
  <ol class="breadcrumb bg-transparent p-0 m-0 d-flex align-items-center" style="list-style: none;">
    <li class="breadcrumb-item d-flex align-items-center border-0 p-0">
      <a href="/Hauptseite" class="text-secondary d-flex align-items-center" style="text-decoration: none; font-size: 0.875rem;">
         <svg style="width: 0.75rem; height: 0.75rem;" class="mr-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
         <svg style="width: 0.75rem; height: 0.75rem;" class="mr-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
           <path d="m19.707 9.293-2-2-7-7a1 1 0 0 0-1.414 0l-7 7-2 2a1 1 0 0 0 1.414 1.414L2 10.414V18a2 2 0 0 0 2 2h3a1 1 0 0 0 1-1v-4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v4a1 1 0 0 0 1 1h3a2 2 0 0 0 2-2v-7.586l.293.293a1 1 0 0 0 1.414-1.414Z"/>
           <path d="m19.707 9.293-2-2-7-7a1 1 0 0 0-1.414 0l-7 7-2 2a1 1 0 0 0 1.414 1.414L2 10.414V18a2 2 0 0 0 2 2h3a1 1 0 0 0 1-1v-4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v4a1 1 0 0 0 1 1h3a2 2 0 0 0 2-2v-7.586l.293.293a1 1 0 0 0 1.414-1.414Z"/>
         </svg>
         </svg>
         Hauptseite
         Home
      </a>
    ]])
     </li>
   
     <li class="breadcrumb-item d-flex align-items-center border-0 p-0">
     -- Category item
      <svg style="width: 0.75rem; height: 0.75rem; margin: 0 0.5rem;" class="text-muted" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
     local li2 = ol:tag('li')
        <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 9 4-4-4-4"/>
        :addClass('breadcrumb-item d-flex align-items-center border-0 p-0')
      </svg>
   
      <a href="]] .. categoryLink .. [[" class="text-secondary" style="text-decoration: none; font-size: 0.875rem;">]] .. categoryName .. [[</a>
    li2:wikitext([[
     </li>
        <svg style="width: 0.75rem; height: 0.75rem; margin: 0 0.5rem;" class="text-muted" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
     <li class="breadcrumb-item d-flex align-items-center border-0 p-0" aria-current="page">
          <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 9 4-4-4-4"/>
      <svg style="width: 0.75rem; height: 0.75rem; margin: 0 0.5rem;" class="text-muted" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
        </svg>
        <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 9 4-4-4-4"/>
    ]])
      </svg>
   
      <span class="text-muted" style="font-size: 0.875rem;">]] .. pageName .. [[</span>
    local categoryLinkTag = li2:tag('a')
     </li>
        :attr('href', "/" .. categoryLink)
  </ol>
        :addClass('text-dark')
</div>
        :css('text-decoration', 'none')
]]
        :css('font-size', '0.875rem')
 
        :css('font-weight', 'normal')
     return html
        :css('transition', 'font-weight 0.2s')
    categoryLinkTag:wikitext(categoryName)
   
     -- Current page item
     local li3 = ol:tag('li')
        :addClass('breadcrumb-item d-flex align-items-center border-0 p-0')
        :attr('aria-current', 'page')
   
    li3:wikitext([[
        <svg style="width: 0.75rem; height: 0.75rem; margin: 0 0.5rem;" class="text-muted" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
          <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 9 4-4-4-4"/>
        </svg>
    ]])
   
    li3:tag('span')
        :addClass('text-muted')
        :css('font-size', '0.875rem')
        :wikitext(pageName)
      
    -- Return the parsed HTML
     return frame:preprocess(tostring(html))
end
end


return p
return p

Aktuelle Version vom 8. September 2025, 10:05 Uhr

Die Dokumentation für dieses Modul kann unter Modul:Breadcrumb/Doku erstellt werden

local p = {}

function p.breadcrumb(frame)
    local args = frame.args
    local categoryLink = args["CategoryLink"] or ""
    local categoryName = args["CategoryName"] or ""
    local pageName = args["PAGENAME"] or ""
    
    -- Create the html container
    local html = mw.html.create('html')
    
    -- Create the main container
    local div = html:tag('div')
        :attr('aria-label', 'breadcrumb')
    
    local ol = div:tag('ol')
        :addClass('breadcrumb bg-transparent p-0 m-0 d-flex align-items-center')
        :css('list-style', 'none')
    
    -- Home item
    local li1 = ol:tag('li')
        :addClass('breadcrumb-item d-flex align-items-center border-0 p-0')
    
    local homeLink = li1:tag('a')
        :attr('href', '/')
        :addClass('text-dark d-flex align-items-center')
        :css('text-decoration', 'none')
        :css('font-size', '0.875rem')
        :css('font-weight', 'normal')
        :css('transition', 'font-weight 0.2s')

    homeLink:wikitext([[
        <svg style="width: 0.75rem; height: 0.75rem;" class="mr-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
          <path d="m19.707 9.293-2-2-7-7a1 1 0 0 0-1.414 0l-7 7-2 2a1 1 0 0 0 1.414 1.414L2 10.414V18a2 2 0 0 0 2 2h3a1 1 0 0 0 1-1v-4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v4a1 1 0 0 0 1 1h3a2 2 0 0 0 2-2v-7.586l.293.293a1 1 0 0 0 1.414-1.414Z"/>
        </svg>
        Home
    ]])
    
    -- Category item
    local li2 = ol:tag('li')
        :addClass('breadcrumb-item d-flex align-items-center border-0 p-0')
    
    li2:wikitext([[
        <svg style="width: 0.75rem; height: 0.75rem; margin: 0 0.5rem;" class="text-muted" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
          <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 9 4-4-4-4"/>
        </svg>
    ]])
    
    local categoryLinkTag = li2:tag('a')
        :attr('href', "/" .. categoryLink)
        :addClass('text-dark')
        :css('text-decoration', 'none')
        :css('font-size', '0.875rem')
        :css('font-weight', 'normal')
        :css('transition', 'font-weight 0.2s')
	
    categoryLinkTag:wikitext(categoryName)
    
    -- Current page item
    local li3 = ol:tag('li')
        :addClass('breadcrumb-item d-flex align-items-center border-0 p-0')
        :attr('aria-current', 'page')
    
    li3:wikitext([[
        <svg style="width: 0.75rem; height: 0.75rem; margin: 0 0.5rem;" class="text-muted" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
          <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 9 4-4-4-4"/>
        </svg>
    ]])
    
    li3:tag('span')
        :addClass('text-muted')
        :css('font-size', '0.875rem')
        :wikitext(pageName)
    
    -- Return the parsed HTML
    return frame:preprocess(tostring(html))
end

return p