Module:SectionNav: Difference between revisions
From Bodhicitta
((by SublimeText.Mediawiker)) |
((by SublimeText.Mediawiker)) |
||
| Line 17: | Line 17: | ||
output = output .. '<span class="muted font-style-italic">First Section</span>' | output = output .. '<span class="muted font-style-italic">First Section</span>' | ||
else | else | ||
output = output .. '<span><a href="/index.php/' .. mw.title.getCurrentTitle().baseText .. '/' .. sectionsTb[index-1] .. '" title="' .. mw.title.getCurrentTitle().baseText .. '/' .. sectionsTb[index-1] .. '"><i class="fa-duotone fa-angles-left"></i> Previous Section</a></span>' | |||
output = output .. '<span><a href="/index.php/' .. mw.title.getCurrentTitle().baseText .. '/' .. sectionsTb[ | |||
end | end | ||
output = output .. ' | ' | output = output .. ' | ' | ||
| Line 24: | Line 23: | ||
output = output .. '<span class="muted font-style-italic">Last Section</span>' | output = output .. '<span class="muted font-style-italic">Last Section</span>' | ||
else | else | ||
output = output .. '<span><a href="/index.php/' .. mw.title.getCurrentTitle().baseText .. '/' .. sectionsTb[index+1] .. '" title="' .. mw.title.getCurrentTitle().baseText .. '/' .. sectionsTb[index+1] .. '">Next Section <i class="fa-duotone fa-angles-right"></i></a></span>' | |||
output = output .. '<span><a href="/index.php/' .. mw.title.getCurrentTitle().baseText .. '/' .. sectionsTb[ | |||
end | end | ||
end | end | ||
Revision as of 09:56, 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
output = output .. '<span><a href="/index.php/' .. mw.title.getCurrentTitle().baseText .. '/' .. sectionsTb[index-1] .. '" title="' .. mw.title.getCurrentTitle().baseText .. '/' .. sectionsTb[index-1] .. '"><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
output = output .. '<span><a href="/index.php/' .. mw.title.getCurrentTitle().baseText .. '/' .. sectionsTb[index+1] .. '" title="' .. mw.title.getCurrentTitle().baseText .. '/' .. sectionsTb[index+1] .. '">Next Section <i class="fa-duotone fa-angles-right"></i></a></span>'
end
end
output = output .. '</div>'
return output
end
return p