feat: migration von directus zu payloadcms
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 1m19s
Build & Deploy / 🧪 QA (push) Failing after 3m32s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🏗️ Build (push) Failing after 7m51s
Build & Deploy / ⚡ Lighthouse (push) Has been skipped
Build & Deploy / 🧪 Smoke Test (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 10s
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 1m19s
Build & Deploy / 🧪 QA (push) Failing after 3m32s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🏗️ Build (push) Failing after 7m51s
Build & Deploy / ⚡ Lighthouse (push) Has been skipped
Build & Deploy / 🧪 Smoke Test (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 10s
This commit is contained in:
10
lib/mdx.ts
10
lib/mdx.ts
@@ -59,7 +59,7 @@ export async function getProductMetadata(
|
||||
.map((img) => (typeof img === 'string' ? img : img.url))
|
||||
.filter(Boolean);
|
||||
|
||||
if (resolvedImages.length === 0) return null; // Original logic skipped docs without images
|
||||
if (resolvedImages.length === 0) return null;
|
||||
|
||||
return {
|
||||
slug: doc.slug,
|
||||
@@ -152,7 +152,6 @@ export async function getAllProductSlugs(locale: string): Promise<string[]> {
|
||||
}
|
||||
|
||||
export async function getAllProducts(locale: string): Promise<ProductMdx[]> {
|
||||
// Fetch ALL products in a single query to avoid N+1 getPayload() calls
|
||||
const payload = await getPayload({ config: configPromise });
|
||||
|
||||
const selectFields = {
|
||||
@@ -163,7 +162,7 @@ export async function getAllProducts(locale: string): Promise<ProductMdx[]> {
|
||||
categories: true,
|
||||
images: true,
|
||||
locale: true,
|
||||
};
|
||||
} as const;
|
||||
|
||||
// Get products for this locale
|
||||
const result = await payload.find({
|
||||
@@ -193,7 +192,7 @@ export async function getAllProducts(locale: string): Promise<ProductMdx[]> {
|
||||
.filter(Boolean),
|
||||
locale: doc.locale,
|
||||
},
|
||||
content: null, // Avoided loading into memory!
|
||||
content: null,
|
||||
}));
|
||||
|
||||
// Also include English fallbacks for slugs not in this locale
|
||||
@@ -230,7 +229,7 @@ export async function getAllProducts(locale: string): Promise<ProductMdx[]> {
|
||||
locale: doc.locale,
|
||||
isFallback: true,
|
||||
},
|
||||
content: null, // Avoided loading into memory!
|
||||
content: null,
|
||||
}));
|
||||
|
||||
products = [...products, ...fallbacks];
|
||||
@@ -240,7 +239,6 @@ export async function getAllProducts(locale: string): Promise<ProductMdx[]> {
|
||||
}
|
||||
|
||||
export async function getAllProductsMetadata(locale: string): Promise<Partial<ProductMdx>[]> {
|
||||
// Reuse getAllProducts to avoid separate N+1 queries
|
||||
const products = await getAllProducts(locale);
|
||||
return products.map((p) => ({
|
||||
slug: p.slug,
|
||||
|
||||
Reference in New Issue
Block a user