Jump to content

Module:Authors

From wikibase
Revision as of 11:35, 17 April 2026 by Design (talk | contribs) (Created page with "local p = {} function p.list(frame) local entity = mw.wikibase.getEntity() if not entity then return "No Wikibase entity found for this page." end local claims = entity.claims or {} local p2Claims = claims.P2 or {} local authors = {} for _, claim in ipairs(p2Claims) do local value = claim.mainsnak.datavalue if value and value.type == "wikibase-entityid" then local itemId = value.value.id...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Authors/doc

local p = {}

function p.list(frame)
    local entity = mw.wikibase.getEntity()
    if not entity then
        return "No Wikibase entity found for this page."
    end
    
    local claims = entity.claims or {}
    local p2Claims = claims.P2 or {}
    
    local authors = {}
    for _, claim in ipairs(p2Claims) do
        local value = claim.mainsnak.datavalue
        if value and value.type == "wikibase-entityid" then
            local itemId = value.value.id
            local label = mw.wikibase.getLabel(itemId) or itemId
            table.insert(authors, "[[" .. label .. "]]")
        end
    end
    
    if #authors == 0 then
        return "No authors found."
    end
    
    return table.concat(authors, ", ")
end

return p