“模块:首页”的版本间的差异
跳到导航
跳到搜索
(未显示同一用户的2个中间版本) | |||
第27行: | 第27行: | ||
]] | ]] | ||
local pages = smw.query_pages(query) | local pages = smw.query_pages(query) | ||
− | local ul = mw.html.create( | + | local ul = mw.html.create() |
+ | local first = true | ||
for i, t in ipairs(pages) do | for i, t in ipairs(pages) do | ||
− | ul:tag(" | + | if first then |
+ | first = false | ||
+ | else | ||
+ | ul:wikitext(", ") | ||
+ | end | ||
+ | ul:tag("span"):wikitext("[[" .. t .. "]]") | ||
end | end | ||
return ul:done() | return ul:done() |
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