local p = {}
-- Function to get the number of works using a parser function
function p.getWorkCount(frame)
local category = frame.args.category or ''
if category == '' then return "0 works" end
-- Use the PAGESINCATEGORY parser function
local pages = frame:preprocess('{{PAGESINCATEGORY:' .. category .. '}}')
-- Return the result formatted
local result = ''
if tonumber(pages) == 1 then
result = "1 work"
else
result = pages .. " works"
end
return result
end
function p.main(frame)
return p.getWorkCount(frame)
end
return p