import { notFound, permanentRedirect } from "next/navigation";
import { Footer } from "@/components/Footer";
import { Header } from "@/components/Header";
import { PageHero } from "@/components/PageShared";
import { ArticleDetailView } from "@/components/ArticleDetail";
import { getBlogById } from "@/lib/meshkee";
import { pageMetadata } from "@/lib/seo";
import { blogPath, blogTitleSlug } from "@/lib/urls";
type PageProps = {
params: Promise<{ id: string; slug: string }>;
};
export async function generateMetadata({ params }: PageProps) {
const { id } = await params;
const { item } = await getBlogById(id);
if (!item) {
return pageMetadata({
title: "مقاله",
description: "مقاله مورد نظر یافت نشد.",
path: `/articles/${id}`,
noIndex: true,
});
}
const description = item.excerpt || item.title;
return pageMetadata({
title: item.title,
description,
path: blogPath(item),
image: item.image || undefined,
});
}
export default async function ArticleDetailPage({ params }: PageProps) {
const { id, slug: slugParam } = await params;
const slug = decodeURIComponent(slugParam);
const { item } = await getBlogById(id);
if (!item) notFound();
const canonicalSlug = blogTitleSlug(item);
if (slug !== canonicalSlug) {
permanentRedirect(blogPath(item));
}
return (
<>
>
);
}