Module:Navigation: Difference between revisions
From PC Gaming Shelter
No edit summary |
No edit summary |
||
| Line 5: | Line 5: | ||
if not target then | if not target then | ||
target = defaultTarget | target = defaultTarget | ||
end | |||
local cardClass = 'navthumb' | |||
if image ~= '' then | |||
cardClass = 'navthumb my-2' | |||
end | end | ||
local html = mw.html.create() | local html = mw.html.create() | ||
local card = html:tag('div'):addClass( | local card = html:tag('div'):addClass(cardClass) | ||
if image ~= '' then | if image ~= '' then | ||
card:tag('div'):addClass('navthumb-image'):attr({ | card:tag('div'):addClass('navthumb-image'):attr({ | ||
Revision as of 12:33, 6 June 2026
Documentation for this module may be created at Module:Navigation/doc
local p = {}
local function renderRow(label, image, target)
local defaultTarget = label
if not target then
target = defaultTarget
end
local cardClass = 'navthumb'
if image ~= '' then
cardClass = 'navthumb my-2'
end
local html = mw.html.create()
local card = html:tag('div'):addClass(cardClass)
if image ~= '' then
card:tag('div'):addClass('navthumb-image'):attr({
['data-bg'] = image,
}):done()
end
card:tag('div'):addClass('navthumb-label'):wikitext(string.format('[[%s|%s]]', target, label)):done()
return html
end
function p.data(frame)
local args = frame:getParent().args or {}
local title = args[1] or args['title'] or 'Navigate'
local showThumbs = args['show thumbs'] or '1'
local html = mw.html.create()
local card = html:tag('div'):addClass('card bg-dark thumbwall mb-3')
local header = card:tag('div'):addClass('card-header'):wikitext(title):done()
local body = card:tag('div'):addClass('card-body')
local i = 1
while args['label' .. i] do
local label = args['label' .. i]
local imageUrl = ''
if showThumbs == '1' then
local image = args['image' .. i] or ''
if image and image ~= '' then
imageUrl = frame:preprocess(
string.format('{{filepath:{{PAGENAME:%s}}}}', image)
)
end
end
local target = args['target' .. i] or label
body:node(renderRow(label, imageUrl, target))
i = i + 1
end
return html
end
return p
