Open this example in the interactive library
Source code
// app/exhibit/[room]/page.tsx
import { notFound } from "next/navigation";
export default async function RoomCollectionShare({
params,
}: {
params: Promise<{ room: string }>;
}) {
const rooms = [
{ slug: "north", artist: "Liu", works: 8, neighbours: ["east"] },
{ slug: "east", artist: "Roy", works: 5, neighbours: ["north", "west"] },
{ slug: "west", artist: "Diaz", works: 9, neighbours: ["east"] },
];
const { room } = await params;
const selected = rooms.find((r) => r.slug === room);
if (!selected) notFound();
const total = rooms.reduce((s, r) => s + r.works, 0);
return (
<p>
{Math.round((selected.works / total) * 100)}% of the exhibition is in {room}.
</p>
);
}
