Module:SectionNav: Difference between revisions
From Bodhicitta
(VSCode edit) |
(VSCode edit) |
||
| Line 20: | Line 20: | ||
else | else | ||
local prevSection = sectionsTb[index-1] | local prevSection = sectionsTb[index-1] | ||
output = output .. '<div>[[' .. mw.title.getCurrentTitle().baseText .. '/' .. prevSection .. '|<i class="fa-duotone fa- | output = output .. '<div>[[' .. 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 | end | ||
| Line 30: | Line 30: | ||
else | else | ||
local nextSection = sectionsTb[index+1] | local nextSection = sectionsTb[index+1] | ||
output = output .. '<div>[[' .. mw.title.getCurrentTitle().baseText .. '/' .. nextSection .. '|Next Section <i class="fa-duotone fa- | output = output .. '<div>[[' .. mw.title.getCurrentTitle().baseText .. '/' .. nextSection .. '|Next Section <i class="fa-sharp-duotone fa-solid fa-arrow-right-long"></i>]]</div>' | ||
end | end | ||
end | end | ||
Revision as of 18:38, 6 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[1]
if sections == nil or sections == '' then return '' end
local sectionsTb = {}
for section in string.gmatch(sections, "([^;]+)") do
table.insert(sectionsTb, section)
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">First Section</div>'
else
local prevSection = sectionsTb[index-1]
output = output .. '<div>[[' .. 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">Last Section</div>'
else
local nextSection = sectionsTb[index+1]
output = output .. '<div>[[' .. 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