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);
|
||||
return resolvedImages.length > 0;
|
||||
})
|
||||
.map((doc) => ({
|
||||
slug: doc.slug,
|
||||
frontmatter: {
|
||||
title: doc.title,
|
||||
sku: doc.sku || '',
|
||||
description: doc.description || '',
|
||||
categories: Array.isArray(doc.categories)
|
||||
? doc.categories.map((c: any) => c.category)
|
||||
: [],
|
||||
images: ((doc.images as any[]) || [])
|
||||
.map((img) => (typeof img === 'string' ? img : img.url))
|
||||
.filter(Boolean),
|
||||
locale: doc.locale,
|
||||
},
|
||||
content: null,
|
||||
}));
|
||||
.map((doc) => {
|
||||
const resolvedImages = ((doc.images as any[]) || [])
|
||||
.map((img) => (typeof img === 'string' ? img : img.url))
|
||||
.filter(Boolean) as string[];
|
||||
|
||||
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') {
|
||||
@@ -229,23 +235,29 @@ export async function getAllProducts(locale: string): Promise<ProductMdx[]> {
|
||||
.filter(Boolean);
|
||||
return resolvedImages.length > 0;
|
||||
})
|
||||
.map((doc) => ({
|
||||
slug: doc.slug,
|
||||
frontmatter: {
|
||||
title: doc.title,
|
||||
sku: doc.sku || '',
|
||||
description: doc.description || '',
|
||||
categories: Array.isArray(doc.categories)
|
||||
? doc.categories.map((c: any) => c.category)
|
||||
: [],
|
||||
images: ((doc.images as any[]) || [])
|
||||
.map((img) => (typeof img === 'string' ? img : img.url))
|
||||
.filter(Boolean),
|
||||
locale: doc.locale,
|
||||
isFallback: true,
|
||||
},
|
||||
content: null,
|
||||
}));
|
||||
.map((doc) => {
|
||||
const resolvedImages = ((doc.images as any[]) || [])
|
||||
.map((img) => (typeof img === 'string' ? img : img.url))
|
||||
.filter(Boolean) as string[];
|
||||
|
||||
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),
|
||||
isFallback: true,
|
||||
},
|
||||
content: null,
|
||||
};
|
||||
});
|
||||
|
||||
products = [...products, ...fallbacks];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user