Jump to content

Module:Redirect and target

From Wikipedia, the free encyclopedia
This is the current revision of this page, as edited by Uzume (talk | contribs) at 18:06, 26 May 2023 (support redirects to anchors). The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

local getTarget = require('Module:Redirect').getTarget
local p = {}

function p.line(frame)
	local pageTitle = frame.args[1]
	local target = getTarget(pageTitle, true)
	if target then
		return string.format('[[%s]] → [[%s]]', pageTitle, target)
	end
	return string.format('[[%s]] is not a redirect', pageTitle)
end

function p.report(frame)
	local pageTitle = frame.args[1]
	local target = getTarget(pageTitle, true)
	if target then
		return string.format('<i>[[%s]] (R)</i> → [[%s]]', pageTitle, target)
	end
	return string.format('[[%s]]', pageTitle)
end

return p