Jump to content

Module:BibliographyLink

From Adaris
Revision as of 08:19, 23 March 2025 by Oros (talk | contribs) (Created page with "local p = {} function p.link(frame) local args = frame:getParent().args local title = args["Title"] or "" local category = args["Category"] or "general" -- Get text before the first colon local base = mw.ustring.match(title, "^[^:]+") or title -- Clean slug: lowercase, replace spaces with dashes local slug = mw.ustring.lower(base) slug = mw.ustring.gsub(slug, " ", "-") local url = "https://adarislibrary.org/docs/books/" .. category...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

local p = {}

function p.link(frame)
    local args = frame:getParent().args
    local title = args["Title"] or ""
    local category = args["Category"] or "general"

    -- Get text before the first colon
    local base = mw.ustring.match(title, "^[^:]+") or title

    -- Clean slug: lowercase, replace spaces with dashes
    local slug = mw.ustring.lower(base)
    slug = mw.ustring.gsub(slug, " ", "-")

    local url = "https://adarislibrary.org/docs/books/" .. category .. "/" .. slug
    return string.format("[%s %s]", url, title)
end

return p