fix some build errors

This commit is contained in:
2024-05-12 23:56:03 +02:00
parent ba43da1556
commit 780e2c7fed
3 changed files with 17 additions and 5 deletions

View File

@ -33,12 +33,16 @@ export async function generateStaticParams() {
} }
} }
`); `);
const { data } = await getClient().query(allGenericSlugsQuery, {}); const { data, error } = await getClient().query(allGenericSlugsQuery, {});
if (data === undefined || error) {
throw new Error("failed to generate static params");
}
return data?.pages.map((page: any) => { return data?.pages.map((page: any) => {
// wagtail-grapple prepends the home page slug to the full path on multisite setups // wagtail-grapple prepends the home page slug to the full path on multisite setups
// we also strip the trailing slash // we also strip the trailing slash
const urlPath = page.urlPath const urlPath: string[] = page.urlPath
.replace(/\/home\//, "") .replace(/\/home\//, "")
.replace(/\/$/, "") .replace(/\/$/, "")
.split("/"); .split("/");
@ -67,7 +71,7 @@ export default async function Page({ params }: { params: { url: string[] } }) {
urlPath: urlPath, urlPath: urlPath,
}); });
const page = (data?.page ?? []) as GenericFragment[]; const page = (data?.page ?? []) as GenericFragment;
if (!page) { if (!page) {
return notFound(); return notFound();

View File

@ -14,7 +14,11 @@ export async function generateStaticParams() {
} }
} }
`); `);
const { data } = await getClient().query(allEventSlugsQuery); const { data, error } = await getClient().query(allEventSlugsQuery, {});
if (data === undefined || error) {
throw new Error("failed to generate static params");
}
return data?.pages.map((page: any) => ({ return data?.pages.map((page: any) => ({
slug: page.slug, slug: page.slug,

View File

@ -13,7 +13,11 @@ export async function generateStaticParams() {
} }
} }
`); `);
const { data } = await getClient().query(allVenueSlugsQuery); const { data, error } = await getClient().query(allVenueSlugsQuery, {});
if (data === undefined || error) {
throw new Error("failed to generate static params");
}
return data?.pages.map((page: any) => ({ return data?.pages.map((page: any) => ({
slug: page.slug, slug: page.slug,