Fewer queries per render: resolveRoute and page metadata cached by value, select for slug-only reads, one Site integrations read

Home 43 -> 24 MongoDB queries per render, other pages -36 to -44 %.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-12-01 13:51:39 +01:00
co-authored by Claude Opus 5.5
parent f3be77b2bc
commit 1d6108765c
7 changed files with 36 additions and 10 deletions
+4 -4
View File
@@ -2,9 +2,8 @@ import { faqItemsFromLayout } from '@intecion/ipal-kit/blocks'
// @starter:if localBusiness
import { buildLocalBusinessJsonLd, createContentHelpers } from '@intecion/ipal-kit'
import { getPayload } from 'payload'
import { contentConfig } from '@/content.config'
import { i18nConfig, type Locale } from '@/i18n.config'
import { i18nConfig } from '@/i18n.config'
// @starter:else
//: import { createContentHelpers } from '@intecion/ipal-kit'
//:
@@ -65,8 +64,9 @@ export const {
// @starter:if localBusiness
// LocalBusiness from the Company global (replaces the default WebSite + Organization from Site settings)
siteJsonLd: async ({ baseUrl, locale }) => {
const payload = await getPayload({ config })
const company = await payload.findGlobal({ slug: 'company', locale: locale as Locale })
// the layout's cached getter: one Company read per request, not two (docs/performance.md → server)
const { getCompany } = await import('./globals')
const company = await getCompany(locale)
return [
buildLocalBusinessJsonLd({
address: { city: company.address?.city ?? undefined, country: company.address?.country ?? 'PL', postalCode: company.address?.postalCode ?? undefined, street: company.address?.street ?? undefined },