import type { Metadata } from "next"; import Link from "next/link"; import { SectionTitle } from "@/components/SectionTitle"; import { site } from "@/data/site"; import { fetchPortfolios, getLocalPortfolios, portfolioCover, portfolioHref, portfolioTitle, } from "@/lib/portfolio"; export const revalidate = 300; export const metadata: Metadata = { title: "نمونه کارها", description: `نمونه کارهای ${site.nameFa} در معماری، طراحی داخلی و طراحی نما.`, }; export default async function PortfolioPage({ searchParams, }: { searchParams: Promise<{ page?: string }>; }) { const { page: pageRaw } = await searchParams; const page = Math.max(1, Number(pageRaw) || 1); const pageSize = 12; const result = await fetchPortfolios({ page, pageSize }); const usingApi = result.items.length > 0; const items = usingApi ? result.items : page === 1 ? getLocalPortfolios() : []; const total = usingApi ? result.total : items.length; const totalPages = Math.max(1, Math.ceil(total / pageSize)); return ( <>
{items.length === 0 ? (

هنوز نمونه کاری منتشر نشده است.

) : (
{items.map((item) => { const title = portfolioTitle(item); return (
{title}

{title}

{item.categoryName || item.abstract ? ( {item.categoryName || item.abstract} ) : null}
{item.titleEn ?

{item.titleEn}

: null} ); })}
)} {totalPages > 1 && items.length ? ( ) : null}
); }