Jump to content

Module:Redirect/doc

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 2a00:1851:800a:ab09:1c29:c9f0:5a7f:3db4 (talk) at 21:07, 2 January 2025. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

IsRedirect

The isRedirect function is used from wiki pages to find out if a given page is a redirect or not. If the page is a redirect, the function returns "yes", and if not the output is blank. Its usage is {{#invoke:redirect|isRedirect|page-name}}.

Examples

  • {{#invoke:redirect|isRedirect|WP:AFC}} → yes
  • {{#invoke:redirect|isRedirect|Wikipedia:Articles for deletion}}
  • {{#invoke:redirect|isRedirect|Wikipedia:Articles for rumination}}

LuaIsRedirect

The isRedirect can be accessed from other Lua modules in the same way as the main function:

local mRedirect = require('Module:Redirect')
mRedirect.luaIsRedirect(rname)

GetTarget

The getTarget function fetches the target page name of a redirect page, and is only usable from Lua. If the page specified is a redirect, then the target is returned; otherwise the function returns nil.

To use it, first load the module.

local mRedirect = require('Module:Redirect')

Then use the function with the following syntax:

mRedirect.getTarget(page)

page can be either the name of the redirect page as a string, or a mw.title object.

See also