Skip to content

Commit 1ae37f6

Browse files
committed
refactor: show all related posts with "load more" by removing server-side slice
1 parent aaa71bf commit 1ae37f6

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

pages/post/[id].tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ export const getStaticProps: ({params}: { params: any }) => Promise<{
4949
(post) =>
5050
post.id !== postData.id &&
5151
post.tags?.some((tag) => postData.tags?.includes(tag))
52-
)
53-
.slice(0, 5);
52+
);
5453

5554
return {
5655
props: {
@@ -159,7 +158,7 @@ export default function Post({ postData, relatedPosts }: InferGetStaticPropsType
159158
{hasMoreRelated && (
160159
<div className="mt-6 text-center">
161160
<button
162-
onClick={() => setVisibleRelatedCount((prev) => prev + 5)}
161+
onClick={() => setVisibleRelatedCount((prev) => prev + 3)}
163162
className="px-5 py-2 text-sm font-medium rounded-md bg-gray-200 hover:bg-gray-300 text-gray-800 dark:bg-gray-700 dark:hover:bg-gray-600 dark:text-white transition"
164163
>
165164
더 보기

0 commit comments

Comments
 (0)