Module:Sandbox/N3rsti/Wikidata

Revision as of 12:22, 19 January 2020 by imported>N3rsti
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Sandbox/N3rsti/Wikidata/doc

local p = {}

function p.get_item_info(frame)
	local qid = frame.args.qid or ""
	local prop = frame.args.prop or ""
	local out = ""
	local val = ""
	local valtbl = mw.wikibase.getBestStatements(qid, prop)
	for _, value in pairs(valtbl) do
		id = value.mainsnak.datavalue.value.id
		label = mw.wikibase.getLabel(id) or ""
		link = mw.wikibase.getSitelink(id)
		if link then
			val = "[[" .. link .. "]]"	
		else
			val = label
		end
		out = out .. val .. "<br>"
	end
	return out
end

return p