Initial commit
This commit is contained in:
26
app/[[...path]]/page.tsx
Normal file
26
app/[[...path]]/page.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import { notFound } from "next/navigation";
|
||||
import { readSchema } from "~/lib/schema.server";
|
||||
import RenderClient from "~/components/RenderClient";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function Page({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ path?: string[] }>;
|
||||
}) {
|
||||
const { path } = await params;
|
||||
const segments = (path ?? []).filter(Boolean);
|
||||
|
||||
// The /edit branch is handled by app/edit; this catch-all only serves view.
|
||||
if (segments[0] === "edit") return notFound();
|
||||
|
||||
const route = "/" + segments.join("/");
|
||||
const lookup = route === "/" ? "/" : route.replace(/\/$/, "");
|
||||
|
||||
const schema = await readSchema();
|
||||
const data = schema[lookup];
|
||||
if (!data) return notFound();
|
||||
|
||||
return <RenderClient data={data} route={lookup} />;
|
||||
}
|
||||
Reference in New Issue
Block a user