import { notFound } from 'next/navigation'; import type { Metadata } from 'next'; import { getRecipeByCategoryAndSlug, getAllRecipePaths } from '@/lib/recipes'; interface RecipePageProps { params: Promise<{ category: string; slug: string; }>; } export async function generateStaticParams() { const paths = getAllRecipePaths(); return paths.map((path) => ({ category: path.category, slug: path.slug, })); } export async function generateMetadata({ params }: RecipePageProps): Promise { const { category, slug } = await params; const recipe = getRecipeByCategoryAndSlug(category, slug); if (!recipe) { return { title: 'Recipe Not Found', }; } return { title: `${recipe.title} - Cooking`, description: recipe.description, keywords: recipe.tags, openGraph: { title: recipe.title, description: recipe.description, type: 'article', }, }; } export default async function RecipePage({ params }: RecipePageProps) { const { category, slug } = await params; const recipe = getRecipeByCategoryAndSlug(category, slug); if (!recipe) { notFound(); } return (
{recipe.category} {recipe.lastUpdated !== recipe.date && ( <> )}

{recipe.title}

{recipe.description}

Prep: {recipe.prepTime} min
Cook: {recipe.cookTime} min
Total: {recipe.totalTime} min
Servings: {recipe.servings}
Difficulty: {recipe.difficulty}
{recipe.tags.map((tag) => ( {tag} ))}

Recipe content will be rendered here from MDX

            {recipe.content.substring(0, 500)}...
          
); }