import { MDXContent } from "@content-collections/mdx/react"; import type { Metadata } from "next"; import { notFound } from "next/navigation"; import { allPosts } from "content-collections"; import type { Post } from "content-collections"; import Image from "next/image"; import AuthorChip from "@/components/author-chip"; export interface PageParams { slug?: string[]; } const getPost = (slug: string[]): Post | null => { const pageSlug = slug.join("/"); for (const post of allPosts) { if (post._meta.path == pageSlug) { return post; } } return null; }; export default async function Page({ params }: { params: PageParams }) { const page = getPost(params.slug!); if (!page) notFound(); return ( <>

{page.title}

{page.summary}

{page.image !== undefined && ( {page.imageDesc!} )}
); } export async function generateStaticParams() { return allPosts.map((page) => ({ slug: page._meta.path.split("/"), })); } export function generateMetadata({ params }: { params: PageParams }) { const page = getPost(params.slug!); if (!page) notFound(); return { title: page.title, description: page.summary, } satisfies Metadata; }