模块:首页

来自iFx Wiki
跳到导航 跳到搜索

此模块的文档可以在模块:首页/doc创建

local smw = require("Module:SMWUtils")
local p = {}

function p.latest_list(frame)
    local user_query = frame.args.query
    local query = user_query .. [[ 
        |limit=20
        |offset=0
        |sort=Modification date
        |order=desc
     ]]
    local pages = smw.query_pages(query)
    local ul = mw.html.create("ul")
    for i, t in ipairs(pages) do
        ul:tag("li"):wikitext("[[" .. t .. "]]")
    end
    return ul:done()
end

function p.latest_flat_list(frame)
    local user_query = frame.args.query
    local query = user_query .. [[ 
        |limit=20
        |offset=0
        |sort=Modification date
        |order=desc
     ]]
    local pages = smw.query_pages(query)
    local ul = mw.html.create()
    local first = true
    for i, t in ipairs(pages) do
        if first then
            first = false
        else
            ul:wikitext(", ")
        end
        ul:tag("span"):wikitext("[[" .. t .. "]]")
    end
    return ul:done()
end

return p