only act on pages in article namespace
This commit is contained in:
parent
ceb3df2fdb
commit
c86fb77f9e
2 changed files with 10 additions and 3 deletions
|
|
@ -165,16 +165,23 @@ export class MediaWikiClient {
|
|||
/**
|
||||
* Gets the list of wiki pages that belong to the given category.
|
||||
* @param {string} name Category name including the `Category:` namespace.
|
||||
* @param {number[] | '*'} namespaces Integer namespace ID(s) or the string
|
||||
* `'*'`. If namespace IDs are provided, only pages in those namespaces will
|
||||
* be returned.
|
||||
* @param {string} limit Maximum number of items to return. Must be 500 or
|
||||
* less. I'm lazy and not supporting API paging so deal with it.
|
||||
* @returns {Promise<{pageid: number; title: string}[]>}
|
||||
*/
|
||||
async listCategoryPages (name, limit = 50) {
|
||||
async listCategoryPages (name, namespaces = '*', limit = 50) {
|
||||
if (Array.isArray(namespaces)) {
|
||||
namespaces = namespaces.join('|');
|
||||
}
|
||||
const body = await this.fetchApiGet({
|
||||
action: 'query',
|
||||
list: 'categorymembers',
|
||||
cmtitle: name,
|
||||
cmlimit: limit,
|
||||
cmnamespace: namespaces,
|
||||
});
|
||||
return body.query.categorymembers;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue