Module:category link
Appearance
- This module lacks a documentation subpage. Please create it.
- Useful links: subpage list • links • transclusions • testcases • sandbox
local concat = table.concat
local html_create = mw.html.create
local is_internal_title = require("Module:pages").is_internal_title
local make_title = mw.title.makeTitle
local tostring = tostring
local export = {}
function export.make_link(name, sortkey)
-- Unconditionally add the "Category:" prefix.
local fullname = "Category:" .. name
if is_internal_title(make_title(14, name)) then
fullname = "[[:" .. fullname .. "]]"
end
return tostring(html_create("code")
:css("white-space", "pre-wrap")
:wikitext("[[" .. concat({fullname, sortkey}, "|") .. "]]")
)
end
return export