28 lines
861 B
TypeScript
28 lines
861 B
TypeScript
import { notFound } from "next/navigation";
|
|
import { readSchema } from "@/lib/schema.server";
|
|
import { resolveSchemaEntry } from "@/lib/schema-resolver";
|
|
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 resolved = resolveSchemaEntry(schema, lookup);
|
|
if (!resolved) return notFound();
|
|
|
|
return <RenderClient data={resolved.data} route={lookup} />;
|
|
}
|