import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { Container } from "@/components/Container"; import { PageHero } from "@/components/layout/PageHero"; import { ProductTabs } from "@/components/product/ProductTabs"; import { Placeholder } from "@/components/Placeholder"; import { blogImage, fetchBlog } from "@/lib/blog"; import { fetchComments } from "@/lib/comments"; import { getBlogPost } from "@/lib/data"; import { formatFaDate } from "@/lib/format"; export const revalidate = 60; export async function generateMetadata({ params, }: { params: Promise<{ slug: string }>; }): Promise { const { slug } = await params; const apiPost = await fetchBlog(slug); if (apiPost) return { title: apiPost.title, description: apiPost.abstract ?? undefined }; const local = getBlogPost(slug); if (!local) return { title: "مقاله" }; return { title: local.title, description: local.excerpt }; } export default async function BlogPostPage({ params, }: { params: Promise<{ slug: string }>; }) { const { slug } = await params; const apiPost = await fetchBlog(slug); if (apiPost) { const comments = await fetchComments("blog", apiPost.id); return ( <>

{formatFaDate(apiPost.publishedAt || apiPost.createdAt)}

{apiPost.abstract ?

{apiPost.abstract}

: null} {apiPost.mainTextHtml ? (
) : null} بازگشت به مقالات
); } const post = getBlogPost(slug); if (!post) notFound(); return ( <>

{post.date}

{post.body.map((paragraph) => (

{paragraph}

))}
بازگشت به مقالات
); }