import { notFound } from 'next/navigation' import { CustomMDX } from '@/components/mdx' import { formatDate, getBlogPosts } from '../utils' import { baseUrl } from '../../sitemap' export async function generateStaticParams() { let posts = getBlogPosts() return posts.map((post) => ({ slug: post.slug, })) } export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }) { const { slug } = await params; const post = getBlogPosts().find((post) => post.slug === slug) if (!post) { return } const { title, publishedAt: publishedTime, summary: description, image, } = post.metadata const ogImage = image ? image : `${baseUrl}/og?title=${encodeURIComponent(title)}` return { title, description, openGraph: { title, description, type: 'article', publishedTime, url: `${baseUrl}/blog/${post.slug}`, images: [ { url: ogImage, }, ], }, twitter: { card: 'summary_large_image', title, description, images: [ogImage], }, } } export default async function Blog({ params }: { params: Promise<{ slug: string }> }) { const { slug } = await params; const post = getBlogPosts().find((post) => post.slug === slug) if (!post) { notFound() } return (