Gutenberg Case Study Blocks Plan
Goal
Enable case study creators to build rich pages in WordPress Gutenberg while the Astro site renders those blocks as high-fidelity static pages.
Non-goals
- No full Gutenberg parity in phase 1.
- No dependency on front-end WordPress rendering at runtime.
- No shipping untrusted raw HTML without sanitization.
Proposed architecture
- Authors create case studies in WordPress using a constrained block set.
- Build step fetches post JSON from WP REST API, including
content.renderedand block metadata when available. - Astro parses Gutenberg block structure into an internal AST.
- Supported blocks map to typed Astro components.
- Unsupported blocks fall back to safe HTML rendering with warning logs.
- Build produces static pages and a support report for editorial + dev teams.
Content model in WordPress
- Create a dedicated case study post type (
case_study) with:
- title
- slug
- hero media
- summary/excerpt
- sector/client taxonomy
- project metrics (repeatable key/value)
- related work links
- Editorial constraints:
- Provide a “Bozboz Case Study” block pattern set.
- Restrict allowed blocks in case study editor.
- Prefer semantic blocks over freeform HTML.
Block support matrix (phase-based)
Phase 1: core essentials
core/paragraphcore/headingcore/listcore/imagecore/gallerycore/quotecore/separatorcore/buttons+core/buttoncore/spacercore/groupcore/columns+core/columncore/embed(whitelist providers)
Phase 2: richer storytelling
core/pullquotecore/tablecore/detailscore/media-text- custom metric cards block
- custom timeline/process block
Phase 3: advanced campaign layouts
- curated custom interactive blocks
- optional animation metadata fields for Astro/GSAP behavior
Rendering strategy in Astro
- Add a block parser in the content pipeline:
- input: WP post content + block metadata
- output: typed
CaseStudyBlock[]
- Create block components, e.g.:
src/components/blocks/BlockParagraph.astrosrc/components/blocks/BlockImage.astrosrc/components/blocks/BlockColumns.astro- etc.
- Add a block renderer switch:
- maps
blockName-> Astro component - logs unsupported blocks to build output
- preserves author intent where possible (alignment, spacing, caption, link behavior)
- Sanitization and safety:
- sanitize fallback HTML
- whitelist iframe/embed providers
- strip inline script/style payloads
Editorial experience
- Add a Gutenberg “Case Study Starter” pattern with:
- hero intro
- challenge/approach/outcome sections
- metrics row
- CTA block
- Add docs for creators:
- which blocks are supported
- how each block appears on static site
- what to avoid in phase 1
- Add preview QA checklist in editorial workflow.
Build and QA workflow
- During
npm run build, emit:
- unsupported block list per slug
- warning count per post
- summary table in console
-
Add visual regression snapshots for top case studies.
-
Add schema tests:
- block parser unit tests
- component snapshot tests
- sanitization tests
URL and routing proposal
- Listing page:
/work/ - Case study pages:
/work/{slug}/ - Keep current external fallback links while migrating entries incrementally.
Migration plan
- Pilot with 2 case studies.
- Freeze block set for phase 1.
- Build + QA + editorial review.
- Migrate remaining case studies in batches.
- Track unsupported block occurrences and prioritize next block implementations.
Risks and mitigations
- Risk: editorial uses unsupported blocks.
- Mitigation: allowed-block restrictions + build warnings + docs.
- Risk: design drift from authored content.
- Mitigation: pattern library + component parity reviews.
- Risk: embed/security issues.
- Mitigation: strict sanitization and provider allowlist.
Success criteria
- Authors can publish case studies without developer intervention.
- 90%+ of case study block usage supported in phase 1+2.
- Zero runtime dependency on WordPress rendering.
- Lighthouse and accessibility scores stay within current site targets.
Suggested implementation tasks
- Define
case_studypost type + taxonomies in WP. - Add Gutenberg allowed-block policy for case studies.
- Build parser + AST types in
src/lib/wp.tspipeline. - Implement phase 1 block components.
- Add build warnings/reporting for unsupported blocks.
- Pilot on 2 real case studies and iterate.
Current scaffold in this repo
The following foundation has already been added:
- Parser + support matrix:
src/lib/gutenberg.ts
- Renderer + JS enhancements:
src/components/blocks/GutenbergRenderer.astrosrc/components/blocks/GutenbergEnhancements.astro
- Core block styling layer:
src/styles/blocks/_gutenberg-core.scss
- Sandbox route for testing block rendering:
/ideas/gutenberg-sandbox/