Module:ElementHubNavigation: Difference between revisions
Appearance
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| Line 18: | Line 18: | ||
} | } | ||
-- Generate a single hub link item | -- Generate a single hub link item using wikilink syntax (like ElementNavigation) | ||
local function generateHubLink(hub) | local function generateHubLink(hub) | ||
return string.format( | return string.format( | ||
'<li class="cdx-hub__item">< | '<li class="cdx-hub__item"><span class="cdx-hub__link">[[%s|%s]]</span></li>', | ||
hub.url, | hub.url, | ||
hub.label | hub.label | ||
Revision as of 03:08, 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
local hubs = {
{ label = 'Nations', url = 'Hub:Nations' },
{ label = 'People', url = 'Hub:People' },
{ label = 'Organizations', url = 'Hub:Organizations' },
{ label = 'Events', url = 'Hub:Events' },
{ label = 'Topics', url = 'Hub:Topics' }
}
-- Generate a single hub link item using wikilink syntax (like ElementNavigation)
local function generateHubLink(hub)
return string.format(
'<li class="cdx-hub__item"><span class="cdx-hub__link">[[%s|%s]]</span></li>',
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