diff --git a/web/src/app/[...url]/page.tsx b/web/src/app/[...url]/page.tsx index c5b8a4c..b742db6 100644 --- a/web/src/app/[...url]/page.tsx +++ b/web/src/app/[...url]/page.tsx @@ -2,9 +2,9 @@ import { graphql } from "@/gql"; import { GenericFragment } from "@/gql/graphql"; import { getClient } from "@/app/client"; import { Blocks } from "@/components/blocks/Blocks"; -import { notFound } from 'next/navigation' +import { notFound } from "next/navigation"; -export const dynamicParams = false +export const dynamicParams = false; const GenericFragmentDefinition = graphql(` fragment Generic on GenericPage { @@ -37,19 +37,20 @@ export async function generateStaticParams() { return data?.pages.map((page: any) => { // wagtail-grapple prepends the home page slug to the full path on multisite setups // we also strip the trailing slash - const urlPath = page.urlPath.replace(/\/home/, "").replace(/\/$/, ""); - console.log("adding", urlPath); + const urlPath = page.urlPath + .replace(/\/home\//, "") + .replace(/\/$/, "") + .split("/"); return { - url: [urlPath], + url: urlPath, }; }); } -export default async function Page({ params }: { params: { url: string } }) { +export default async function Page({ params }: { params: { url: string[] } }) { const { url } = params; // for the page /foo/bar we need to look for `/home/foo/bar/` - const urlPath = `/home/${url}/`; - console.log("real urlPath for", url, "is", urlPath); + const urlPath = `/home/${url.join("/")}/`; const genericPageByUrlPathQuery = graphql(` query genericPageByUrl($urlPath: String!) { @@ -65,11 +66,10 @@ export default async function Page({ params }: { params: { url: string } }) { urlPath: urlPath, }); - const page = (data?.page ?? []) as GenericFragment[]; if (!page) { - return notFound() + return notFound(); } return (