Module:Link

From Create: Minecraft Mod Wiki
Revision as of 19:46, 30 April 2021 by Create: Minecraft Mod Wiki>Joker876 (Created page with "local p = {} function p.mcWikiLink (f) local origArgs = f if f == mw.getCurrentFrame() then origArgs = f:getParent().args else f = mw.getCurrentFrame() end local arg...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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

local p = {}

function p.mcWikiLink (f)
	local origArgs = f
	if f == mw.getCurrentFrame() then
		origArgs = f:getParent().args
	else
		f = mw.getCurrentFrame()
	end
	local args = {}
	for k,v in pairs(origArgs) do
		if type(k) == "string" then k = k:lower() end
		args[k] = v
	end
	
	local link = args[1]
	local alt = args[2] or link
	
	if not link then return '[[w:c:minecraft|<span title="Minecraft Wiki">Minecraft Wiki</span>]]' end
	return table.concat{
		'[[w:c:minecraft:', link, '|<span title="Minecraft Wiki: ', link, '">', alt, '</span>]]'
	}
end

return p