import { Placeholder } from "@/components/ui/Placeholder"; import { EmptyState } from "@/components/ui/EmptyState"; import { getBlogs } from "@/lib/meshkee"; const PAGE_SIZE = 12; function formatDate(iso?: string) { if (!iso) return ""; return new Intl.DateTimeFormat("fa-IR", { dateStyle: "long" }).format(new Date(iso)); } export default async function BlogListPage({ searchParams, }: { searchParams: Promise<{ page?: string }>; }) { const params = await searchParams; const page = Math.max(1, Number(params.page ?? 1) || 1); const { items, total } = await getBlogs({ page, pageSize: PAGE_SIZE }); const totalPages = Math.max(1, Math.ceil(total / PAGE_SIZE)); return (

وبلاگ

{items.length === 0 ? ( ) : ( <>
{items.map((post) => (
{post.categoryName && {post.categoryName}} {post.publishedAt && {formatDate(post.publishedAt)}}

{post.title}

{post.abstract && (

{post.abstract}

)}
))}
{totalPages > 1 && (
{page > 1 ? ( قبلی ) : ( قبلی )} صفحه {page} از {totalPages} {page < totalPages ? ( بعدی ) : ( بعدی )}
)} )}
); }