@decocms/tanstack 8.0.0 → 8.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/README.md +79 -0
  2. package/dist/draft.d.ts +33 -0
  3. package/dist/draft.d.ts.map +1 -0
  4. package/dist/draft.js +41 -0
  5. package/dist/draft.js.map +1 -0
  6. package/dist/index.d.ts +9 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +9 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/react/DecoDocument.d.ts +61 -0
  11. package/dist/react/DecoDocument.d.ts.map +1 -0
  12. package/dist/react/DecoDocument.js +96 -0
  13. package/dist/react/DecoDocument.js.map +1 -0
  14. package/dist/react/Image.d.ts +96 -0
  15. package/dist/react/Image.d.ts.map +1 -0
  16. package/dist/react/Image.js +79 -0
  17. package/dist/react/Image.js.map +1 -0
  18. package/dist/react/index.d.ts +7 -0
  19. package/dist/react/index.d.ts.map +1 -0
  20. package/dist/react/index.js +7 -0
  21. package/dist/react/index.js.map +1 -0
  22. package/dist/react/pageValues.d.ts +10 -0
  23. package/dist/react/pageValues.d.ts.map +1 -0
  24. package/dist/react/pageValues.js +29 -0
  25. package/dist/react/pageValues.js.map +1 -0
  26. package/dist/react/scripts.d.ts +14 -0
  27. package/dist/react/scripts.d.ts.map +1 -0
  28. package/dist/react/scripts.js +96 -0
  29. package/dist/react/scripts.js.map +1 -0
  30. package/dist/router/index.d.ts +38 -0
  31. package/dist/router/index.d.ts.map +1 -0
  32. package/dist/router/index.js +60 -0
  33. package/dist/router/index.js.map +1 -0
  34. package/dist/scope/browser.d.ts +11 -0
  35. package/dist/scope/browser.d.ts.map +1 -0
  36. package/dist/scope/browser.js +8 -0
  37. package/dist/scope/browser.js.map +1 -0
  38. package/dist/scope/server.d.ts +13 -0
  39. package/dist/scope/server.d.ts.map +1 -0
  40. package/dist/scope/server.js +26 -0
  41. package/dist/scope/server.js.map +1 -0
  42. package/dist/server/index.d.ts +27 -0
  43. package/dist/server/index.d.ts.map +1 -0
  44. package/dist/server/index.js +31 -0
  45. package/dist/server/index.js.map +1 -0
  46. package/dist/shared.d.ts +26 -0
  47. package/dist/shared.d.ts.map +1 -0
  48. package/dist/shared.js +26 -0
  49. package/dist/shared.js.map +1 -0
  50. package/dist/start/index.d.ts +9 -0
  51. package/dist/start/index.d.ts.map +1 -0
  52. package/dist/start/index.js +33 -0
  53. package/dist/start/index.js.map +1 -0
  54. package/dist/studio.d.ts +28 -0
  55. package/dist/studio.d.ts.map +1 -0
  56. package/dist/studio.js +53 -0
  57. package/dist/studio.js.map +1 -0
  58. package/dist/vite/index.d.ts +15 -0
  59. package/dist/vite/index.d.ts.map +1 -0
  60. package/dist/vite/index.js +95 -0
  61. package/dist/vite/index.js.map +1 -0
  62. package/dist/worker/cacheProfiles.d.ts +43 -0
  63. package/dist/worker/cacheProfiles.d.ts.map +1 -0
  64. package/dist/worker/cacheProfiles.js +162 -0
  65. package/dist/worker/cacheProfiles.js.map +1 -0
  66. package/dist/worker/cookies.d.ts +20 -0
  67. package/dist/worker/cookies.d.ts.map +1 -0
  68. package/dist/worker/cookies.js +69 -0
  69. package/dist/worker/cookies.js.map +1 -0
  70. package/dist/worker/drafts.d.ts +59 -0
  71. package/dist/worker/drafts.d.ts.map +1 -0
  72. package/dist/worker/drafts.js +140 -0
  73. package/dist/worker/drafts.js.map +1 -0
  74. package/dist/worker/index.d.ts +107 -0
  75. package/dist/worker/index.d.ts.map +1 -0
  76. package/dist/worker/index.js +511 -0
  77. package/dist/worker/index.js.map +1 -0
  78. package/dist/worker/security.d.ts +14 -0
  79. package/dist/worker/security.d.ts.map +1 -0
  80. package/dist/worker/security.js +48 -0
  81. package/dist/worker/security.js.map +1 -0
  82. package/dist/worker/segment.d.ts +21 -0
  83. package/dist/worker/segment.d.ts.map +1 -0
  84. package/dist/worker/segment.js +43 -0
  85. package/dist/worker/segment.js.map +1 -0
  86. package/package.json +86 -31
  87. package/src/draft.ts +43 -0
  88. package/src/index.ts +8 -44
  89. package/src/react/DecoDocument.tsx +234 -0
  90. package/src/react/Image.tsx +213 -0
  91. package/src/react/index.ts +24 -0
  92. package/src/react/pageValues.ts +35 -0
  93. package/src/react/scripts.ts +98 -0
  94. package/src/router/index.ts +80 -0
  95. package/src/scope/browser.ts +18 -0
  96. package/src/scope/server.ts +37 -0
  97. package/src/server/index.ts +43 -0
  98. package/src/shared.ts +29 -0
  99. package/src/start/index.ts +31 -0
  100. package/src/studio.ts +52 -0
  101. package/src/vite/index.ts +105 -0
  102. package/src/worker/cacheProfiles.ts +180 -0
  103. package/src/worker/cookies.ts +65 -0
  104. package/src/worker/drafts.ts +157 -0
  105. package/src/worker/index.ts +648 -0
  106. package/src/worker/security.ts +63 -0
  107. package/src/worker/segment.ts +49 -0
  108. package/src/cms/kvBlockSource.test.ts +0 -82
  109. package/src/cms/kvBlockSource.ts +0 -68
  110. package/src/daemon/auth.ts +0 -204
  111. package/src/daemon/fs.ts +0 -238
  112. package/src/daemon/index.ts +0 -8
  113. package/src/daemon/middleware.ts +0 -156
  114. package/src/daemon/tunnel.ts +0 -129
  115. package/src/daemon/volumes.ts +0 -366
  116. package/src/daemon/watch.ts +0 -272
  117. package/src/hooks/DecoPageRenderer.tsx +0 -688
  118. package/src/hooks/DecoRootLayout.tsx +0 -111
  119. package/src/hooks/NavigationProgress.tsx +0 -21
  120. package/src/hooks/PreviewProviders.tsx +0 -26
  121. package/src/hooks/StableOutlet.tsx +0 -30
  122. package/src/hooks/index.ts +0 -9
  123. package/src/routes/adminRoutes.test.ts +0 -99
  124. package/src/routes/adminRoutes.ts +0 -153
  125. package/src/routes/cmsRoute.test.ts +0 -100
  126. package/src/routes/cmsRoute.ts +0 -944
  127. package/src/routes/components.tsx +0 -57
  128. package/src/routes/index.ts +0 -24
  129. package/src/routes/pageUrl.test.ts +0 -70
  130. package/src/routes/pageUrl.ts +0 -54
  131. package/src/routes/withSiteGlobals.test.ts +0 -206
  132. package/src/routes/withSiteGlobals.ts +0 -222
  133. package/src/sdk/cookiePassthrough.ts +0 -58
  134. package/src/sdk/createInvoke.ts +0 -77
  135. package/src/sdk/deferredSectionLoader.test.ts +0 -94
  136. package/src/sdk/deferredSectionLoader.ts +0 -46
  137. package/src/sdk/kvHydration.test.ts +0 -215
  138. package/src/sdk/kvHydration.ts +0 -193
  139. package/src/sdk/outboundHeaders.test.ts +0 -113
  140. package/src/sdk/outboundHeaders.ts +0 -81
  141. package/src/sdk/router.ts +0 -92
  142. package/src/sdk/useHydrated.ts +0 -19
  143. package/src/sdk/workerEntry.test.ts +0 -495
  144. package/src/sdk/workerEntry.ts +0 -2307
  145. package/src/setupFastDeploy.ts +0 -13
  146. package/src/vite/plugin-scaffold-gen.test.js +0 -106
  147. package/src/vite/plugin.js +0 -850
  148. package/src/vite/plugin.test.js +0 -113
  149. package/src/vite/plugin.test.ts +0 -52
  150. package/tsconfig.json +0 -7
@@ -1,944 +0,0 @@
1
- /**
2
- * CMS Route Helpers
3
- *
4
- * Reusable building blocks for CMS catch-all and homepage routes.
5
- * Since TanStack Router requires routes to be file-based in the site repo,
6
- * we export helper functions and config that sites use in their route files.
7
- *
8
- * @example Site's `src/routes/$.tsx`:
9
- * ```ts
10
- * import { createFileRoute, notFound } from "@tanstack/react-router";
11
- * import { loadCmsPage, cmsRouteConfig } from "@decocms/start/routes";
12
- * import { DecoPageRenderer } from "@decocms/start/hooks";
13
- *
14
- * export const Route = createFileRoute("/$")({
15
- * ...cmsRouteConfig({
16
- * siteName: "My Store",
17
- * defaultTitle: "My Store - Best products",
18
- * ignoreSearchParams: ["skuId"],
19
- * }),
20
- * });
21
- * ```
22
- */
23
-
24
- import type {
25
- DeferredSection,
26
- MatcherContext,
27
- PageSeo,
28
- ResolvedSection,
29
- } from "@decocms/blocks/cms";
30
- import {
31
- extractSeoFromProps,
32
- extractSeoFromSections,
33
- getDeferredRawProps,
34
- getDegradedSections,
35
- getSiteSeo,
36
- isEagerRequest,
37
- preloadSectionComponents,
38
- reExtractRawProps,
39
- resolveDecoPage,
40
- resolveDeferredSection,
41
- resolveDeferredSectionFull,
42
- runSectionLoaders,
43
- runSingleSectionLoader,
44
- } from "@decocms/blocks/cms";
45
- import { withTracing } from "@decocms/blocks/middleware/observability";
46
- import {
47
- type CacheProfileName,
48
- cacheHeaders,
49
- detectCacheProfile,
50
- routeCacheDefaults,
51
- } from "@decocms/blocks/sdk/cacheHeaders";
52
- import {
53
- parseSegmentCookie,
54
- SEGMENT_COOKIE,
55
- type StoredFlag,
56
- serializeSegmentCookie,
57
- } from "@decocms/blocks/sdk/flags";
58
- import { normalizeUrlsInObject } from "@decocms/blocks/sdk/normalizeUrls";
59
- import { type Device, detectDevice } from "@decocms/blocks/sdk/useDevice";
60
- import { createServerFn } from "@tanstack/react-start";
61
- import {
62
- getCookies,
63
- getRequest,
64
- getRequestHeader,
65
- getRequestUrl,
66
- setCookie,
67
- setResponseHeader,
68
- } from "@tanstack/react-start/server";
69
- import { createElement } from "react";
70
- import { derivePageUrl, isClientNavigation } from "./pageUrl";
71
- import { dedupeGlobals, resolveSiteGlobals } from "./withSiteGlobals";
72
- import type { SiteGlobalRef } from "./withSiteGlobals";
73
-
74
- const isServer = typeof document === "undefined";
75
-
76
- // Section chunk manifest — maps section keys to chunk filenames.
77
- // Generated by decoVitePlugin's generateBundle hook. Used to emit
78
- // <link rel="modulepreload"> hints for eager sections.
79
- let sectionChunkMap: Record<string, string> = {};
80
-
81
- /**
82
- * Set the section chunk manifest. Called by the site's worker entry
83
- * or setup after loading the manifest.
84
- */
85
- export function setSectionChunkMap(map: Record<string, string>): void {
86
- sectionChunkMap = map;
87
- }
88
-
89
- // ---------------------------------------------------------------------------
90
- // Server function — loads a CMS page, runs section loaders, detects cache
91
- // ---------------------------------------------------------------------------
92
-
93
- type PageResult = Awaited<ReturnType<typeof loadCmsPageInternal>>;
94
- const pageInflight = new Map<string, Promise<PageResult>>();
95
-
96
- /** Same shape as `resolveSiteGlobals()`'s empty result — used when `resolveGlobals: false`. */
97
- const EMPTY_GLOBALS: { resolvedSections: ResolvedSection[]; rawRefs: SiteGlobalRef[] } = {
98
- resolvedSections: [],
99
- rawRefs: [],
100
- };
101
-
102
- /** One year — the cohort is sticky; the `pct` fingerprint handles re-rolls. */
103
- const SEGMENT_COOKIE_MAX_AGE = 60 * 60 * 24 * 365;
104
-
105
- /**
106
- * Persist sticky A/B decisions recorded during resolution and return them for
107
- * the client (analytics).
108
- *
109
- * Merges the freshly recorded flags over any already in the `deco_segment`
110
- * cookie (so navigating to a second A/B page doesn't drop the first page's
111
- * cohort), and only re-issues the cookie when the merged value changed.
112
- * Setting the cookie also makes the worker skip caching THIS response
113
- * (`deco_segment` is not a "safe" cookie), so an unassigned visitor never
114
- * poisons the shared entry — their next request carries the cookie and hits
115
- * the per-cohort cache entry.
116
- *
117
- * `encode: (v) => v` keeps the raw base64 intact — @decocms/apps
118
- * OneDollarStats reads the cookie with `atob()` directly.
119
- */
120
- function persistFlags(matcherCtx: MatcherContext): StoredFlag[] {
121
- const recorded = matcherCtx.flags ?? [];
122
- if (!recorded.length) return [];
123
-
124
- const raw = matcherCtx.cookies?.[SEGMENT_COOKIE];
125
- const merged = new Map<string, StoredFlag>();
126
- for (const f of parseSegmentCookie(raw)) merged.set(f.name, f);
127
- for (const f of recorded) merged.set(f.name, f);
128
-
129
- const serialized = serializeSegmentCookie([...merged.values()]);
130
- if (serialized !== (raw ?? "")) {
131
- setCookie(SEGMENT_COOKIE, serialized, {
132
- path: "/",
133
- maxAge: SEGMENT_COOKIE_MAX_AGE,
134
- sameSite: "lax",
135
- encode: (v) => v,
136
- });
137
- }
138
- return recorded;
139
- }
140
-
141
- /**
142
- * Run the body sections' loaders and the SEO section's loader in the SAME
143
- * batch (`Promise.all` via `runSectionLoaders`), instead of sequentially
144
- * (body first, then `buildPageSeo` separately awaiting the SEO section).
145
- *
146
- * On a PDP, the SEO section (e.g. SeoPDP) commonly resolves the same
147
- * product as a body section via the same commerce loader. Running them
148
- * sequentially meant the SEO fetch always missed any in-flight request
149
- * dedup at the fetch-cache layer (apps-vtex's fetchWithCache) — the body
150
- * fetch had already completed and left the in-flight map by the time the
151
- * SEO fetch started, so the origin got hit twice per navigation (#355).
152
- * Batching them gives concurrent identical requests a chance to share one
153
- * origin round-trip.
154
- */
155
- /** @internal exported for tests */
156
- export async function runSectionLoadersWithSeo(
157
- resolvedSections: ResolvedSection[],
158
- seoSection: ResolvedSection | null | undefined,
159
- request: Request,
160
- ): Promise<{ enrichedSections: ResolvedSection[]; enrichedSeoSection: ResolvedSection | null | undefined }> {
161
- if (!seoSection) {
162
- return { enrichedSections: await runSectionLoaders(resolvedSections, request), enrichedSeoSection: seoSection };
163
- }
164
- const enrichedAll = await runSectionLoaders([...resolvedSections, seoSection], request);
165
- return {
166
- enrichedSections: enrichedAll.slice(0, -1),
167
- enrichedSeoSection: enrichedAll[enrichedAll.length - 1],
168
- };
169
- }
170
-
171
- async function loadCmsPageInternal(fullPath: string, resolveGlobals: boolean) {
172
- const [basePath] = fullPath.split("?");
173
- // On client-side navigation getRequestUrl() is the /_serverFn/... endpoint,
174
- // not the page being loaded — derivePageUrl rebuilds the real page URL so
175
- // matcherCtx.url / __pageUrl stay consistent with __pagePath (#280).
176
- const serverUrl = getRequestUrl();
177
- const urlWithSearch = derivePageUrl(fullPath, serverUrl);
178
-
179
- const originRequest = getRequest();
180
- const matcherCtx: MatcherContext = {
181
- userAgent: getRequestHeader("user-agent") ?? "",
182
- url: urlWithSearch,
183
- path: basePath,
184
- cookies: getCookies(),
185
- request: originRequest,
186
- isClientNavigation: isClientNavigation(fullPath, serverUrl),
187
- flags: [],
188
- };
189
- const page = await resolveDecoPage(basePath, matcherCtx);
190
- if (!page) return null;
191
- const flags = persistFlags(matcherCtx);
192
-
193
- const request = new Request(urlWithSearch, {
194
- headers: originRequest.headers,
195
- });
196
-
197
- // Resolve page sections (+ the SEO section, batched together — see #355)
198
- // and site globals in parallel. Globals are merged into the same
199
- // `resolvedSections` array so the path through this server function is
200
- // identical for SSR (F5) and SPA (<Link>) navigations — see #233 for the
201
- // previous SPA-breakage when `withSiteGlobals` ran client-side and saw an
202
- // empty client-bundled `blocks.gen.ts`.
203
- const [{ enrichedSections, enrichedSeoSection }, globals] = await Promise.all([
204
- runSectionLoadersWithSeo(page.resolvedSections, page.seoSection, request),
205
- resolveGlobals ? resolveSiteGlobals() : Promise.resolve(EMPTY_GLOBALS),
206
- ]);
207
-
208
- // Page sections take precedence over globals — dedupe drops any global
209
- // whose component is already rendered by the page.
210
- const mergedSections: ResolvedSection[] = [
211
- ...dedupeGlobals(globals.resolvedSections, enrichedSections),
212
- ...enrichedSections,
213
- ];
214
-
215
- // Pre-import eager section modules so their default exports are cached
216
- // in resolvedComponents. This ensures SSR renders with direct component
217
- // refs, and the client hydration can skip React.lazy/Suspense.
218
- const eagerKeys = mergedSections.map((s) => s.component);
219
- await preloadSectionComponents(eagerKeys);
220
-
221
- const cacheProfile = detectCacheProfile(basePath);
222
- const ua = getRequestHeader("user-agent") ?? "";
223
- const device = detectDevice(ua);
224
-
225
- // Build SEO: merge page-level seo block (primary) with section-contributed SEO (secondary)
226
- const seo = buildPageSeo(
227
- page.seoSection,
228
- enrichedSeoSection,
229
- mergedSections,
230
- isEagerRequest(matcherCtx),
231
- );
232
-
233
- // Destructure seoSection out — it's an internal artifact, not serialized to client
234
- const { seoSection: _seo, ...pageData } = page;
235
-
236
- // Anti-cache-poisoning: if a critical section loader failed, this page is
237
- // rendering with raw/empty data. Flag the response so the edge refuses to
238
- // cache the broken 200 and serves stale instead (see workerEntry.ts). Without
239
- // this, the empty page would be cached as healthy for the whole retention
240
- // window and stale-if-error would never fire.
241
- const degraded = getDegradedSections();
242
- if (degraded.length > 0) {
243
- setResponseHeader("X-Deco-Degraded", "true");
244
- console.warn(`[cms] page degraded — critical sections failed: ${degraded.join(", ")}`);
245
- }
246
-
247
- return {
248
- ...pageData,
249
- resolvedSections: normalizeUrlsInObject(mergedSections),
250
- deferredSections: normalizeUrlsInObject(page.deferredSections),
251
- cacheProfile,
252
- degraded: degraded.length > 0,
253
- pageUrl: urlWithSearch,
254
- pagePath: basePath,
255
- seo,
256
- device,
257
- flags,
258
- siteGlobals: { rawRefs: globals.rawRefs },
259
- };
260
- }
261
-
262
- /** Accepted by `loadCmsPage` — a bare path (back-compat) or `{ path, resolveGlobals }`. */
263
- export type LoadCmsPageInput = string | { path: string; resolveGlobals?: boolean };
264
-
265
- /** @internal exported for tests */
266
- export function parseLoadCmsPageInput(data: unknown): { path: string; resolveGlobals: boolean } {
267
- if (typeof data === "string") return { path: data, resolveGlobals: true };
268
- const obj = data as { path: string; resolveGlobals?: boolean };
269
- return { path: obj.path, resolveGlobals: obj.resolveGlobals ?? true };
270
- }
271
-
272
- export const loadCmsPage = createServerFn({ method: "GET" })
273
- .inputValidator((data: unknown) => data as LoadCmsPageInput)
274
- .handler(async (ctx) => {
275
- const { path: fullPath, resolveGlobals } = parseLoadCmsPageInput(ctx.data);
276
-
277
- // Use the full path (including query string) as the dedup key.
278
- // Using basePath only caused /s?q=a and /s?q=b to share one promise,
279
- // returning wrong/empty results for search and filtered PLPs.
280
- //
281
- // Client-nav resolves all sections eagerly (#277). An in-flight SSR response
282
- // for the same path may carry deferredSections; sharing that promise with a
283
- // concurrent SPA transition would smuggle those deferred sections in, causing
284
- // loadDeferredSection to run without the per-request commerce app context.
285
- // Use separate dedup buckets for SSR vs client-nav. `resolveGlobals` is also
286
- // part of the key — otherwise a `resolveGlobals: false` request could return
287
- // (or share a promise with) a `resolveGlobals: true` response for the same path.
288
- const clientNav = isClientNavigation(fullPath, getRequestUrl());
289
- const inflightKey =
290
- (clientNav ? `__nav:${fullPath}` : fullPath) + (resolveGlobals ? "" : "|noGlobals");
291
- const existing = pageInflight.get(inflightKey);
292
- if (existing) return existing;
293
-
294
- const promise = loadCmsPageInternal(fullPath, resolveGlobals).finally(() =>
295
- pageInflight.delete(inflightKey),
296
- );
297
- pageInflight.set(inflightKey, promise);
298
- return promise;
299
- });
300
-
301
- /** Accepted by `loadCmsHomePage` — optional so existing no-arg callers keep working. */
302
- export type LoadCmsHomePageInput = { resolveGlobals?: boolean } | undefined;
303
-
304
- /** @internal exported for tests */
305
- export function parseLoadCmsHomePageInput(data: unknown): { resolveGlobals: boolean } {
306
- const obj = (data ?? {}) as { resolveGlobals?: boolean };
307
- return { resolveGlobals: obj.resolveGlobals ?? true };
308
- }
309
-
310
- /**
311
- * Same as loadCmsPage but hardcoded to "/" path.
312
- * Avoids passing data through the server function for the homepage.
313
- */
314
- export const loadCmsHomePage = createServerFn({ method: "GET" })
315
- .inputValidator((data: unknown) => data as LoadCmsHomePageInput)
316
- .handler(async (ctx) => {
317
- const { resolveGlobals } = parseLoadCmsHomePageInput(ctx.data);
318
- const request = getRequest();
319
- const ua = getRequestHeader("user-agent") ?? "";
320
- const serverUrl = getRequestUrl();
321
- const matcherCtx: MatcherContext = {
322
- userAgent: ua,
323
- url: serverUrl.toString(),
324
- path: "/",
325
- cookies: getCookies(),
326
- request,
327
- isClientNavigation: isClientNavigation("/", serverUrl),
328
- flags: [],
329
- };
330
- const page = await resolveDecoPage("/", matcherCtx);
331
- if (!page) return null;
332
- const flags = persistFlags(matcherCtx);
333
- const [{ enrichedSections, enrichedSeoSection }, globals] = await Promise.all([
334
- runSectionLoadersWithSeo(page.resolvedSections, page.seoSection, request),
335
- resolveGlobals ? resolveSiteGlobals() : Promise.resolve(EMPTY_GLOBALS),
336
- ]);
337
-
338
- const mergedSections: ResolvedSection[] = [
339
- ...dedupeGlobals(globals.resolvedSections, enrichedSections),
340
- ...enrichedSections,
341
- ];
342
-
343
- const eagerKeys = mergedSections.map((s) => s.component);
344
- await preloadSectionComponents(eagerKeys);
345
-
346
- const device = detectDevice(ua);
347
- const seo = buildPageSeo(
348
- page.seoSection,
349
- enrichedSeoSection,
350
- mergedSections,
351
- isEagerRequest(matcherCtx),
352
- );
353
-
354
- const { seoSection: _seo, ...pageData } = page;
355
-
356
- // Same anti-cache-poisoning flag as loadCmsPageInternal — the homepage is the
357
- // highest-traffic, most-cached route, so it must not be exempt. The actual
358
- // X-Deco-Degraded header is emitted by the route `headers:` callback from
359
- // this `degraded` field (a reliable document-response channel).
360
- const degraded = getDegradedSections();
361
- if (degraded.length > 0) {
362
- console.warn(`[cms] home degraded — critical sections failed: ${degraded.join(", ")}`);
363
- }
364
-
365
- return {
366
- ...pageData,
367
- resolvedSections: normalizeUrlsInObject(mergedSections),
368
- deferredSections: normalizeUrlsInObject(page.deferredSections),
369
- degraded: degraded.length > 0,
370
- pagePath: "/",
371
- pageUrl: serverUrl.toString(),
372
- seo,
373
- device,
374
- flags,
375
- siteGlobals: { rawRefs: globals.rawRefs },
376
- };
377
- });
378
-
379
- // ---------------------------------------------------------------------------
380
- // Deferred section loader — resolves + enriches a single section on demand
381
- // ---------------------------------------------------------------------------
382
-
383
- /**
384
- * @deprecated Prefer TanStack native streaming via `deferredPromises` in the
385
- * route loader. This POST server function is kept for backward compatibility
386
- * and as a fallback for SPA navigations.
387
- */
388
- export const loadDeferredSection = createServerFn({ method: "POST" })
389
- .inputValidator(
390
- (data: unknown) =>
391
- data as {
392
- component: string;
393
- /** @deprecated rawProps are now resolved server-side from the deferred props cache. */
394
- rawProps?: Record<string, any>;
395
- pagePath: string;
396
- pageUrl?: string;
397
- /** Original position in the page section list — preserved for correct SPA ordering. */
398
- index?: number;
399
- },
400
- )
401
- .handler(async (ctx) => {
402
- const { component, rawProps: clientRawProps, pagePath, pageUrl, index } = ctx.data;
403
-
404
- const originRequest = getRequest();
405
- const serverUrl = getRequestUrl().toString();
406
- const matcherCtx: MatcherContext = {
407
- userAgent: getRequestHeader("user-agent") ?? "",
408
- url: pageUrl || serverUrl,
409
- path: pagePath,
410
- cookies: getCookies(),
411
- request: originRequest,
412
- };
413
-
414
- // Resolve rawProps: prefer client-provided (backward compat), then server cache,
415
- // then re-extract from the page as a last resort (handles cross-isolate cache miss
416
- // on Cloudflare Workers and TTL expiry for slow-scrolling users).
417
- const rawProps =
418
- clientRawProps ??
419
- (index !== undefined ? getDeferredRawProps(pagePath, component, index) : null) ??
420
- (index !== undefined
421
- ? await reExtractRawProps(pagePath, component, index, matcherCtx)
422
- : null);
423
-
424
- if (!rawProps) {
425
- console.warn(
426
- `[CMS] Deferred section cache miss: ${component} at index ${index} on ${pagePath}`,
427
- );
428
- return null;
429
- }
430
-
431
- const section = await withTracing(
432
- "deco.section.deferred.load",
433
- () => resolveDeferredSection(component, rawProps, pagePath, matcherCtx),
434
- {
435
- "section.name": component,
436
- "page.path": pagePath,
437
- ...(typeof index === "number" ? { "section.index": index } : {}),
438
- },
439
- );
440
- if (!section) return null;
441
-
442
- // Preserve original index for correct ordering in SPA navigation merge
443
- if (index !== undefined) section.index = index;
444
-
445
- const request = new Request(pageUrl || serverUrl, {
446
- headers: originRequest.headers,
447
- });
448
- const enriched = await runSingleSectionLoader(section, request);
449
-
450
- // Anti-cache-poisoning: if this deferred section's loader failed (e.g. an
451
- // empty product shelf during a VTEX outage), do NOT mark it cacheable —
452
- // otherwise the empty shelf would be stored in serverFnCache and served to
453
- // every visitor for the full retention window. Flag it degraded instead.
454
- if (getDegradedSections().length > 0) {
455
- setResponseHeader("X-Deco-Degraded", "true");
456
- } else {
457
- // Signal to the worker entry that this response is safe to edge-cache.
458
- // Without this header, POST _serverFn responses are passed through
459
- // without caching (checkout actions, invoke mutations, etc.).
460
- setResponseHeader("X-Deco-Cacheable", "true");
461
- }
462
-
463
- return normalizeUrlsInObject(enriched);
464
- });
465
-
466
- // ---------------------------------------------------------------------------
467
- // Default pending component — shown during SPA navigation while loader runs
468
- // ---------------------------------------------------------------------------
469
-
470
- export function CmsPagePendingFallback() {
471
- return createElement(
472
- "div",
473
- { className: "w-full min-h-[60vh] flex flex-col gap-6 py-8" },
474
- createElement("div", {
475
- className: "skeleton animate-pulse w-full rounded",
476
- style: { aspectRatio: "1440/400", minHeight: 200 },
477
- }),
478
- createElement(
479
- "div",
480
- { className: "px-4 lg:px-8 flex flex-col gap-4" },
481
- createElement("div", { className: "skeleton animate-pulse w-48 h-8 rounded" }),
482
- createElement(
483
- "div",
484
- { className: "grid grid-cols-2 lg:grid-cols-4 gap-4" },
485
- ...Array.from({ length: 4 }, (_, i) =>
486
- createElement("div", {
487
- key: i,
488
- className: "skeleton animate-pulse w-full h-48 lg:h-64 rounded",
489
- }),
490
- ),
491
- ),
492
- ),
493
- );
494
- }
495
-
496
- /**
497
- * Default branded error boundary for CMS routes. Rendered when page resolution
498
- * throws (as opposed to returning no match, which is a 404 / not-found path) —
499
- * e.g. an uncaught throw in `resolveDecoPage` / `buildPageSeo` /
500
- * `resolveSiteGlobals` during a VTEX outage. Without an `errorComponent` the
501
- * loader rejection surfaces as a raw 500 white screen.
502
- *
503
- * This is the COLD-CACHE last resort: whenever a warm edge entry exists the
504
- * worker serves it as `STALE-ERROR` before the request ever reaches here.
505
- * Sites override via `cmsRouteConfig({ errorComponent })`.
506
- */
507
- export function CmsPageErrorFallback(props: { reset?: () => void }) {
508
- return createElement(
509
- "div",
510
- { className: "min-h-[60vh] flex items-center justify-center px-4 text-center" },
511
- createElement(
512
- "div",
513
- { className: "max-w-md flex flex-col items-center gap-4" },
514
- createElement("h1", { className: "text-2xl font-bold" }, "Estamos com uma instabilidade"),
515
- createElement(
516
- "p",
517
- { className: "opacity-70" },
518
- "Não conseguimos carregar esta página agora. Tente novamente em instantes.",
519
- ),
520
- createElement(
521
- "button",
522
- {
523
- type: "button",
524
- className: "btn btn-primary",
525
- onClick: () => (props.reset ? props.reset() : undefined),
526
- },
527
- "Tentar de novo",
528
- ),
529
- ),
530
- );
531
- }
532
-
533
- // ---------------------------------------------------------------------------
534
- // Route configuration factory
535
- // ---------------------------------------------------------------------------
536
-
537
- export interface CmsRouteOptions {
538
- /** Site name used in page titles (e.g. "Espaço Smart"). */
539
- siteName: string;
540
- /** Default page title when CMS page has no name. */
541
- defaultTitle: string;
542
- /** Default description for pages without section-contributed SEO. */
543
- defaultDescription?: string;
544
- /**
545
- * Search params to exclude from loader deps.
546
- * These params won't trigger a server re-fetch when they change.
547
- * Defaults to `["skuId"]` — variant selection is client-side only.
548
- */
549
- ignoreSearchParams?: string[];
550
- /** Custom pending component shown during SPA navigation. */
551
- pendingComponent?: () => any;
552
- /**
553
- * Custom error boundary rendered when the loader / page resolution throws.
554
- * Defaults to {@link CmsPageErrorFallback} (branded "instability" page with a
555
- * retry button) so an outage degrades gracefully instead of a raw 500.
556
- * Receives TanStack Router's `{ error, reset }`.
557
- */
558
- errorComponent?: (props: { error: Error; reset: () => void }) => any;
559
- /**
560
- * Delay (ms) before showing the pending component during SPA navigation.
561
- * If the loader resolves before this threshold, no pending UI is shown.
562
- * Prevents skeleton flash on fast cache-hit navigations. Default: 200.
563
- */
564
- pendingMs?: number;
565
- /**
566
- * Minimum display time (ms) for the pending component once shown.
567
- * Prevents jarring flash when data arrives shortly after the threshold.
568
- * Default: 300.
569
- */
570
- pendingMinMs?: number;
571
- /**
572
- * SSR mode for this route.
573
- * - `true` (default): Full SSR — loader + component render on server.
574
- * - `'data-only'`: Loader runs on server, component renders on client only.
575
- * Use for interactive-heavy pages (PDP with zoom/variant selector).
576
- * - `false`: Everything runs on client only.
577
- */
578
- ssr?: boolean | "data-only";
579
- /**
580
- * Resolve `site.theme + site.global + site.pageSections` (the CMS `Site`
581
- * block) and merge them into every page's sections.
582
- *
583
- * Default: `true`. Set to `false` to restore pre-6.7.4 behavior for sites
584
- * that don't use the `Site` block and don't want it silently activated
585
- * (see #292) — this also skips the `Theme` section's `<style>` injection,
586
- * so the site's own `:root` CSS fallbacks apply instead.
587
- */
588
- resolveGlobals?: boolean;
589
- }
590
-
591
- type CmsPageLoaderData = {
592
- name?: string;
593
- cacheProfile?: CacheProfileName;
594
- degraded?: boolean;
595
- seo?: PageSeo;
596
- device?: Device;
597
- resolvedSections?: Array<{ component: string }>;
598
- } | null;
599
-
600
- // ---------------------------------------------------------------------------
601
- // Page SEO assembly — merges page.seo block with section-contributed SEO
602
- // ---------------------------------------------------------------------------
603
-
604
- /**
605
- * Process the resolved SEO section from page.seo, apply title/description
606
- * templates, and merge with section-contributed SEO.
607
- *
608
- * `seoSection` is the raw (pre-loader) resolved section — its `props` are
609
- * used for the CMS-configured `titleTemplate`/`descriptionTemplate` fields,
610
- * which a loader transforming `{jsonLD} → {title, description}` may not
611
- * pass through unchanged. `enrichedSeoSection` must already have gone
612
- * through that registered section loader (e.g., SEOPDP transforms
613
- * {jsonLD: ProductDetailsPage} → {title, description, ...}) — batched
614
- * together with the body sections in `runSectionLoadersWithSeo` so a
615
- * commerce loader shared by both (the same product fetched by both the PDP
616
- * body section and the SeoPDP section) gets a chance to dedupe at the
617
- * fetch-cache layer instead of resolving the page twice (#355). This
618
- * function itself no longer runs any loader.
619
- */
620
- function buildPageSeo(
621
- seoSection: ResolvedSection | null | undefined,
622
- enrichedSeoSection: ResolvedSection | null | undefined,
623
- enrichedSections: ResolvedSection[],
624
- isEager: boolean,
625
- ): PageSeo {
626
- // Secondary source: SEO sections embedded in the sections array.
627
- // `isEager` keeps structured-data suppression bot-aware: humans skip the
628
- // JSON-LD when `ignoreStructuredData` is on; crawlers still get it.
629
- const sectionSeo = extractSeoFromSections(enrichedSections, { isEager });
630
-
631
- // Site-wide SEO config from the "Site" app block — mirrors ctx.seo in
632
- // the original deco-cx/deco framework. Provides fallback title,
633
- // description, and templates when page-level seo doesn't supply them.
634
- const siteSeo = getSiteSeo();
635
-
636
- if (!seoSection) {
637
- // No page.seo block — use site-wide SEO as primary, section-contributed as secondary
638
- const merged: PageSeo = { ...sectionSeo };
639
- if (siteSeo.title && !merged.title) merged.title = siteSeo.title;
640
- if (siteSeo.description && !merged.description) merged.description = siteSeo.description;
641
- if (siteSeo.image && !merged.image) merged.image = siteSeo.image;
642
-
643
- // Apply site-level templates even when there is no page-level seo
644
- // section. Without this, pages whose title comes from a content
645
- // section (e.g. <h1> + sectionSeo) or from the site default would
646
- // skip `siteSeo.titleTemplate`, causing prod-vs-worker title drift.
647
- const titleTemplate = effectiveTemplate(siteSeo.titleTemplate);
648
- const descTemplate = effectiveTemplate(siteSeo.descriptionTemplate);
649
- if (titleTemplate && merged.title) {
650
- merged.title = titleTemplate.replace("%s", merged.title);
651
- }
652
- if (descTemplate && merged.description) {
653
- merged.description = descTemplate.replace("%s", merged.description);
654
- }
655
-
656
- return merged;
657
- }
658
-
659
- // enrichedSeoSection should always be present once seoSection is, but
660
- // fall back to the raw section's props (pre-loader) if the loader batch
661
- // somehow dropped it — same "use the raw resolved props" resilience the
662
- // old inline try/catch had around the loader call.
663
- const enrichedProps = (enrichedSeoSection ?? seoSection).props;
664
- const pageSeo = extractSeoFromProps(enrichedProps, { isEager });
665
-
666
- // Replicate original SeoV2 loader logic: `_title ?? appTitle`
667
- // When the page's seo block doesn't have a title/description,
668
- // fall back to the Site app's seo config.
669
- if (!pageSeo.title && siteSeo.title) pageSeo.title = siteSeo.title;
670
- if (!pageSeo.description && siteSeo.description) pageSeo.description = siteSeo.description;
671
- if (!pageSeo.image && siteSeo.image) pageSeo.image = siteSeo.image;
672
-
673
- // Apply title/description templates.
674
- // Priority: page-level template → site-level template → no-op.
675
- // This mirrors the original: `(titleTemplate ?? "").trim().length === 0 ? "%s" : titleTemplate`
676
- const rawProps = seoSection.props;
677
- const titleTemplate =
678
- effectiveTemplate(rawProps.titleTemplate as string | undefined) ??
679
- effectiveTemplate(siteSeo.titleTemplate);
680
- const descTemplate =
681
- effectiveTemplate(rawProps.descriptionTemplate as string | undefined) ??
682
- effectiveTemplate(siteSeo.descriptionTemplate);
683
-
684
- if (titleTemplate && pageSeo.title) {
685
- pageSeo.title = titleTemplate.replace("%s", pageSeo.title);
686
- }
687
- if (descTemplate && pageSeo.description) {
688
- pageSeo.description = descTemplate.replace("%s", pageSeo.description);
689
- }
690
-
691
- // Primary source (page.seo) overrides secondary (section-contributed).
692
- // Only truthy fields in pageSeo override — undefined keys don't clear sectionSeo.
693
- return { ...sectionSeo, ...pageSeo };
694
- }
695
-
696
- /** Returns a non-trivial template string, or undefined for "%s" / empty / blank. */
697
- function effectiveTemplate(tmpl: string | undefined): string | undefined {
698
- if (!tmpl || tmpl.trim() === "" || tmpl.trim() === "%s") return undefined;
699
- return tmpl;
700
- }
701
-
702
- // ---------------------------------------------------------------------------
703
- // Head metadata builder
704
- // ---------------------------------------------------------------------------
705
-
706
- /**
707
- * Build TanStack Router `head()` metadata from page-level and section-contributed SEO.
708
- * Emits: title, description, canonical, OG tags, Twitter Card, robots directive.
709
- */
710
- function buildHead(
711
- loaderData: CmsPageLoaderData | undefined,
712
- siteName: string,
713
- defaultTitle: string,
714
- defaultDescription?: string,
715
- ) {
716
- const seo = loaderData?.seo;
717
- const title = seo?.title
718
- ? seo.title
719
- : loaderData?.name
720
- ? `${loaderData.name} | ${siteName}`
721
- : defaultTitle;
722
- const description = seo?.description || defaultDescription;
723
- const image = seo?.image;
724
- const canonical = seo?.canonical;
725
- const noIndex = seo?.noIndexing;
726
-
727
- const meta: Record<string, string>[] = [{ title }];
728
-
729
- if (description) {
730
- meta.push({ name: "description", content: description });
731
- }
732
-
733
- // Robots — always emit a directive so crawlers see an explicit signal
734
- meta.push({
735
- name: "robots",
736
- content: noIndex
737
- ? "noindex, nofollow"
738
- : "index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1",
739
- });
740
-
741
- // Open Graph
742
- meta.push({ property: "og:title", content: title });
743
- if (description) meta.push({ property: "og:description", content: description });
744
- if (image) meta.push({ property: "og:image", content: image });
745
- meta.push({ property: "og:type", content: seo?.type || "website" });
746
- if (canonical) meta.push({ property: "og:url", content: canonical });
747
-
748
- // Twitter Card
749
- meta.push({ name: "twitter:card", content: image ? "summary_large_image" : "summary" });
750
- meta.push({ name: "twitter:title", content: title });
751
- if (description) meta.push({ name: "twitter:description", content: description });
752
- if (image) meta.push({ name: "twitter:image", content: image });
753
-
754
- const links: Record<string, string>[] = [];
755
- if (canonical) {
756
- links.push({ rel: "canonical", href: canonical });
757
- }
758
-
759
- // Modulepreload hints for eager section chunks
760
- if (loaderData?.resolvedSections) {
761
- for (const s of loaderData.resolvedSections) {
762
- const chunkFile = sectionChunkMap[s.component];
763
- if (chunkFile) {
764
- links.push({ rel: "modulepreload", href: `/${chunkFile}` });
765
- }
766
- }
767
- }
768
-
769
- // JSON-LD structured data — rendered as <script type="application/ld+json"> in <head>
770
- const scripts: Array<{ type: string; children: string }> = [];
771
- if (seo?.jsonLDs?.length) {
772
- for (const jsonLD of seo.jsonLDs) {
773
- scripts.push({
774
- type: "application/ld+json",
775
- children: JSON.stringify(jsonLD),
776
- });
777
- }
778
- }
779
-
780
- return { meta, links, scripts };
781
- }
782
-
783
- /**
784
- * Returns a TanStack Router route config object for a CMS catch-all route.
785
- * Spread the result into your `createFileRoute("/$")({...})` call.
786
- *
787
- * Includes: loaderDeps, loader, headers, head (with full SEO), staleTime/gcTime.
788
- * Does NOT include: component, notFoundComponent (site provides these).
789
- *
790
- * SEO metadata is extracted from sections registered via `registerSeoSections()`.
791
- * The `head()` function emits title, description, canonical, OG tags, and robots.
792
- */
793
- export function cmsRouteConfig(options: CmsRouteOptions) {
794
- const {
795
- siteName,
796
- defaultTitle,
797
- defaultDescription,
798
- ignoreSearchParams = ["skuId"],
799
- pendingComponent,
800
- pendingMs = 200,
801
- pendingMinMs = 300,
802
- ssr: ssrMode,
803
- errorComponent = CmsPageErrorFallback,
804
- resolveGlobals,
805
- } = options;
806
-
807
- const ignoreSet = new Set(ignoreSearchParams);
808
-
809
- return {
810
- // Catch-all search validation: preserve all URL search params so they
811
- // reach loaderDeps. Without this, TanStack Router may strip unknown
812
- // params (e.g. ?q=, filter.*, page, sort) during SPA navigation.
813
- validateSearch: (search: Record<string, unknown>) => search as Record<string, string>,
814
-
815
- loaderDeps: ({ search }: { search: Record<string, string> }) => {
816
- const filtered = Object.fromEntries(
817
- Object.entries(search ?? {}).filter(([k]) => !ignoreSet.has(k)),
818
- );
819
- return {
820
- search: Object.keys(filtered).length ? filtered : undefined,
821
- };
822
- },
823
-
824
- loader: async ({
825
- params,
826
- deps,
827
- }: {
828
- params: { _splat?: string };
829
- deps: { search?: Record<string, string> };
830
- }) => {
831
- const basePath = "/" + (params._splat || "");
832
- const searchStr = deps.search
833
- ? "?" + new URLSearchParams(deps.search as Record<string, string>).toString()
834
- : "";
835
- const page = await loadCmsPage({
836
- data: { path: basePath + searchStr, resolveGlobals },
837
- });
838
- if (!page) return page;
839
-
840
- if (!isServer && page.resolvedSections) {
841
- const keys = page.resolvedSections.map((s: ResolvedSection) => s.component);
842
- await preloadSectionComponents(keys);
843
- }
844
-
845
- // Deferred sections use client-side IntersectionObserver loading.
846
- // DecoPageRenderer renders skeletons (LoadingFallback) during SSR and
847
- // loads full section content via _serverFn when scrolled into view.
848
- //
849
- // Previously, SSR streaming via TanStack <Await> resolved ALL deferred
850
- // sections server-side and streamed them in the initial HTML. This caused
851
- // the browser to load ALL product shelf images at once (~3x more image
852
- // requests than the IntersectionObserver path). Client SPA navigation
853
- // also blocked on await Promise.all() for all deferred sections.
854
- //
855
- // The IO path (DeferredSectionWrapper) only fetches section data when
856
- // the skeleton scrolls into view, matching Fresh/Deno partial behavior
857
- // and significantly reducing initial image load and TBT.
858
- return page;
859
- },
860
-
861
- ...(pendingComponent ? { pendingComponent } : {}),
862
- pendingMs,
863
- pendingMinMs,
864
- errorComponent,
865
- ...(ssrMode !== undefined ? { ssr: ssrMode } : {}),
866
-
867
- ...routeCacheDefaults("product"),
868
-
869
- headers: ({ loaderData }: { loaderData?: CmsPageLoaderData }) => {
870
- const profile = loaderData?.cacheProfile ?? "listing";
871
- const headers = cacheHeaders(profile);
872
- // Emit the degraded flag on the DOCUMENT response via the route headers
873
- // callback — the reliable channel (same one cacheHeaders rides), unlike
874
- // setResponseHeader inside the server fn which may not reach the document.
875
- // The worker treats a 200 + X-Deco-Degraded like a 5xx (no store, serve
876
- // stale) to prevent caching an empty page during a VTEX outage.
877
- if (loaderData?.degraded) headers["X-Deco-Degraded"] = "true";
878
- return headers;
879
- },
880
-
881
- head: ({ loaderData }: { loaderData?: CmsPageLoaderData }) =>
882
- buildHead(loaderData, siteName, defaultTitle, defaultDescription),
883
- };
884
- }
885
-
886
- /**
887
- * Returns a TanStack Router route config for the CMS homepage route.
888
- * Spread into `createFileRoute("/")({...})`.
889
- *
890
- * Like `cmsRouteConfig`, emits full SEO head metadata from section-contributed data.
891
- */
892
- export function cmsHomeRouteConfig(options: {
893
- defaultTitle: string;
894
- defaultDescription?: string;
895
- /** Site name for OG title composition. Defaults to defaultTitle. */
896
- siteName?: string;
897
- pendingComponent?: () => any;
898
- /** Delay (ms) before showing pending component. Default: 200. */
899
- pendingMs?: number;
900
- /** Minimum display time (ms) for pending component. Default: 300. */
901
- pendingMinMs?: number;
902
- /** Error boundary for loader throws. Defaults to {@link CmsPageErrorFallback}. */
903
- errorComponent?: (props: { error: Error; reset: () => void }) => any;
904
- /** See `CmsRouteOptions.resolveGlobals` — default `true`. */
905
- resolveGlobals?: boolean;
906
- }) {
907
- const {
908
- defaultTitle,
909
- defaultDescription,
910
- siteName,
911
- pendingMs = 200,
912
- pendingMinMs = 300,
913
- errorComponent = CmsPageErrorFallback,
914
- resolveGlobals,
915
- } = options;
916
-
917
- return {
918
- loader: async () => {
919
- const page = await loadCmsHomePage({ data: { resolveGlobals } });
920
- if (!page) return page;
921
-
922
- if (!isServer && page.resolvedSections) {
923
- const keys = page.resolvedSections.map((s: ResolvedSection) => s.component);
924
- await preloadSectionComponents(keys);
925
- }
926
-
927
- // Deferred sections use client-side IntersectionObserver loading.
928
- // See cmsRouteConfig loader for rationale.
929
- return page;
930
- },
931
- ...(options.pendingComponent ? { pendingComponent: options.pendingComponent } : {}),
932
- pendingMs,
933
- pendingMinMs,
934
- errorComponent,
935
- ...routeCacheDefaults("static"),
936
- headers: ({ loaderData }: { loaderData?: CmsPageLoaderData }) => {
937
- const headers = cacheHeaders("static");
938
- if (loaderData?.degraded) headers["X-Deco-Degraded"] = "true";
939
- return headers;
940
- },
941
- head: ({ loaderData }: { loaderData?: CmsPageLoaderData }) =>
942
- buildHead(loaderData, siteName ?? defaultTitle, defaultTitle, defaultDescription),
943
- };
944
- }