Jump to content

Module:ElementHubNavigation

Revision as of 12:28, 28 October 2025 by MarkWD (talk | contribs) (// via Wikitext Extension for VSCode)

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