Module:SectionNav: Difference between revisions
From Bodhicitta
(VSCode edit) |
(VSCode edit) |
||
| Line 12: | Line 12: | ||
end | end | ||
if #sectionsTb then return | if tostring(#sectionsTb) == '1' then return '' end | ||
local output = '' | local output = '' | ||
Revision as of 14:43, 13 March 2026
Documentation for this module may be created at Module:SectionNav/doc
local p = {}
function p.main(frame)
local pArgs = frame:getParent().args
local sections = pArgs[2]
if sections == nil or sections == '' then return '' end
local sectionsTb = {}
for section in string.gmatch(sections, "([^;]+)") do
table.insert(sectionsTb, mw.text.trim(section))
end
if tostring(#sectionsTb) == '1' then return '' end
local output = ''
for index,section in ipairs(sectionsTb) do
if section == mw.title.getCurrentTitle().subpageText then
if index == 1 then
output = output .. '<div class="muted font-style-italic my-1 text-110">First Section</div>'
else
local prevSection = sectionsTb[index-1]
output = output .. '<div class="my-1 text-110">[[' .. mw.title.getCurrentTitle().baseText .. '/' .. prevSection .. '|Previous Section <i class="fa-sharp-duotone fa-solid fa-arrow-u-turn-up-left"></i>]]</div>'
end
end
end
for index,section in ipairs(sectionsTb) do
if section == mw.title.getCurrentTitle().subpageText then
if index == #sectionsTb then
output = output .. '<div class="muted font-style-italic my-1 text-110">Last Section</div>'
else
local nextSection = sectionsTb[index+1]
output = output .. '<div class="my-1 text-110">[[' .. mw.title.getCurrentTitle().baseText .. '/' .. nextSection .. '|Next Section <i class="fa-sharp-duotone fa-solid fa-arrow-right-long"></i>]]</div>'
end
end
end
return output
end
return p