import type { Metadata } from "next"; import Link from "next/link"; import { notFound, redirect } 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 { blogHref, blogImage, blogTitleSlug, fetchBlogById } 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<{ id: string; slug: string }>; }): Promise { const { id } = await params; const apiPost = await fetchBlogById(id); if (apiPost) return { title: apiPost.title, description: apiPost.abstract ?? undefined }; const local = getBlogPost(id); if (!local) return { title: "مقاله" }; return { title: local.title, description: local.excerpt }; } export default async function BlogPostPage({ params, }: { params: Promise<{ id: string; slug: string }>; }) { const { id, slug } = await params; const apiPost = await fetchBlogById(id); if (apiPost) { const canonical = blogTitleSlug(apiPost.title); if (decodeURIComponent(slug) !== canonical) { redirect(blogHref(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(id); if (!post) notFound(); const canonical = blogTitleSlug(post.title); if (decodeURIComponent(slug) !== canonical) { redirect(blogHref({ id: post.slug, title: post.title })); } return ( <>

{post.date}

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

{paragraph}

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