Open this example in the interactive library
Source code
// app/kitchen/[dish]/page.tsx
import { notFound } from "next/navigation";
export default async function DinnerPlanningDeadline({
params,
}: {
params: Promise<{ dish: string }>;
}) {
const menu = [
{ slug: "soup", mins: [10, 25], ingredients: ["lentils", "stock"], serves: 4 },
{ slug: "toast", mins: [3, 4], ingredients: ["bread", "oil"], serves: 2 },
];
const { dish } = await params;
const recipe = menu.find((r) => r.slug === dish);
if (!recipe) notFound();
const total = recipe.mins.reduce((a, b) => a + b, 0);
const start = 18 * 60 - total;
return (
<p>
For a 6 pm dinner start at {Math.floor(start / 60)}:
{String(start % 60).padStart(2, "0")}.
</p>
);
}
