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
+6 -29
View File
@@ -1,42 +1,19 @@
import { Metadata, ResolvingMetadata } from "next";
import { notFound } from "next/navigation";
import { ContactIndexFragment } from "@/gql/graphql";
import { getClient } from "@/app/client";
import {
ContactIndexView,
contactQuery,
loadContactIndexProps,
} from "@/components/contact/ContactIndexView";
import { getSeoMetadata } from "@/lib/seo";
export async function generateMetadata(
{ params }: { params: Promise<{}> },
_: unknown,
parent: ResolvingMetadata
): Promise<Metadata | null> {
const { data, error } = await getClient().query(contactQuery, {});
if (error) {
throw new Error(error.message);
}
if (!data?.index) {
return null;
}
const index = data.index as ContactIndexFragment;
const metadata = await getSeoMetadata(index, parent);
return metadata;
const { index } = await loadContactIndexProps();
return getSeoMetadata(index, parent);
}
export default async function Page() {
const { data, error } = await getClient().query(contactQuery, {});
if (error) {
throw new Error(error.message);
}
if (!data?.index) {
return notFound();
}
const index = data.index as ContactIndexFragment;
return <ContactIndexView index={index} />;
const props = await loadContactIndexProps();
return <ContactIndexView {...props} />;
}