fix(cms): resolve site globals in resolveDecoPage, replacing tanstack side path (#292)#352
Open
JonasJesus42 wants to merge 1 commit into
Open
fix(cms): resolve site globals in resolveDecoPage, replacing tanstack side path (#292)#352JonasJesus42 wants to merge 1 commit into
JonasJesus42 wants to merge 1 commit into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Closes #292.
Since v6.7.4,
resolveSiteGlobals()ran unconditionally on every CMS route via atanstack-only path bolted onto
loadCmsPage/loadCmsHomePage, injecting the CMSSiteblock (theme+global+pageSections) into every page. This divergedfrom 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+globalon thewebsiteapp and prepended them in theshared Page loader, resolved through the one resolution engine. We mirror that:
packages/blocks(runtime):resolveDecoPagenow prepends the Site block'stheme+global(opt-in by declaration) intopage.resolvedSections, dedupedso page sections win, resolved via the normal path reusing
resolvedLayoutCache.site.pageSectionsis intentionally dropped (old deco's Site block never had it —it was the divergence behind Breaking change (6.7.4): resolveSiteGlobals() now runs on all CMS routes, silently activating site globals for sites not using withSiteGlobals() #292).
packages/tanstack:cmsRoutestops callingresolveSiteGlobals()+ themanual merge/dedupe; drops the unused
siteGlobals.rawRefsreturn.withSiteGlobals()stays a deprecated no-op. The
__nav:client-nav dedup bucket (Client-side navigation renders blank for deferred sections that depend on per-request app context (admin-source-of-truth deferral leaks into SPA nav) #277) is preserved.packages/nextjs: no code change — it renderspage.resolvedSections, so itnow picks up declared globals through the same path (unifies both bindings).
Breaking change
Declared
theme/globalrender on every page (as in 6.7.4+ and old deco); a sitewith a malformed Theme must fix it site-side.
site.pageSectionsno 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/sitekey 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:
resolveDecoPagenow prependsSite.themeandSite.globalto every page and removes the tanstack-only globals path, fixing the divergence in #292. This unifies behavior across@decocms/tanstackand@decocms/nextjsand dedupes against page sections.Refactors
@decocms/blocks:resolveDecoPagegatherssite.theme+site.global, resolves them with the same path and layout cache, and prepends them; dropssite.pageSectionsas a globals source; dedupes so page sections win.@decocms/tanstack:cmsRouteno longer callsresolveSiteGlobals()or merges globals; removessiteGlobals.rawRefsfrom loader return;withSiteGlobals()kept as a deprecated no-op.Migration
site.themeandsite.global; stop relying onsite.pageSectionsbeing injected.resolveSiteGlobals()/withSiteGlobals(); prefer the runtime path viaresolveDecoPage.Written for commit 42131f4. Summary will update on new commits.