diff --git a/next.config.ts b/next.config.ts index 98dec97..a8262f8 100644 --- a/next.config.ts +++ b/next.config.ts @@ -10,6 +10,7 @@ const nextConfig: NextConfig = { }, ]; }, + cacheComponents: true, }; export default nextConfig; diff --git a/src/app/(pages)/article/[slug]/page.tsx b/src/app/(pages)/article/[slug]/page.tsx index c5947ea..e0735e4 100644 --- a/src/app/(pages)/article/[slug]/page.tsx +++ b/src/app/(pages)/article/[slug]/page.tsx @@ -10,6 +10,10 @@ interface ArticlePageProps { params: Promise<{ slug: string }>; } +interface ArticleContentProps { + params: Promise<{ slug: string }>; +} + function readingTime(text: string): number { const words = text.trim().split(/\s+/).length; return Math.max(1, Math.ceil(words / 200)); @@ -64,7 +68,8 @@ const ArticleContentSkeleton = () => ( ); -const ArticleContent = async ({ slug }: { slug: string }) => { +const ArticleContent = async ({ params }: ArticleContentProps) => { + const { slug } = await params; const article = await getArticleBySlug(slug); if (!article) notFound(); @@ -137,12 +142,10 @@ const ArticleContent = async ({ slug }: { slug: string }) => { ); }; -const ArticlePage = async ({ params }: ArticlePageProps) => { - const { slug } = await params; - +const ArticlePage = ({ params }: ArticlePageProps) => { return ( }> - + ); }; diff --git a/src/app/(pages)/home/page.tsx b/src/app/(pages)/home/page.tsx index edbb635..9111720 100644 --- a/src/app/(pages)/home/page.tsx +++ b/src/app/(pages)/home/page.tsx @@ -37,11 +37,14 @@ const ArticleListSkeleton = () => ( ); interface ArticleListProps { - page: number; - pageSize: number; + searchParams: Promise<{ page?: string; pageSize?: string }>; } -const ArticleList = async ({ page, pageSize }: ArticleListProps) => { +const ArticleList = async ({ searchParams }: ArticleListProps) => { + const { page: pageParam, pageSize: pageSizeParam } = await searchParams; + const page = Math.max(1, Number(pageParam) || 1); + const pageSize = Number(pageSizeParam) || PAGE_SIZE; + const { data: articles, totalPages, @@ -94,10 +97,6 @@ type HomeProps = { }; const Home = async ({ searchParams }: HomeProps) => { - const { page: pageParam, pageSize: pageSizeParam } = await searchParams; - const page = Math.max(1, Number(pageParam) || 1); - const pageSize = Number(pageSizeParam) || PAGE_SIZE; - return (
@@ -109,7 +108,7 @@ const Home = async ({ searchParams }: HomeProps) => {
}> - +
);