From 1af3328e3aecf4dc421ec4dd71499a7c5fdd8449 Mon Sep 17 00:00:00 2001 From: WakuwakuP Date: Thu, 7 Nov 2024 04:05:22 +0900 Subject: [PATCH] Update `page.tsx` to fetch and pass next and previous articles * Change cache keys and tags for `cachedGetNextArticle` and `cachedGetPreviousArticle` to match `cachedGetContentDetail` * Fetch next and previous articles using `cachedGetNextArticle` and `cachedGetPreviousArticle` * Pass next and previous articles as props to `ContentDetail` component --- src/app/content/detail/[id]/page.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/app/content/detail/[id]/page.tsx b/src/app/content/detail/[id]/page.tsx index d22d5a5..fedf909 100644 --- a/src/app/content/detail/[id]/page.tsx +++ b/src/app/content/detail/[id]/page.tsx @@ -62,9 +62,9 @@ const cachedGetNextArticle = (publishedAt: string) => async () => { return await getNextArticle(publishedAt) }, - ['next-article', publishedAt], + ['content-detail-next', publishedAt], { - tags: ['next-article'], + tags: ['content-detail'], }, ) @@ -73,9 +73,9 @@ const cachedGetPreviousArticle = (publishedAt: string) => async () => { return await getPreviousArticle(publishedAt) }, - ['previous-article', publishedAt], + ['content-detail-previous', publishedAt], { - tags: ['previous-article'], + tags: ['content-detail'], }, ) @@ -89,8 +89,11 @@ export default async function ContentDetailPage({ params }: { params: { id: stri } const content = data - const nextArticle = cachedGetNextArticle(content.publishedAt) - const previousArticle = cachedGetPreviousArticle(content.publishedAt) + + const getNextArticle = cachedGetNextArticle(content.publishedAt) + const getPreviousArticle = cachedGetPreviousArticle(content.publishedAt) + const nextArticle = await getNextArticle() + const previousArticle = await getPreviousArticle() return (