Module:ElementHubNavigation: Difference between revisions
Appearance
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| Line 2: | Line 2: | ||
* Name: ElementHubNavigation | * Name: ElementHubNavigation | ||
* Author: Mark W. Datysgeld | * Author: Mark W. Datysgeld | ||
* Description: Hub navigation module for Main Page | * Description: Hub navigation module for Main Page - MINIMAL TEXT-ONLY VERSION | ||
* Notes: | * Notes: Phase 1 - Text links with layout only, no icons yet | ||
* | * Pattern: MediaWiki table syntax + string concatenation (like ElementNavigation) | ||
]] | ]] | ||
local p = {} | local p = {} | ||
-- Hub configuration | -- Hub configuration | ||
local hubs = { | 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 as | -- Generate a single hub link item as plain text link | ||
local function generateHubLink(hub) | local function generateHubLink(hub) | ||
return string.format( | return string.format( | ||
'<li class="cdx-hub__item"><a href="/wiki/%s" class="cdx-hub__link | '<li class="cdx-hub__item"><a href="/wiki/%s" class="cdx-hub__link">%s</a></li>', | ||
hub.url, | hub.url, | ||
hub.label | hub.label | ||
) | ) | ||
| Line 55: | Line 44: | ||
' ' .. table.concat(hubLinks, '\n '), | ' ' .. table.concat(hubLinks, '\n '), | ||
' </ul>', | ' </ul>', | ||
'</div>', | '</div>', | ||
'<div id="hub-spacer" aria-hidden="true"></div>', | '<div id="hub-spacer" aria-hidden="true"></div>', | ||
Revision as of 12:28, 28 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 as plain text link
local function generateHubLink(hub)
return string.format(
'<li class="cdx-hub__item"><a href="/wiki/%s" class="cdx-hub__link">%s</a></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