feat: refactor article components to use searchParams for pagination and improve content loading

This commit is contained in:
2026-04-11 01:13:15 -03:00
parent 34a662fb30
commit f62e1c4180
3 changed files with 16 additions and 13 deletions

View File

@@ -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 = () => (
</article>
);
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 (
<Suspense fallback={<ArticleContentSkeleton />}>
<ArticleContent slug={slug} />
<ArticleContent params={params} />
</Suspense>
);
};