Skip to content

fix(cms): resolve site globals in resolveDecoPage, replacing tanstack side path (#292)#352

Open
JonasJesus42 wants to merge 1 commit into
mainfrom
fix/292-site-globals-runtime
Open

fix(cms): resolve site globals in resolveDecoPage, replacing tanstack side path (#292)#352
JonasJesus42 wants to merge 1 commit into
mainfrom
fix/292-site-globals-runtime

Conversation

@JonasJesus42

@JonasJesus42 JonasJesus42 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Context

Closes #292.

Since v6.7.4, resolveSiteGlobals() ran unconditionally on every CMS route via a
tanstack-only path bolted onto loadCmsPage/loadCmsHomePage, injecting the CMS
Site block (theme + global + pageSections) into every page. This diverged
from how the old framework (deco-cx/apps website + deco-cx/deco) handled globals.

Approach — replicate the old-deco model (faithful, no opt-out flag)

Old deco declared theme + global on the website app and prepended them in the
shared Page loader, resolved through the one resolution engine. We mirror that:

Breaking change

Declared theme/global render on every page (as in 6.7.4+ and old deco); a site
with a malformed Theme must fix it site-side. site.pageSections no longer injected.
Heads-up filed at deco-sites/lebiscuit-tanstack#143.

Tests

+5 targeted tests in resolve.test.ts (prepend order, dedupe, opt-in, Site/site
key casing). Full suites pass: blocks 1072, tanstack 107, next 39. blocks typecheck clean.

🤖 Generated with Claude Code


Summary by cubic

Moves site globals resolution into the runtime: resolveDecoPage now prepends Site.theme and Site.global to every page and removes the tanstack-only globals path, fixing the divergence in #292. This unifies behavior across @decocms/tanstack and @decocms/nextjs and dedupes against page sections.

  • Refactors

    • @decocms/blocks: resolveDecoPage gathers site.theme + site.global, resolves them with the same path and layout cache, and prepends them; drops site.pageSections as a globals source; dedupes so page sections win.
    • @decocms/tanstack: cmsRoute no longer calls resolveSiteGlobals() or merges globals; removes siteGlobals.rawRefs from loader return; withSiteGlobals() kept as a deprecated no-op.
    • Opt-in by declaration; works for SSR and SPA with one consistent path.
  • Migration

    • Declare globals under site.theme and site.global; stop relying on site.pageSections being injected.
    • Ensure your Theme is valid, as it now renders on every page.
    • Remove or update any direct uses of resolveSiteGlobals()/withSiteGlobals(); prefer the runtime path via resolveDecoPage.

Written for commit 42131f4. Summary will update on new commits.

Review in cubic

…tack side path (#292)

Mirror deco-cx/apps `website/pages/Page.tsx`: prepend the Site block's
`theme` + `global` into every page's resolvedSections from the shared runtime
resolver (`resolveDecoPage`), reusing the layout-section cache — instead of the
tanstack-only `resolveSiteGlobals()` parallel path bolted onto the route layer.
Both `@decocms/tanstack` and `@decocms/nextjs` now render declared globals
through one path. Opt-in by declaration; `site.pageSections` is intentionally
dropped as a globals source (old deco's Site block only had theme + global).

- packages/blocks: gatherSiteGlobalRefs + resolveSiteGlobalSections +
  dedupeGlobals in resolveDecoPage; +5 tests (prepend order, dedupe, opt-in,
  Site/site key casing)
- packages/tanstack: cmsRoute stops calling resolveSiteGlobals + manual
  merge/dedupe; drops unused siteGlobals rawRefs from the return;
  withSiteGlobals kept as a deprecated no-op

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@JonasJesus42
JonasJesus42 requested a review from a team July 13, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Breaking change (6.7.4): resolveSiteGlobals() now runs on all CMS routes, silently activating site globals for sites not using withSiteGlobals()

1 participant