From e76692c9ba9470b6a4b83eff3eda1649c1e2867e Mon Sep 17 00:00:00 2001 From: rasm-its Date: Wed, 5 Aug 2026 16:38:25 +0200 Subject: [PATCH] fixed resolveRoute.ts --- src/modules/content/resolveRoute.ts | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/modules/content/resolveRoute.ts b/src/modules/content/resolveRoute.ts index fc521f5..46c24bc 100644 --- a/src/modules/content/resolveRoute.ts +++ b/src/modules/content/resolveRoute.ts @@ -82,12 +82,26 @@ export async function resolveRoute({ })) as Record // Locale root → Homepage from System Pages. + // settings.homepage is a shallow relation (depth: 1 above) — it identifies + // WHICH page is the homepage, but its nested block relations (e.g. Hero + // images) aren't populated. Re-fetch that page from the pages collection at + // the same depth as every other page, so the frontend gets one consistent + // shape. Uses pagesSlug/locale from args — no hard-coded collection or locale. if (!segments?.length) { const homepage = settings.homepage - if (homepage && typeof homepage === 'object') { - return { type: 'home', doc: homepage as Record } + if (!homepage || typeof homepage !== 'object') { + return null } - return null + + const homepageId = (homepage as { id: number | string }).id + const doc = await payload.findByID({ + id: homepageId, + collection: pagesSlug, + depth: 2, + locale: locale as never, + }) + + return doc ? { type: 'home', doc: doc as Record } : null } const [first, ...rest] = segments