@reecem/prismic-sitemap
Advanced tools
Comparing version 0.4.0 to 0.4.2
{ | ||
"name": "@reecem/prismic-sitemap", | ||
"version": "0.4.0", | ||
"version": "0.4.2", | ||
"description": "Sitemap Generator for Prismic and Next.js with Minimal Configuration", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -10,3 +10,3 @@ const Prismic = require("prismic-javascript"); | ||
* @param {Prismic} api prismic client | ||
* @param {Object} options {pageSize, auto} | ||
* @param {Object} options {pageSize} | ||
*/ | ||
@@ -20,10 +20,18 @@ init(api, options = {}) { | ||
/** | ||
* This paginates automatically over the document list from Prismic | ||
* @todo Add Lang support for scoping to a selection of languages. | ||
* | ||
* @param {String} type The Document type | ||
* @param {Number} next The Next Page type | ||
* @returns Promise | ||
*/ | ||
async paginate(type, next = null) { | ||
const { results, total_pages, page } = await this.api.query( | ||
Prismic.Predicates.at("document.type", type), | ||
{ | ||
lang: "*", | ||
pageSize: this.pageSize, | ||
page: next | ||
} | ||
{ | ||
lang: "*", | ||
pageSize: this.pageSize, | ||
page: next | ||
} | ||
); | ||
@@ -33,3 +41,3 @@ | ||
if (total_pages > this.nextPage) { | ||
if (total_pages !== page) { | ||
return this.paginate(type, page + 1) | ||
@@ -36,0 +44,0 @@ } |
23475
223