Modul:Wikidata/Formatters/appendcategory

Z Wikipedie, otevřené encyklopedie

Dokumentaci tohoto modulu lze vytvořit na stránce Modul:Wikidata/Formatters/appendcategory/Dokumentace

require 'Modul:No globals'

local parent = require 'Modul:Wikidata/Formatters/wikibase-entityid'

local p = {}

p.getRawValue = parent.getRawValue

function p.formatValue(value, options)
	return p.formatRawValue(p.getRawValue(value, {}), options)
end

function p.formatRawValue(value, options)
	local out = parent.formatRawValue(value, options)
	if options.appendcategory then
		local WD = require 'Modul:Wikidata'
		local link = WD.getSitelinkFromLua{ id = value, of = options.appendcategory }
		if link then
			out = out .. mw.ustring.format('[[%s]]', link)
		end
	end
	return out
end

return p