From abf6e96383035f99addab804e8c3dd1a74d36375 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Fri, 17 Dec 2021 17:58:03 +0100 Subject: chore: display comments list on posts --- src/services/graphql/post.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/services') diff --git a/src/services/graphql/post.ts b/src/services/graphql/post.ts index 2ce918b..e827fd4 100644 --- a/src/services/graphql/post.ts +++ b/src/services/graphql/post.ts @@ -104,7 +104,10 @@ const fetchPostBySlug: FetchPostByReturn = async (slug: string) => { export const getPostBySlug: GetPostByReturn = async (slug: string) => { const rawPost = await fetchPostBySlug(slug); - const comments = rawPost.postBy.comments.nodes; + const comments = rawPost.postBy.comments.nodes.reverse().map((comment) => { + const author = comment.author.node; + return { ...comment, author: author, replies: [] }; + }); const content = rawPost.postBy.contentParts.afterMore; const featuredImage = rawPost.postBy.featuredImage ? rawPost.postBy.featuredImage.node -- cgit v1.2.3