fix for static tag page generation

This commit is contained in:
William Grant 2021-12-11 08:16:53 +11:00
parent 296ec378f3
commit d27e330611
2 changed files with 11 additions and 7 deletions

View File

@ -186,8 +186,8 @@ export const getStaticPaths: GetStaticPaths = async () => {
const pageCount = Math.ceil(total / CMS.BLOG_RESULTS_PER_PAGE); const pageCount = Math.ceil(total / CMS.BLOG_RESULTS_PER_PAGE);
const _paths = []; const _paths = [];
for (let i = 1; i <= pageCount; i++) { for (let j = 1; j <= pageCount; j++) {
_paths.push({ params: { slug: [tags[i], String(i)] } }); _paths.push({ params: { slug: [tags[i], String(j)] } });
} }
paths.push(..._paths); paths.push(..._paths);

View File

@ -86,11 +86,15 @@ export class CmsApi {
skip: (page - 1) * quantity, skip: (page - 1) * quantity,
}); });
const results = await this.generateEntries(_entries, 'post'); if (_entries.items.length > 0) {
return { const results = await this.generateEntries(_entries, 'post');
entries: results.entries as Array<IPost>, return {
total: results.total, entries: results.entries as Array<IPost>,
}; total: results.total,
};
}
return Promise.reject(new Error(`Failed to fetch entries for ${tag}`));
} }
public async fetchBlogEntriesWithoutDevUpdates( public async fetchBlogEntriesWithoutDevUpdates(