import type { Metadata } from "next"; import Link from "next/link"; import { notFound, redirect } from "next/navigation"; import CommentBox from "@/components/CommentBox"; import SlotImage from "@/components/SlotImage"; import { blogDate, blogHref, blogImage, blogTitleSlug, fetchBlogById, getLocalBlogPost, } from "@/lib/blog"; import { fetchComments } from "@/lib/comments"; import { sanitizeHtml } from "@/lib/format"; import { pageMetadata } from "@/lib/seo"; export const revalidate = 60; type Params = { id: string; slug: string }; export async function generateMetadata({ params, }: { params: Promise; }): Promise { const { id } = await params; const post = (await fetchBlogById(id)) ?? getLocalBlogPost(id); if (!post) { return { title: "مقاله یافت نشد", description: "این مطلب در وبلاگ پنجره فرخ موجود نیست.", robots: { index: false }, }; } return pageMetadata({ title: post.title, description: post.abstract?.trim() || `${post.title} | مقالات پنجره فرخ`, path: blogHref(post), image: blogImage(post), }); } export default async function BlogDetailPage({ params }: { params: Promise }) { const { id, slug } = await params; const apiPost = await fetchBlogById(id); const post = apiPost ?? getLocalBlogPost(id); if (!post) notFound(); const canonical = blogTitleSlug(post.title); if (decodeURIComponent(slug) !== canonical) { redirect(blogHref(post)); } const comments = apiPost ? await fetchComments("blog", post.id) : []; const html = sanitizeHtml(post.mainTextHtml); return ( <>
ARTICLE

{post.title}

{blogDate(post) ?

{blogDate(post)}

: null}
{blogImage(post) ? (
) : null} {post.abstract ?

{post.abstract}

: null} {html ?
: null}

نظرات

{apiPost ? ( ) : (

ثبت نظر برای این مطلب در دسترس نیست.

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