fix: make sitemap dynamic, fix baseUrl logic, and relax product image filter
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 13s
Build & Deploy / 🧪 QA (push) Successful in 2m18s
Build & Deploy / 🏗️ Build (push) Successful in 5m49s
Build & Deploy / 🚀 Deploy (push) Successful in 23s
Build & Deploy / 🧪 Post-Deploy Verification (push) Failing after 2m19s
Build & Deploy / ⚡ Performance & Accessibility (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 1s

This commit is contained in:
2026-02-25 12:48:29 +01:00
parent 5652f27c71
commit 44d3e8585b
4 changed files with 77 additions and 37 deletions

View File

@@ -123,6 +123,8 @@ export async function getAllPosts(locale: string): Promise<PostMdx[]> {
limit: 100,
});
console.log(`[Payload] getAllPosts for ${locale}: Found ${docs.length} docs`);
return docs.map((doc) => {
return {
slug: doc.slug,

View File

@@ -186,35 +186,30 @@ export async function getAllProducts(locale: string): Promise<ProductMdx[]> {
select: selectFields,
});
let products: ProductMdx[] = result.docs
.filter((doc) => {
const resolvedImages = ((doc.images as any[]) || [])
.map((img) => (typeof img === 'string' ? img : img.url))
.filter(Boolean);
return resolvedImages.length > 0;
})
.map((doc) => {
const resolvedImages = ((doc.images as any[]) || [])
.map((img) => (typeof img === 'string' ? img : img.url))
.filter(Boolean) as string[];
console.log(`[Payload] getAllProducts for ${locale}: Found ${result.docs.length} docs`);
const plainCategories = Array.isArray(doc.categories)
? doc.categories.map((c: any) => String(c.category))
: [];
let products: ProductMdx[] = result.docs.map((doc) => {
const resolvedImages = ((doc.images as any[]) || [])
.map((img) => (typeof img === 'string' ? img : img.url))
.filter(Boolean) as string[];
return {
slug: String(doc.slug),
frontmatter: {
title: String(doc.title),
sku: doc.sku ? String(doc.sku) : '',
description: doc.description ? String(doc.description) : '',
categories: plainCategories,
images: resolvedImages,
locale: String(doc.locale),
},
content: null,
};
});
const plainCategories = Array.isArray(doc.categories)
? doc.categories.map((c: any) => String(c.category))
: [];
return {
slug: String(doc.slug),
frontmatter: {
title: String(doc.title),
sku: doc.sku ? String(doc.sku) : '',
description: doc.description ? String(doc.description) : '',
categories: plainCategories,
images: resolvedImages,
locale: String(doc.locale),
},
content: null,
};
});
// Also include English fallbacks for slugs not in this locale
if (locale !== 'en') {
@@ -227,14 +222,12 @@ export async function getAllProducts(locale: string): Promise<ProductMdx[]> {
select: selectFields,
});
console.log(
`[Payload] getAllProducts (en fallbacks) for ${locale}: Found ${enResult.docs.length} docs`,
);
const fallbacks = enResult.docs
.filter((doc) => !localeSlugs.has(doc.slug))
.filter((doc) => {
const resolvedImages = ((doc.images as any[]) || [])
.map((img) => (typeof img === 'string' ? img : img.url))
.filter(Boolean);
return resolvedImages.length > 0;
})
.map((doc) => {
const resolvedImages = ((doc.images as any[]) || [])
.map((img) => (typeof img === 'string' ? img : img.url))