import { notFound } from "next/navigation" import { getDocsForSlug, getDocsTocs } from "@/lib/markdown" import DocsBreadcrumb from "@/components/DocsBreadcrumb" import Pagination from "@/components/pagination" import Toc from "@/components/toc" import { Typography } from "@/components/typography" import EditThisPage from "@/components/EditWithGithub" import { formatDate2 } from "@/lib/utils" import docuConfig from "@/docu.json" import MobToc from "@/components/DocsSidebar" const { meta } = docuConfig type PageProps = { params: Promise<{ slug: string[] }> } // Function to generate metadata dynamically export async function generateMetadata(props: PageProps) { const params = await props.params const { slug = [] } = params const pathName = slug.join("/") const res = await getDocsForSlug(pathName) if (!res) { return { title: "Page Not Found", description: "The requested page was not found.", } } const { title, description, image } = res.frontmatter // Absolute URL for og:image const ogImage = image ? `${meta.baseURL}/images/${image}` : `${meta.baseURL}/images/og-image.png` return { title: `${title}`, description, openGraph: { title, description, url: `${meta.baseURL}/docs/${pathName}`, type: "article", images: [ { url: ogImage, width: 1200, height: 630, alt: title, }, ], }, twitter: { card: "summary_large_image", title, description, images: [ogImage], }, } } export default async function DocsPage(props: PageProps) { const params = await props.params const { slug = [] } = params const pathName = slug.join("/") const res = await getDocsForSlug(pathName) if (!res) notFound() const { title, description, image: _image, date } = res.frontmatter const filePath = res.filePath const tocs = await getDocsTocs(pathName) return (
{description}
Published on {formatDate2(date)}
)}