Dokumentācijas ikona Moduļa dokumentācija[izveidot]
local p = {}
local getArgs = require('Module:Arguments').getArgs
local entity = mw.wikibase.getEntityObject()

local type = {
	{ "commons", "* [[Attēls:Commons-logo.svg|12px|link=|alt=]] [[Vikikrātuve|Vikikrātuvē]] par šo tēmu ir pieejami [[multivides]] faili."} ,
	{ "wikisource", "* [[Attēls:Wikisource-logo.svg|12px|link=|alt=]] ''[[Wikisource]]'' ir vairāk informācijas par šo tēmu."}
}
--[=[
local function makeLink(type, prefix, link, text)
	return type .. " Skatīt: '''''[[" .. prefix .. link .. "|" .. text .. "]]'''''"
end
]=]

local function makeLink(prefix, link, text)
	return "* [[Attēls:Commons-logo.svg|12px|link=|alt=]] [[Vikikrātuve|Vikikrātuvē]] par šo tēmu ir pieejami [[multivides]] faili. Skatīt: '''''[[:" .. prefix .. link .. "|" .. text .. "]]'''''."
end

function p._main(args)
	local result = ''
	local currentpage = mw.title.getCurrentTitle()
	local disambigname = mw.ustring.gsub(args.name or currentpage.text, " %b()", "")
	local commons = args.c
	local title = args[1] or disambigname
	
	if commons then
		result = makeLink("Commons:Category:",commons,title)
		elseif entity and entity.claims and entity.claims["P373"] then
		if entity.claims["P373"][1].mainsnak.snaktype == 'value' then
			result = makeLink("Commons:Category:",entity.claims["P373"][1].mainsnak.datavalue.value,title)
		elseif entity.sitelinks.commonswiki then
			result = makeLink("Commons:",entity.sitelinks.commonswiki.title,title)
		end
	end
	
	return result
end

function p.main(frame)
	local args = getArgs(frame)
	return p._main(args)
end

return p