Module:LatestPages:修订间差异
武外梗百科 爱国好学自强图新的百科全书
更多操作
创建页面,内容为“local p = {} function p.render(frame) local limit = tonumber(frame.args.count) or 6 local pages = mw.site.stats.pagesInCategory -- 占位,强制加载 local api = mw.api local result = api.get({ action = "query", list = "recentchanges", rctype = "new", rcnamespace = 0, rclimit = limit, rcprop = "title|timestamp" }) if not result or not result.query or not result.query.recentchanges th…” |
无编辑摘要 |
||
| 第4行: | 第4行: | ||
local limit = tonumber(frame.args.count) or 6 | local limit = tonumber(frame.args.count) or 6 | ||
local | local result = mw.api.get({ | ||
action = "query", | action = "query", | ||
list = "recentchanges", | list = "recentchanges", | ||
| 第16行: | 第13行: | ||
}) | }) | ||
if not result or not result.query or not result.query.recentchanges then | if not result | ||
or not result.query | |||
or not result.query.recentchanges | |||
or #result.query.recentchanges == 0 | |||
then | |||
return "<p>暂无最新页面。</p>" | return "<p>暂无最新页面。</p>" | ||
end | end | ||
2025年12月13日 (六) 21:09的最新版本
此模块的文档可以在Module:LatestPages/doc创建
local p = {}
function p.render(frame)
local limit = tonumber(frame.args.count) or 6
local result = mw.api.get({
action = "query",
list = "recentchanges",
rctype = "new",
rcnamespace = 0,
rclimit = limit,
rcprop = "title|timestamp"
})
if not result
or not result.query
or not result.query.recentchanges
or #result.query.recentchanges == 0
then
return "<p>暂无最新页面。</p>"
end
local html = mw.html.create("div"):addClass("latest-list")
for _, item in ipairs(result.query.recentchanges) do
local row = mw.html.create("div")
:addClass("latest-item")
row:tag("div")
:addClass("latest-title")
:wikitext(string.format("[[%s]]", item.title))
html:node(row)
end
return tostring(html)
end
return p