Module:Number of works

From ProleWiki, the proletarian encyclopedia
Revision as of 15:41, 5 July 2023 by CriticalResist (talk | contribs) (1 work instead of 1 works)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
local p = {}

function p.getWorkCount(frame)
    local category = frame.args.category or ''
    local pages = mw.site.stats.pagesInCategory(category)
    
    if tonumber(pages) == 1 then
        return "1 work"
    else
        return pages .. " works"
    end
end

function p.main(frame)
    return p.getWorkCount(frame)
end

return p