{post.frontmatter.title}
{post.frontmatter.description}
import { notFound } from "next/navigation"; import Link from "next/link"; import { getBlogPostBySlug, getAllPosts } from "../../../lib/contentProcessor"; import ContentThumbnailTemplate from "../../components/ContentThumbnailTemplate"; /** * Generate static params for all blog posts * This enables static generation for all blog posts at build time */ export async function generateStaticParams() { try { const posts = getAllPosts(); return posts.map((post) => ({ slug: post.slug, })); } catch (error) { console.error("Error generating static params:", error); return []; } } /** * Generate metadata for each blog post */ export async function generateMetadata({ params }) { try { const { slug } = await params; const post = getBlogPostBySlug(slug); if (!post) { return { title: "Post Not Found", description: "The requested blog post could not be found.", }; } return { title: post.frontmatter.title, description: post.frontmatter.description, authors: [{ name: post.frontmatter.author }], openGraph: { title: post.frontmatter.title, description: post.frontmatter.description, type: "article", publishedTime: post.frontmatter.date, authors: [post.frontmatter.author], }, }; } catch (error) { console.error("Error generating metadata:", error); return { title: "Blog Post", description: "A blog post from our community.", }; } } /** * Dynamic blog post page */ export default async function BlogPostPage({ params }) { // Get the blog post data const { slug } = await params; const post = getBlogPostBySlug(slug); // If post doesn't exist, show 404 if (!post) { notFound(); } // Get related posts (for now, just get other posts) const allPosts = getAllPosts(); const relatedPosts = allPosts.filter((p) => p.slug !== post.slug).slice(0, 3); // Show up to 3 related posts return (
{post.frontmatter.description}