Modul:Huvudkategori
Dokumentationen för denna modul kan skapas på Modul:Huvudkategori/dok
p = {}
function p.huvudkategori(frame)
local text = ''
local table entity = mw.wikibase.getEntityObject()
if entity then
if entity.claims then
if entity.claims.P910 then
local i = 1
while entity.claims.P910[i] do
if entity.claims.P910[i].mainsnak.snaktype == 'value' then
local id = entity.claims.P910[i].mainsnak.datavalue.value['numeric-id']
if id then
local sort = entity.claims.P910[i].mainsnak.datavalue.value['entity-type']
if sort == 'item' then
id = 'q' .. id
elseif sort == 'property' then
id = 'p' .. id
else
return ''
end
local u = mw.wikibase.sitelink( id )
if string.sub(u, 1, 9) == 'Kategori:' then
text = text .. '[[' .. u .. '| ' .. i .. ']]'
end
end
end
i = i + 1
end
end
end
end
return text
end
return p