Modul:Breadcrumb
Aus Stadtsprachen
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