Module:Ref/ssm

From A Wiki of Ice and Fire
Revision as of 15:52, 1 November 2023 by Abjiklam (talk | contribs)
Jump to: navigation, search

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

local data = require('Module:Ref/ssm/data')
local getArgs = require('Module:Arguments').getArgs

local p = {}

function p.main(frame)
    local args = getArgs(frame)
    return p._main(args)
end

function p._main(args)
    local number = tonumber(args[1])
    local article = data[number]
    local title = article.title
    local date = article.date
    local lang = mw.language.getContentLanguage()
    local date_text = lang:formatDate("F j, Y", date)
    return mw.ustring.format(
        "[[So Spake Martin]]: ''[https://www.westeros.org/Citadel/SSM/Entry/%d %s]'' (%s)",
        number,
        title,
        date_text
    )
end

return p