Dev Helpers
← Back

Exhibit audio guide links

Place this file at app/exhibit/[room]/page.tsx in an App Router project.

Open this example in the interactive library

Source code

// app/exhibit/[room]/page.tsx

import Link from "next/link";

import { notFound } from "next/navigation";

export default async function ExhibitAudioGuideLinks({
  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();
  return (
    <ol>
      {Array.from({ length: selected.works }, (_, i) => (
        <li key={i}>
          <Link href={"/audio/" + selected.slug + "/" + (i + 1)}>
            Audio stop {i + 1}
          </Link>
        </li>
      ))}
    </ol>
  );
}