Files
havaran/src/app/articles/[id]/[slug]/page.tsx
T
Alireza HassaniandCursor e4ca605e93 Ship fonts, customer auth menu, contact API, and Meshkee SEO wiring.
Host Iran Yekan/Montserrat locally, link login to customer.havaran.com with a logged-in dropdown, submit contact forms to Meshkee, and publish sitemap-config with canonical id/slug detail URLs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-08 22:53:33 +03:30

65 lines
1.7 KiB
TypeScript

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 (
<>
<Header />
<main>
<PageHero
title={item.title}
titleEn="ARTICLE"
breadcrumb={[
{ label: "صفحه اصلی", href: "/" },
{ label: "مقالات", href: "/articles" },
{ label: item.title, href: blogPath(item) },
]}
/>
<ArticleDetailView item={item} />
</main>
<Footer />
</>
);
}