“模块:首页”的版本间的差异
		
		
		
		
		
		跳到导航
		跳到搜索
		
				
		
		
	
| 第33行: | 第33行: | ||
             first = false  |              first = false  | ||
         else  |          else  | ||
| − |              ul:wikitext(",")  | + |              ul:wikitext(", ")  | 
         end  |          end  | ||
         ul:tag("span"):wikitext("[[" .. t .. "]]")  |          ul:tag("span"):wikitext("[[" .. t .. "]]")  | ||
2021年4月2日 (五) 13:51的最新版本
此模块的文档可以在模块:首页/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