Module:ElementHubNavigation: Difference between revisions
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| Line 9: | Line 9: | ||
local p = {} | local p = {} | ||
-- Hub configuration | -- Hub configuration with icon test methods | ||
local hubs = { | local hubs = { | ||
{ label = 'Nations', url = 'Hub:Nations' }, | { label = 'Nations', url = 'Hub:Nations', method = 'inline_svg' }, | ||
{ label = 'People', url = 'Hub:People' }, | { label = 'People', url = 'Hub:People', method = 'css_bg' }, | ||
{ label = 'Organizations', url = 'Hub:Organizations' }, | { label = 'Organizations', url = 'Hub:Organizations', method = 'mw_file' }, | ||
{ label = 'Events', url = 'Hub:Events' }, | { label = 'Events', url = 'Hub:Events', method = 'direct_url' }, | ||
{ label = 'Topics', url = 'Hub:Topics' } | { label = 'Topics', url = 'Hub:Topics', method = 'text_only' } | ||
} | } | ||
-- Generate a single hub link item | -- Inline SVG code for Icon-User.svg | ||
local inlineSVG = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="hub-icon"><path d="M20 21a8 8 0 0 0-16 0"/><circle cx="12" cy="7" r="4"/></svg>' | |||
-- Generate a single hub link item with specified icon method | |||
local function generateHubLink(hub) | local function generateHubLink(hub) | ||
local iconHtml = '' | |||
local wrapperClass = 'cdx-hub__link' | |||
if hub.method == 'inline_svg' then | |||
-- Method 1: Inline SVG (baked in HTML) | |||
iconHtml = inlineSVG | |||
elseif hub.method == 'css_bg' then | |||
-- Method 2: CSS background-image (add class for CSS to target) | |||
wrapperClass = 'cdx-hub__link hub-icon-css' | |||
elseif hub.method == 'mw_file' then | |||
-- Method 3: MediaWiki File reference | |||
iconHtml = '[[File:Icon-User.svg|24px|link=|class=hub-icon]]' | |||
elseif hub.method == 'direct_url' then | |||
-- Method 4: Direct image URL | |||
iconHtml = '<img src="https://icannwiki.org/images/9/9c/Icon-User.svg" width="24" height="24" class="hub-icon" alt="">' | |||
-- else: text_only - no icon | |||
end | |||
return string.format( | return string.format( | ||
'<li class="cdx-hub__item"><span class=" | '<li class="cdx-hub__item"><span class="%s">%s[[%s|%s]]</span></li>', | ||
wrapperClass, | |||
iconHtml, | |||
hub.url, | hub.url, | ||
hub.label | hub.label | ||