fix: aggressively serialize getAllProducts output to prevent React RSC stream errors
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 7s
Build & Deploy / 🧪 QA (push) Successful in 2m17s
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / ♿ WCAG (push) Has been cancelled
Build & Deploy / 🛡️ Quality Gates (push) Has been cancelled
Build & Deploy / 🏗️ Build (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 7s
Build & Deploy / 🧪 QA (push) Successful in 2m17s
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / ♿ WCAG (push) Has been cancelled
Build & Deploy / 🛡️ Quality Gates (push) Has been cancelled
Build & Deploy / 🏗️ Build (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
This commit is contained in:
78
lib/mdx.ts
78
lib/mdx.ts
@@ -193,22 +193,28 @@ export async function getAllProducts(locale: string): Promise<ProductMdx[]> {
|
|||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
return resolvedImages.length > 0;
|
return resolvedImages.length > 0;
|
||||||
})
|
})
|
||||||
.map((doc) => ({
|
.map((doc) => {
|
||||||
slug: doc.slug,
|
const resolvedImages = ((doc.images as any[]) || [])
|
||||||
frontmatter: {
|
.map((img) => (typeof img === 'string' ? img : img.url))
|
||||||
title: doc.title,
|
.filter(Boolean) as string[];
|
||||||
sku: doc.sku || '',
|
|
||||||
description: doc.description || '',
|
const plainCategories = Array.isArray(doc.categories)
|
||||||
categories: Array.isArray(doc.categories)
|
? doc.categories.map((c: any) => String(c.category))
|
||||||
? doc.categories.map((c: any) => c.category)
|
: [];
|
||||||
: [],
|
|
||||||
images: ((doc.images as any[]) || [])
|
return {
|
||||||
.map((img) => (typeof img === 'string' ? img : img.url))
|
slug: String(doc.slug),
|
||||||
.filter(Boolean),
|
frontmatter: {
|
||||||
locale: doc.locale,
|
title: String(doc.title),
|
||||||
},
|
sku: doc.sku ? String(doc.sku) : '',
|
||||||
content: null,
|
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
|
// Also include English fallbacks for slugs not in this locale
|
||||||
if (locale !== 'en') {
|
if (locale !== 'en') {
|
||||||
@@ -229,23 +235,29 @@ export async function getAllProducts(locale: string): Promise<ProductMdx[]> {
|
|||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
return resolvedImages.length > 0;
|
return resolvedImages.length > 0;
|
||||||
})
|
})
|
||||||
.map((doc) => ({
|
.map((doc) => {
|
||||||
slug: doc.slug,
|
const resolvedImages = ((doc.images as any[]) || [])
|
||||||
frontmatter: {
|
.map((img) => (typeof img === 'string' ? img : img.url))
|
||||||
title: doc.title,
|
.filter(Boolean) as string[];
|
||||||
sku: doc.sku || '',
|
|
||||||
description: doc.description || '',
|
const plainCategories = Array.isArray(doc.categories)
|
||||||
categories: Array.isArray(doc.categories)
|
? doc.categories.map((c: any) => String(c.category))
|
||||||
? doc.categories.map((c: any) => c.category)
|
: [];
|
||||||
: [],
|
|
||||||
images: ((doc.images as any[]) || [])
|
return {
|
||||||
.map((img) => (typeof img === 'string' ? img : img.url))
|
slug: String(doc.slug),
|
||||||
.filter(Boolean),
|
frontmatter: {
|
||||||
locale: doc.locale,
|
title: String(doc.title),
|
||||||
isFallback: true,
|
sku: doc.sku ? String(doc.sku) : '',
|
||||||
},
|
description: doc.description ? String(doc.description) : '',
|
||||||
content: null,
|
categories: plainCategories,
|
||||||
}));
|
images: resolvedImages,
|
||||||
|
locale: String(doc.locale),
|
||||||
|
isFallback: true,
|
||||||
|
},
|
||||||
|
content: null,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
products = [...products, ...fallbacks];
|
products = [...products, ...fallbacks];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user