打开/关闭菜单
46
56
27
964
武外梗百科
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

Module:FeaturedArticle

武外梗百科 爱国好学自强图新的百科全书
Zelda110留言 | 贡献2025年11月30日 (日) 12:38的版本 (创建页面,内容为“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.…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

此模块的文档可以在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