Module:Series
Documentation for this module may be created at Module:Series/doc
local p = {}
-- Returns the index of a given value in a table, if it exists
function getPosInTable(tbl, val)
for i,v in ipairs(tbl) do
if v == val then
return i
end
end
return nil
end
-- Returns a page footer in wikitext with links to the previous and next pages in the series, if they exist
function p.main(frame)
local args = frame.args
local series_name = args.title
local title = mw.title.getCurrentTitle().fullText
local curPos = getPosInTable(args, title)
local prev = curPos and args[curPos - 1]
local next = curPos and args[curPos + 1]
local html = ""
html = html .. "<div class=\"article-series\" data-nosnippet>"
html = html .. "<div class=\"series-header\">"
html = html .. "This article is a part of " .. (series_name and "the " .. series_name or "a") .. " series."
html = html .. "</div>"
html = html .. "<div class=\"series-list\">"
html = html .. (prev and "[[" .. prev .. "|< " .. prev .. "]] | " or "") .. "'''" .. title .. "'''" .. (next and " | [[" .. next .. "|" .. next .. " >]]" or "")
html = html .. "</div>"
html = html .. "</div>"
return html
end
return p