diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-01-13 18:34:27 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-01-13 18:34:27 +0100 |
| commit | 320b5782f348d42f6a2bb74a70d4d114525355e4 (patch) | |
| tree | e7d29b73e679f07906068593d0e25bf6f8c728fe /src/utils | |
| parent | 295c9b4bb33bfc21f12715bb9cdaed2ca4d1dd4d (diff) | |
chore: add all posts from CMS to feed
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/helpers/rss.ts | 12 |
1 files changed, 10 insertions, 2 deletions
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<ArticlePreview[]> => { 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; }; |
