import type { Metadata } from "next"; import { notFound } from "next/navigation"; import { getTranslations } from "next-intl/server"; import { CourseDetailTemplate } from "@/components/templates/CourseDetailTemplate"; import { getCourseById } from "@/lib/data/courses"; import { htmlToPlain } from "@/lib/html-text"; import { pageMetadata, truncateMetaDescription } from "@/lib/seo/metadata"; type Props = { params: Promise<{ slug: string }> }; export async function generateMetadata({ params }: Props): Promise { const { slug } = await params; const course = await getCourseById(slug); if (!course) return { title: "دوره یافت نشد" }; const pathSlug = course.slug || slug; return pageMetadata({ title: course.title, description: truncateMetaDescription( course.seoDescription || htmlToPlain(course.summary), ), path: `/register/${pathSlug}`, ...(course.posterImageUrl ? { image: course.posterImageUrl } : {}), }); } export default async function CourseRegisterPage({ params }: Props) { const { slug } = await params; const [course, t] = await Promise.all([ getCourseById(slug), getTranslations("pages"), ]); if (!course) notFound(); return ( ); }