Site Settings read at depth 1; archive page re-fetched at page depth

getSettings ran findGlobal at depth 2 on every request, pulling the
relations of every page a project field links to (menus). Depth 1 keeps
slug/title. The archive page itself was rendered from the settings copy,
which maxDepth caps at 1, so its media never populated; resolveRoute now
re-fetches it at depth 2 like the homepage.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-22 17:02:07 +02:00
co-authored by Claude Opus 5.5
parent 8e10232765
commit 561a9e2bb7
4 changed files with 108 additions and 3 deletions
+12 -2
View File
@@ -143,12 +143,22 @@ export async function resolveRoute({
if (archiveDoc.slug !== first) {continue}
if (!isPublic(archiveDoc, draft)) {return null}
// /pl/artykuly → the archive page itself.
// /pl/artykuly → the archive page itself. Settings hold it shallow (depth
// 1); re-fetch it at page depth so its blocks render like any other page.
if (rest.length === 0) {
const doc = await payload.findByID({
id: archiveDoc.id,
collection: pagesSlug as never,
depth: 2,
disableErrors: true,
draft,
locale: locale as never,
})
if (!doc || !isPublic(doc, draft)) {return null}
return {
type: 'archive',
collection: collection.slug,
doc: archiveDoc as Record<string, unknown>,
doc: doc as Record<string, unknown>,
page,
perPage: collection.perPage ?? 10,
}
+6 -1
View File
@@ -188,10 +188,15 @@ export function createContentHelpers({
/**
* SiteSettings for a locale — ONE query per locale per request, shared by the
* layout, generatePageMetadata, resolveRoute and anything else that asks.
*
* Depth 1: logos and assigned pages arrive as documents (slug, title), but
* not THEIR relations. Depth 2 pulled every assigned page's blocks and media
* (homepage, archives, system pages) into every request; resolveRoute
* re-fetches the one page it actually renders.
*/
const getSettings = cache(async (locale: string) => {
const payload = await getCachedPayload()
return payload.findGlobal({ slug: settingsSlug as never, depth: 2, locale: locale as never })
return payload.findGlobal({ slug: settingsSlug as never, depth: 1, locale: locale as never })
})
/** What does this URL point at? Routing only — no listing data. */