Module:ElementHubNavigation: Difference between revisions
Appearance
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| Line 9: | Line 9: | ||
local p = {} | local p = {} | ||
-- Hub configuration with icon | -- Hub configuration with icon file mappings | ||
local hubs = { | local hubs = { | ||
{ label = 'Nations', url = 'Hub:Nations', | { label = 'Nations', url = 'Hub:Nations', icon = 'Icon-Globe.svg' }, | ||
{ label = 'People', url = 'Hub:People', | { label = 'People', url = 'Hub:People', icon = 'Icon-User.svg' }, | ||
{ label = 'Organizations', url = 'Hub:Organizations', | { label = 'Organizations', url = 'Hub:Organizations', icon = 'Icon-Building.svg' }, | ||
{ label = 'Events', url = 'Hub:Events', | { label = 'Events', url = 'Hub:Events', icon = 'Icon-Calendar.svg' }, | ||
{ label = 'Topics', url = 'Hub:Topics', | { label = 'Topics', url = 'Hub:Topics', icon = 'Icon-Layers.svg' } | ||
} | } | ||
-- Generate a single hub link item using MediaWiki File reference | |||
-- Generate a single hub link item | |||
local function generateHubLink(hub) | local function generateHubLink(hub) | ||
local iconHtml = | local iconHtml = string.format('[[File:%s|24px|link=|class=hub-icon]]', hub.icon) | ||
return string.format( | return string.format( | ||
'<li class="cdx-hub__item"><span class=" | '<li class="cdx-hub__item"><span class="cdx-hub__link">%s[[%s|%s]]</span></li>', | ||
iconHtml, | iconHtml, | ||
hub.url, | hub.url, | ||
Revision as of 04:15, 29 October 2025
Documentation for this module may be created at Module:ElementHubNavigation/doc
--[[
* Name: ElementHubNavigation
* Author: Mark W. Datysgeld
* Description: Hub navigation module for Main Page - MINIMAL TEXT-ONLY VERSION
* Notes: Phase 1 - Text links with layout only, no icons yet
* Pattern: MediaWiki table syntax + string concatenation (like ElementNavigation)
]]
local p = {}
-- Hub configuration with icon file mappings
local hubs = {
{ label = 'Nations', url = 'Hub:Nations', icon = 'Icon-Globe.svg' },
{ label = 'People', url = 'Hub:People', icon = 'Icon-User.svg' },
{ label = 'Organizations', url = 'Hub:Organizations', icon = 'Icon-Building.svg' },
{ label = 'Events', url = 'Hub:Events', icon = 'Icon-Calendar.svg' },
{ label = 'Topics', url = 'Hub:Topics', icon = 'Icon-Layers.svg' }
}
-- Generate a single hub link item using MediaWiki File reference
local function generateHubLink(hub)
local iconHtml = string.format('[[File:%s|24px|link=|class=hub-icon]]', hub.icon)
return string.format(
'<li class="cdx-hub__item"><span class="cdx-hub__link">%s[[%s|%s]]</span></li>',
iconHtml,
hub.url,
hub.label
)
end
-- Main render function
function p.render(frame)
-- Generate all hub links
local hubLinks = {}
for i, hub in ipairs(hubs) do
hubLinks[i] = generateHubLink(hub)
end
-- Build complete output using MediaWiki table syntax + HTML
local output = {
'{| class="hub-nav-table"',
'|- class="hub-nav-row"',
'| colspan="2" |',
'<div id="hub" class="cdx-hub" role="navigation" aria-label="Hub Navigation">',
' <ul class="cdx-hub__list">',
' ' .. table.concat(hubLinks, '\n '),
' </ul>',
'</div>',
'<div id="hub-spacer" aria-hidden="true"></div>',
'|}'
}
return table.concat(output, '\n')
end
return p