Module:Sisterlinks

From Wikipedia

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

local p = {}

function p.main(frame)
	local config = frame.args
	
	if mw.wikibase.getEntityObject() ~= nil then
		if config[1] == "wikiheimild" then
			if mw.wikibase.getEntityObject():getSitelink("enwikisource") ~= nil then
				wikidata = mw.wikibase.getEntityObject():getSitelink("enwikisource")
			end
		elseif config[1] == "wikipedia" then
			if mw.wikibase.getEntityObject():getSitelink("enwiki") ~= nil then
				wikidata = mw.wikibase.getEntityObject():getSitelink("enwiki")
			end
		elseif config[1] == "commons" then
			if mw.wikibase.getEntityObject():getSitelink("commonswiki") ~= nil then
				wikidata = mw.wikibase.getEntityObject():getSitelink("commonswiki")
			end
		elseif config[1] == "commonscat" then
			if mw.wikibase.entity.formatPropertyValues("P55") ~= nil then
				wdtable = mw.wikibase.entity.formatPropertyValues("P55")
				wikidata = table.concat(wdtable)
			end
		end
	end
	if wikidata == nil then
		return "wikidata returns nothing"
	else
		return wikidata
	end
end

return p