Usage: {{#invoke:Which Chapter|where_chapter|number}}
For Chapter 89+ specifically, use {{#invoke:Which Chapter|where_chapter|89+}}
local data = require("Module:Which_Chapter/data")
local chapters = data[1]
---@param num integer
local function get_chapter(num)
for i, v in ipairs(chapters) do
if i == num then
return v
end
end
return "TBA"
end
local util = require("Module:Util")
local mod = {
chapters = chapters
}
function mod.where_chapter(frame)
local args = frame.args
local parent = frame:getParent()
local pargs={}
if parent then pargs=parent.args end
local n = args[1] or pargs[1] or ""
if n == "89+" then return "Chapter 89+" end
local num = tonumber(n) or #chapters + 1
local resolve = args[2] or pargs[2] or nil
local res = frame:preprocess(get_chapter(num))
if resolve ~= nil then
if res == "TBA" then return res end
return util.resolve_text(res)
else
return res
end
end
return mod