Module:FeaturedArticle
武外梗百科 爱国好学自强图新的百科全书
更多操作
此模块的文档可以在Module:FeaturedArticle/doc创建
local p = {}
function p.show(frame)
local smw = mw.smw
if not smw then
return "⚠️ Semantic MediaWiki 未启用"
end
-- 查询所有 IsFeatured::Yes 页面
local q = smw.ask{
query = "[[IsFeatured::Yes]]",
limit = 0, -- 获取全部
format = "o" -- 返回对象
}
if not q or #q == 0 then
return "(暂无特色条目)"
end
-- 随机选择一条
math.randomseed(os.time() % 2147483647)
local row = q[math.random(1, #q)]
local title = row.fulltext or row.printouts[1] or "未知页面"
-- 构造卡片 HTML
local html = mw.html.create('div'):addClass('fa-box')
html:tag('div'):addClass('fa-title'):wikitext('⭐ 今日特色条目')
html:tag('div'):addClass('fa-article-title'):wikitext('[['..title..']]')
html:tag('div'):addClass('fa-link'):wikitext('[['..title..'|阅读全文 →]]')
return html:allHtml()
end
return p