Module:SectionNav: Difference between revisions
From Bodhicitta
((by SublimeText.Mediawiker)) |
((by SublimeText.Mediawiker)) |
||
| Line 29: | Line 29: | ||
end | end | ||
output = output .. '</div>' | |||
return output | return output | ||
Revision as of 09:45, 7 December 2023
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]
local sectionsTb = {}
for section in string.gmatch(sections, "([^;]+)") do
table.insert(sectionsTb, section)
end
local output = '<div class="text-center">'
for index,section in ipairs(sectionsTb) do
if index == 0 then
output = output .. '<span class="muted font-style-italic">First Section</span>'
else
prevIndex = index - 1
output = output .. '<span><a href="/index.php/' .. mw.title.getCurrentTitle().baseText .. '/' .. sectionsTb[prevIndex] .. '" title="' .. mw.title.getCurrentTitle().baseText .. '/' .. sectionsTb[prevIndex] .. '"><i class="fa-duotone fa-angles-left"></i> Previous Section</a></span>'
end
output = output .. ' | '
if index == #index then
output = output .. '<span class="muted font-style-italic">Last Section</span>'
else
nextIndex = index + 1
output = output .. '<span><a href="/index.php/' .. mw.title.getCurrentTitle().baseText .. '/' .. sectionsTb[nextIndex] .. '" title="' .. mw.title.getCurrentTitle().baseText .. '/' .. sectionsTb[nextIndex] .. '">Next Section <i class="fa-duotone fa-angles-right"></i></a></span>'
end
end
output = output .. '</div>'
return output
end
return p