Skip to content

feat(core): add customizable page sections renderer - #3604

Open
lokinmodar wants to merge 10 commits into
vtex:devfrom
lokinmodar:feat/page-sections-renderer
Open

lokinmodar wants to merge 10 commits into
vtex:devfrom
lokinmodar:feat/page-sections-renderer

Conversation

@lokinmodar

Copy link
Copy Markdown

What's the purpose of this pull request?

Stores that need multi-column or zoned CMS page layouts currently have to bypass or reimplement FastStore's section pipeline. That loses framework behavior such as section boundaries, lazy loading, component resolution, and framework-injected sections.

This PR adds an opt-in, content-type-agnostic page sections renderer. Store code can group or partition page sections while delegating every subset back to the native renderer.

Closes #3603

How it works?

  • Adds the store-level customization file src/components/PageSectionsRenderer.tsx.
  • Exposes PageSectionsRendererProps from @faststore/core with:
    • contentType
    • page settings
    • augmented page sections
    • renderSections(sections), which preserves the native FastStore pipeline
  • Wires the extension point into home, landingPage, plp, search, pdp, 404, 500, and login.
  • Keeps the default renderer as a fragment-only pass-through, so the default DOM and rendering order do not change.
  • Leaves global sections, page children, PreviewTag, Toast, schemas, and content documents unchanged.
  • Documents the store override, fallback behavior, and the requirement to delegate every section exactly once.

The contract is additive. Existing RenderSections callers that do not provide a contentType continue through the previous path.

How to test it?

Automated validation run from a clean clone:

  • pnpm turbo run generate --filter=@faststore/core
  • pnpm turbo run test --filter=@faststore/core — 153 files and 1,322 tests passed
  • pnpm turbo run build --filter=@faststore/core
  • Biome and Prettier checks passed for all changed TypeScript/TSX files

Manual validation:

  1. Install the PR package in a FastStore starter using the version produced by the ci/codesandbox check.
  2. Add src/components/PageSectionsRenderer.tsx using the example in packages/core/README.md.
  3. Partition one content type into two layout zones and delegate both subsets with renderSections.
  4. Verify that other content types keep their default layout and that lazy loading and injected sections still work.

Starters Deploy Preview

A dedicated starter URL is not included because this is a framework extension point rather than a fixed visual change. The installable version generated by the ci/codesandbox check can be used with the documented example in any starter.

References

Checklist

PR Title and Commit Messages

PR Description

  • Added the contributing label according to the repository guidelines (automation currently lacks label permission)

Dependencies

  • No package dependency changed, so pnpm-lock.yaml is unchanged

Documentation

  • PR description
  • Updated packages/core/README.md and pinged @Mariana-Caetano for review

@lokinmodar
lokinmodar requested a review from a team as a code owner November 20, 2026 10:48
@lokinmodar
lokinmodar requested review from lariciamota and renatamottam and removed request for a team November 20, 2026 10:48
@dk-pr-review

dk-pr-review Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

DK Review — Audit Summary

Verdict: ✅ CLEAN

Severity Count
BLOCK 0
RESTRICT 0
SUGGEST 1

Only BLOCK and RESTRICT findings anchored to a changed line are commented inline on the diff. The finding below opens no review thread.

Scenarios evaluated: feature-flags, general-review
Scenarios skipped: dependency-governance (no matching files), pipeline-config (no matching files), agent-skills-review (no matching files), quality-ratchet (no matching files)


📋 Findings (1)

SUGGEST

  1. [Evolvability.Organizational] packages/core/src/components/cms/RenderSections.tsx:287 — augmentedSections (built by withRegionSliderSection, which synthesizes the internal 'RegionSlider' global section) is passed wholesale into the public PageSectionsRenderer customization API. Every store-authored renderer is now required to know about and forward framework-internal sections to avoid tripping the omission warning (as the README explicitly calls out and the new test mocks explicitly special-case). If FastStore adds or renames another internally-injected section in the future, all existing store customizations silently become 'incomplete' without any compatibility seam: e.g. a second framework-injected global section gets added next release, and every store's existing PageSectionsRenderer (written against the current contract) starts omitting it, triggering the dev warning and potentially never rendering the new section until each store updates its customization.
    → Consider separating CMS-authored sections from framework-injected ones in the renderSections contract (e.g. render framework sections outside the customizable surface, or auto-append omitted framework sections) so internal sections aren't a forward-compatibility burden on every store-level override.

DK Review v1.0.0 | To contest a finding, reply in its thread

@lokinmodar

Copy link
Copy Markdown
Author

Regarding the DK Review suggestion to replace contentType: string with a closed union: the open string is intentional and is now documented in the Core README.

PageSectionsRenderer is a content-source-agnostic public extension point. Stores and content platforms can define additional content types beyond FastStore's built-in pages; a closed union would reject those valid consumers and would already break the customPage contract covered by the focused tests. Built-in values remain documented examples, but the public type must stay extensible.

@lokinmodar

Copy link
Copy Markdown
Author

Addressed the DK Review general.documentation-gap suggestion in f6c254e. The Core README now calls out that 404, 500, and login may pass through PageSectionsRenderer, explains the fallback-page failure risk, and requires an early safe default branch before type-specific assumptions.

@lokinmodar

Copy link
Copy Markdown
Author

Clarified the store-owned recipe contract in 69a7283. The README example now selects a two-column recipe from page settings, documents local narrowing for the open settings record, and explicitly covers multi-row, column-region, and full-width compositions without exposing CSS or a layout DSL through CMS. No public API or runtime change was needed: the existing contentType, settings, sections, and renderSections contract already supports these layouts.

@lokinmodar

Copy link
Copy Markdown
Author

Addressed the latest DK Review Functional.Check suggestion in f50af43. The development validation effect now depends on settings, and the new browser test rerenders with stable section/global/component references while changing only the layout setting; it proves the omitted-section warning is re-evaluated. Targeted result: RenderSections.browser.test.tsx, 10/10 passing.

@orca-security-us orca-security-us Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed OSS Licenses high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Malicious Packages high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

@sonar-workflows

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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.

Expose an overridable page sections renderer with CMS page context

1 participant