fix: build stability (added try-catch to payload queries and removed generateStaticParams from generic pages)
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 9s
Build & Deploy / 🧪 QA (push) Failing after 3m20s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🏗️ Build (push) Successful in 14m43s
Build & Deploy / 🧪 Smoke Test (push) Has been skipped
Build & Deploy / ⚡ Lighthouse (push) Has been skipped
Build & Deploy / ♿ WCAG (push) Has been skipped
Build & Deploy / 🛡️ Quality Gates (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 13s

This commit is contained in:
2026-02-24 19:45:33 +01:00
parent f7aa880d9f
commit d57700d322
6 changed files with 292 additions and 262 deletions

View File

@@ -16,97 +16,112 @@ export interface PageMdx {
}
export async function getPageBySlug(slug: string, locale: string): Promise<PageMdx | null> {
const payload = await getPayload({ config: configPromise });
try {
const payload = await getPayload({ config: configPromise });
const result = await payload.find({
collection: 'pages' as any,
where: {
slug: { equals: slug },
locale: { equals: locale },
},
limit: 1,
});
const result = await payload.find({
collection: 'pages' as any,
where: {
slug: { equals: slug },
locale: { equals: locale },
},
limit: 1,
});
const docs = result.docs as any[];
const docs = result.docs as any[];
if (!docs || docs.length === 0) return null;
if (!docs || docs.length === 0) return null;
const doc = docs[0];
const doc = docs[0];
return {
slug: doc.slug,
frontmatter: {
title: doc.title,
excerpt: doc.excerpt || '',
locale: doc.locale,
featuredImage:
typeof doc.featuredImage === 'object' && doc.featuredImage !== null
? doc.featuredImage.sizes?.card?.url || doc.featuredImage.url
: null,
} as PageFrontmatter,
content: doc.content as any, // Native Lexical Editor State
};
return {
slug: doc.slug,
frontmatter: {
title: doc.title,
excerpt: doc.excerpt || '',
locale: doc.locale,
featuredImage:
typeof doc.featuredImage === 'object' && doc.featuredImage !== null
? doc.featuredImage.sizes?.card?.url || doc.featuredImage.url
: null,
} as PageFrontmatter,
content: doc.content as any, // Native Lexical Editor State
};
} catch (error) {
console.error(`[Payload] getPageBySlug failed for ${slug}:`, error);
return null;
}
}
export async function getAllPages(locale: string): Promise<PageMdx[]> {
const payload = await getPayload({ config: configPromise });
try {
const payload = await getPayload({ config: configPromise });
const result = await payload.find({
collection: 'pages' as any,
where: {
locale: {
equals: locale,
const result = await payload.find({
collection: 'pages' as any,
where: {
locale: {
equals: locale,
},
},
},
limit: 100,
});
limit: 100,
});
const docs = result.docs as any[];
const docs = result.docs as any[];
return docs.map((doc: any) => {
return {
slug: doc.slug,
frontmatter: {
title: doc.title,
excerpt: doc.excerpt || '',
locale: doc.locale,
featuredImage:
typeof doc.featuredImage === 'object' && doc.featuredImage !== null
? doc.featuredImage.sizes?.card?.url || doc.featuredImage.url
: null,
} as PageFrontmatter,
content: doc.content as any,
};
});
return docs.map((doc: any) => {
return {
slug: doc.slug,
frontmatter: {
title: doc.title,
excerpt: doc.excerpt || '',
locale: doc.locale,
featuredImage:
typeof doc.featuredImage === 'object' && doc.featuredImage !== null
? doc.featuredImage.sizes?.card?.url || doc.featuredImage.url
: null,
} as PageFrontmatter,
content: doc.content as any,
};
});
} catch (error) {
console.error(`[Payload] getAllPages failed for ${locale}:`, error);
return [];
}
}
export async function getAllPagesMetadata(locale: string): Promise<Partial<PageMdx>[]> {
const payload = await getPayload({ config: configPromise });
try {
const payload = await getPayload({ config: configPromise });
const result = await payload.find({
collection: 'pages' as any,
where: {
locale: {
equals: locale,
const result = await payload.find({
collection: 'pages' as any,
where: {
locale: {
equals: locale,
},
},
},
limit: 100,
});
limit: 100,
});
const docs = result.docs as any[];
const docs = result.docs as any[];
return docs.map((doc: any) => {
return {
slug: doc.slug,
frontmatter: {
title: doc.title,
excerpt: doc.excerpt || '',
locale: doc.locale,
featuredImage:
typeof doc.featuredImage === 'object' && doc.featuredImage !== null
? doc.featuredImage.sizes?.card?.url || doc.featuredImage.url
: null,
} as PageFrontmatter,
};
});
return docs.map((doc: any) => {
return {
slug: doc.slug,
frontmatter: {
title: doc.title,
excerpt: doc.excerpt || '',
locale: doc.locale,
featuredImage:
typeof doc.featuredImage === 'object' && doc.featuredImage !== null
? doc.featuredImage.sizes?.card?.url || doc.featuredImage.url
: null,
} as PageFrontmatter,
};
});
} catch (error) {
console.error(`[Payload] getAllPagesMetadata failed for ${locale}:`, error);
return [];
}
}