PC Gaming Shelter
An archive dedicated to preserving PC Gaming history and more

Module:Navigation: Difference between revisions

From PC Gaming Shelter
No edit summary
No edit summary
 
(11 intermediate revisions by the same user not shown)
Line 8: Line 8:
     local html = mw.html.create()
     local html = mw.html.create()
     html:tag('div')
     html:tag('div'):addClass('navthumb')
         :tag('div'):attr('data-bg', image):wikitext(string.format([[%s|%s]], target, label)):done()
         :tag('div'):addClass('navthumb-image'):attr({
         :tag('div'):wikitext(string.format([[%s|%s]], target, label)):done()
        ['data-bg'] = image,
        }):done()
         :tag('div'):addClass('navthumb-label'):wikitext(string.format('[[%s|%s]]', target, label)):done()
     :done()
     :done()


Line 21: Line 23:
    
    
   local html = mw.html.create()
   local html = mw.html.create()
   html:tag('div'):addClass('card bg-dark thumbwall')
   local card = html:tag('div'):addClass('card bg-dark thumbwall mb-3')
:tag('div'):addClass('card-header'):wikitext(title):done()
  local header = card:tag('div'):addClass('card-header'):wikitext(title):done()
:tag('div'):addClass('card-body')
  local body = card:tag('div'):addClass('card-body')
 
 
local i = 1
local i = 1
while args['label' .. i] do
while args['label' .. i] do
local label = args['label' .. i]
local label = args['label' .. i]
local image = args['image' .. i] or ''
local image = args['image' .. i] or ''
local imageUrl = ''
if image and image ~= '' then
imageUrl = frame:preprocess(
string.format('{{filepath:{{PAGENAME:%s}}}}', image)
)
end
local target = args['target' .. i] or label
local target = args['target' .. i] or label
         html:node(renderRow(label, image, target))
         body:node(renderRow(label, imageUrl, target))
     i = i + 1
     i = i + 1
end
end
Line 36: Line 44:
   return html
   return html
end
end
return p

Latest revision as of 17:36, 18 March 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 html = mw.html.create()
    html:tag('div'):addClass('navthumb')
        :tag('div'):addClass('navthumb-image'):attr({
        	['data-bg'] = image,
        }):done()
        :tag('div'):addClass('navthumb-label'):wikitext(string.format('[[%s|%s]]', target, label)):done()
    :done()

    return html
end

function p.data(frame)
  local args = frame:getParent().args or {}
  local title = args[1] or args['title'] or 'Navigate'
  
  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 image = args['image' .. i] or ''
		local imageUrl = ''
		if image and image ~= '' then
			imageUrl = frame:preprocess(
				string.format('{{filepath:{{PAGENAME:%s}}}}', image)
			)
		end
		local target = args['target' .. i] or label
        body:node(renderRow(label, imageUrl, target))
    	i = i + 1
	end

  return html
end

return p