feat(sections): implement modular page sections with reusable schemas - #3
srikishore5727 wants to merge 6 commits into
Conversation
Change SummaryImplements modular Sanity-driven page sections by routing section data through Next and the new PageRenderer. Adds Hero, Text-Image, and Feature List components plus section mapping/types to render dynamic blocks. Updates Sanity schemas and config to support the new section types and remote Sanity imagery. File Changes
Based on f8711bf...245d72a |
PR ScorecardScoreScoring MethodologyCommunication Scoring FrameworkThe overall communication score is a weighted average:
Formula: Code Scoring FrameworkThe scorecard evaluates code using 3 key reviewer questions:
PR Communication NotesDescription Quality
PR Size & Scope
Commit Messages
Issue NotesCode Correctness & Design Quality
Test Quality & Coverage
💬 Minor Issues (Nitpicks)Code Correctness & Design Quality
Code Readability & Maintainability
Based on f8711bf...40ebde5 |
| name: 'heroBanner', | ||
| title: 'Hero Banner', | ||
| type: 'image', | ||
| name: 'slug', |
There was a problem hiding this comment.
Severity: 🟠 Major
Make slug required again so pages can’t be published without a route key.
defineField({
name: 'slug',
...,
validation: (Rule) => Rule.required(),
})| type PageDoc = { | ||
| title: string | ||
| description?: string | null | ||
| sections?: any[] //newly added for testing |
There was a problem hiding this comment.
Severity: 🟠 Major
Replace any[] with a discriminated union (or unknown + runtime narrowing) so section rendering changes are type-checked.
type PageSection = HeroSection | TextImageSection | FeatureListSection;
...
sections?: PageSection[];| }>) { | ||
| return ( | ||
| <html lang="en"> | ||
| <html lang="en" suppressHydrationWarning> |
There was a problem hiding this comment.
Severity: 🟠 Major
Avoid globally suppressing hydration warnings; fix the underlying mismatch (or scope suppression to the smallest possible subtree).
<html lang="en">
<body className={...}>
PR OverviewPR Type: Feature Focus Areas for Architect Review
PR InsightsPotential PR Improvements
PR Strengths
|
|
Tip Need another review? Tag me and say rereview for re-analysis after you have fixed all the issues. @cw-pr-agent rereview |
|
@cw-pr-agent rereview |
PR ScorecardScoreScoring MethodologyCommunication Scoring FrameworkThe overall communication score is a weighted average:
Formula: Code Scoring FrameworkThe scorecard evaluates code using 3 key reviewer questions:
PR Communication NotesDescription Quality
PR Size & Scope
Commit Messages
Issue NotesCode Correctness & Design Quality
Test Quality & Coverage
Code Readability & Maintainability
💬 Minor Issues (Nitpicks)Code Readability & Maintainability
Based on 40ebde5...3908fc5 |
PR OverviewPR Type: Feature Focus Areas for Architect Review
Rereview ImpressionsProgress Since Last Review
New Issues Introduced (if any)
PR InsightsPotential PR Improvements
PR Strengths
|
|
@cw-pr-agent rereview |
PR ScorecardScoreScoring MethodologyCommunication Scoring FrameworkThe overall communication score is a weighted average:
Formula: Code Scoring FrameworkThe scorecard evaluates code using 3 key reviewer questions:
PR Communication NotesDescription Quality
PR Size & Scope
Commit Messages
Issue NotesCode Correctness & Design Quality
Test Quality & Coverage
Code Readability & Maintainability
💬 Minor Issues (Nitpicks)Code Correctness & Design Quality
Code Readability & Maintainability
Based on 3908fc5...5dce4cc |
| import FeatureListSection from './sections/FeatureListSection' | ||
| import type { SectionProps } from './PageRenderer.type' | ||
|
|
||
| export const sectionMap: { [K in SectionProps['_type']]: React.ComponentType<Extract<SectionProps, { _type: K }>> } = { |
There was a problem hiding this comment.
Severity: 🟠 Major
If other files still import SectionType, reintroduce it (or update all call sites) to avoid breaking the build.
export type SectionType = SectionProps['_type']| return ( | ||
| <> | ||
| {sections.map((section) => { | ||
| const Component = sectionMap[section._type] as React.ComponentType<typeof section> |
There was a problem hiding this comment.
Severity: 🟠 Major
Remove the React.ComponentType<typeof section> cast by narrowing on section._type (e.g., switch/if), so the compiler enforces that each section variant renders with the correct props.
switch (section._type) {
case 'heroSection': return <HeroSection key={section._key} {...section} />
...
}| import FeatureListSection from './sections/FeatureListSection' | ||
| import type { SectionProps } from './PageRenderer.type' | ||
|
|
||
| export const sectionMap: { [K in SectionProps['_type']]: React.ComponentType<Extract<SectionProps, { _type: K }>> } = { |
There was a problem hiding this comment.
Severity: 💬 Minor [nitpick]
Prefer importing React types instead of relying on the global React namespace to avoid lint/typeconfig surprises.
import type { ComponentType } from 'react'
...
export const sectionMap: { ...: ComponentType<...> } = { ... }
PR OverviewPR Type: Feature Focus Areas for Architect Review
Rereview ImpressionsProgress Since Last Review
New Issues Introduced (if any)
Remaining Concerns
PR InsightsPotential PR Improvements
PR Strengths
|
|
@cw-pr-agent rereview |
PR ScorecardScoreScoring MethodologyCommunication Scoring FrameworkThe overall communication score is a weighted average:
Formula: Code Scoring FrameworkThe scorecard evaluates code using 3 key reviewer questions:
PR Communication NotesDescription Quality
PR Size & Scope
Commit Messages
Issue NotesCode Correctness & Design Quality
Test Quality & Coverage
Code Readability & Maintainability
Based on 5dce4cc...245d72a |
| <> | ||
| {sections.map((section) => { | ||
| const Component = sectionMap[section._type] as React.ComponentType<typeof section> | ||
| console.log('Rendering section:', section._type, 'with key:', section._key) |
There was a problem hiding this comment.
Severity: 🟠 Major
Remove or gate this debug logging to development to avoid leaking CMS structure and spamming logs in production.
if (process.env.NODE_ENV === 'development') {
console.log('Rendering section:', section._type, 'with key:', section._key)
}| return ( | ||
| <> | ||
| {sections.map((section) => { | ||
| const Component = sectionMap[section._type] as React.ComponentType<typeof section> |
There was a problem hiding this comment.
Severity: 🟠 Major
Avoid as React.ComponentType<typeof section> by narrowing on section._type so TS enforces correct props per section variant.
switch (section._type) {
case 'heroSection': return <HeroSection key={section._key} {...section} />
}
PR OverviewPR Type: Feature Focus Areas for Architect Review
Rereview ImpressionsProgress Since Last Review
New Issues Introduced (if any)
Remaining Concerns
PR InsightsPotential PR Improvements
PR Strengths
|
What does this PR do?
sectionsarray instead of hardcoded layout fields.What steps does your reviewer have to take to test this PR manually?
npm run dev.http://localhost:3000/studio.http://localhost:3000/homeon the frontend.sectionsarray.Pull Request standards checklist - Please check off
Testing checklist - Please check off
Definition of Done - Please check off