From 320b5782f348d42f6a2bb74a70d4d114525355e4 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Thu, 13 Jan 2022 18:34:27 +0100 Subject: chore: add all posts from CMS to feed --- src/utils/helpers/rss.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/utils/helpers/rss.ts') diff --git a/src/utils/helpers/rss.ts b/src/utils/helpers/rss.ts index 3e7258a..7851ff8 100644 --- a/src/utils/helpers/rss.ts +++ b/src/utils/helpers/rss.ts @@ -1,12 +1,20 @@ import { config } from '@config/website'; import { getPublishedPosts } from '@services/graphql/queries'; import { ArticlePreview } from '@ts/types/articles'; +import { PostsList } from '@ts/types/blog'; import { Feed } from 'feed'; const getAllPosts = async (): Promise => { const posts: ArticlePreview[] = []; - const postsList = await getPublishedPosts({ first: 100 }); - posts.push(...postsList.posts); + let hasNextPage = true; + let after = undefined; + + do { + const postsList: PostsList = await getPublishedPosts({ first: 10, after }); + posts.push(...postsList.posts); + hasNextPage = postsList.pageInfo.hasNextPage; + after = postsList.pageInfo.endCursor; + } while (hasNextPage); return posts; }; -- cgit v1.2.3