Open this example in the interactive library
Source code
// app/docs/[[...parts]]/page.tsx
import Link from "next/link";
export default async function NestedParentTopic({
params,
}: {
params: Promise<{ parts?: string[] }>;
}) {
const { parts = [] } = await params;
const parent = ["", "docs", ...parts.slice(0, -1).map(encodeURIComponent)].join("/");
return (
<main>
<h1>{parts.at(-1) ?? "Docs"}</h1>
{parts.length > 0 && <Link href={parent}>Parent topic</Link>}
</main>
);
}
