import type { Metadata } from "next"; import Image from "next/image"; import Link from "next/link"; import { notFound } from "next/navigation"; import { MDXRemote } from "next-mdx-remote/rsc"; import { mdxComponents } from "@/components/blogComponents"; import { getAllPosts, getPostBySlug } from "@/lib/blogUtils"; import type { BlogParams } from "@/lib/types"; export function generateStaticParams() { return getAllPosts().map((post) => ({ slug: post.slug })); } export async function generateMetadata({ params, }: { params: BlogParams; }): Promise { const { slug } = await params; const post = getPostBySlug({ slug }); if (!post) return { title: "Post Not Found" }; return { title: post.title, description: post.description, openGraph: { title: post.title, description: post.description, type: "article", ...(post.date ? { publishedTime: post.date } : {}), authors: [post.author], ...(post.image && { images: [{ url: post.image }], }), }, }; } function formatDate(dateString: string | null) { if (!dateString) return ""; return new Date(dateString).toLocaleDateString("en-US", { year: "numeric", month: "long", day: "numeric", }); } export default async function BlogPostPage({ params }: { params: BlogParams }) { const { slug } = await params; const post = getPostBySlug({ slug }); if (!post) notFound(); return (
Back to blog
{formatDate(post.date)} {post.author}

{post.title}

{post.description && (

)}

{post.image && (
{post.title}
)}
); }