web: centralize prop fetching for live + preview, fix preview banner breakage

This commit is contained in:
2026-05-19 18:37:58 +02:00
parent a5ebb897f1
commit e960da6f1c
31 changed files with 582 additions and 591 deletions
+7 -32
View File
@@ -1,11 +1,10 @@
import { graphql } from "@/gql";
import { GenericFragment } from "@/gql/graphql";
import { getClient } from "@/app/client";
import { Metadata, ResolvingMetadata } from "next";
import { notFound } from "next/navigation";
import {
GenericPageView,
genericPageByUrlPathQuery,
loadGenericPageProps,
} from "@/components/general/GenericPageView";
import { getSeoMetadata } from "@/lib/seo";
@@ -53,38 +52,14 @@ export async function generateMetadata(
parent: ResolvingMetadata
): Promise<Metadata | null> {
const { url } = await params;
const urlPath = getWagtailUrlPath(url);
const { data, error } = await getClient().query(genericPageByUrlPathQuery, {
urlPath: urlPath,
});
if (error) {
throw new Error(error.message);
}
if (!data?.page) {
return null;
}
const page = data.page as GenericFragment;
const metadata = await getSeoMetadata(page, parent);
return metadata;
const props = await loadGenericPageProps({ urlPath: getWagtailUrlPath(url) });
if (!props) return null;
return getSeoMetadata(props.page, parent);
}
export default async function Page({ params }: { params: Params }) {
const { url } = await params;
const urlPath = getWagtailUrlPath(url);
const { data, error } = await getClient().query(genericPageByUrlPathQuery, {
urlPath: urlPath,
});
if (error) {
throw new Error(error.message);
}
if (!data?.page) {
return notFound();
}
const page = data?.page as GenericFragment;
return <GenericPageView page={page} />;
const props = await loadGenericPageProps({ urlPath: getWagtailUrlPath(url) });
if (!props) return notFound();
return <GenericPageView {...props} />;
}