import { getArticlesPaginated } from '@/lib/feature/article/article.external';
import { ArticleCard } from '@/ui/components/internal/article-card';
import { ArticleListPagination } from '@/ui/components/internal/article-list-pagination';
import { FileTextIcon } from 'lucide-react';
import { Suspense } from 'react';
const PAGE_SIZE = 9;
const ArticleCardSkeleton = () => (
);
const ArticleListSkeleton = () => (
<>
{Array.from({ length: PAGE_SIZE }).map((_, i) => (
))}
>
);
type ArticleListProps = {
searchParams: Promise<{ page?: string; pageSize?: string }>;
};
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,
total,
} = await getArticlesPaginated(page, pageSize);
return (
<>
{total === 0
? 'No articles published yet.'
: `${total} article${total === 1 ? '' : 's'} published`}
{articles.length === 0 ? (
No articles yet. Check back soon!
) : (
{articles.map((article) => (
))}
)}
{totalPages > 1 && (
Page {page} of {totalPages}
)}
>
);
};
type HomeProps = {
searchParams: Promise<{ page?: string; pageSize?: string }>;
};
const Home = async ({ searchParams }: HomeProps) => {
return (
);
};
export default Home;