Module:RecursiveSelectiveList

From Ikwipedia
Revision as of 07:23, 22 December 2024 by EnWikiAdmin (talk | contribs)

Documentation for this module may be created at Module:RecursiveSelectiveList/doc

local p = {}

function p.main(frame)
    local categoryName = frame.args.categoryName or "Category:Example" -- Default category
    local limit = tonumber(frame.args.limit) or 10 -- Default limit

    -- Fetch category members
    local members = mw.site.categoryMembers(categoryName, nil, limit)
    
    -- Build the output
    local results = {}
    for _, member in ipairs(members) do
        table.insert(results, string.format("* [[%s]]", member.title))
    end

    -- Return the results as a bulleted list
    return table.concat(results, "\n")
end

return p