Jump to content

Module:Navigation header

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Harej (talk | contribs) at 00:35, 29 April 2023 (Module for creating a header like Template:InternetArchiveBot header). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

local p = {}

local iconTable = {
    discuss = "Font Awesome 5 solid comment-dots.svg"
}

function p.getIcon(key)
    return iconTable[key] or key
end

function p.navigationHeader(frame)
    local icon = {}
    local label = {}
    local i = 1

    while frame.args["icon" .. i] or frame.args["type" .. i] or frame.args["label" .. i] do
        icon[i] = frame.args["icon" .. i] or p.getIcon(frame.args["type" .. i])
        label[i] = frame.args["label" .. i] or ""
        i = i + 1
    end

    local output = {}
    output[#output + 1] = '<div class="navigation-header"><div role="navigation" class="navigation-header-tabs">'

    for j = 1, #icon do
        output[#output + 1] = string.format(
            '* <div class="navigation-header-icon">[[File:%s|x18px|link=]]</div>&nbsp;%s',
            icon[j],
            label[j]
        )
    end

    output[#output + 1] = '</div></div>'

    return table.concat(output, '\n')
end

return p