Skip to content

Use datocms astro structured text instead of own structured text component#335

Open
JopMolenaar wants to merge 18 commits intomainfrom
feat/use-datocms-astro-components-instead-of-own-components
Open

Use datocms astro structured text instead of own structured text component#335
JopMolenaar wants to merge 18 commits intomainfrom
feat/use-datocms-astro-components-instead-of-own-components

Conversation

@JopMolenaar
Copy link
Copy Markdown
Contributor

@JopMolenaar JopMolenaar commented Apr 1, 2026

Changes

Use datocms astro components instead of own components

Associated issue

Resolves #333

How to test

  1. Check if nothing breaks when making content in a textblock in random blocks where this component is used.
  2. Compare it to the main branch (changes in primary and view it in preview)

Checklist

  • I have performed a self-review of my own code
  • I have made sure that my PR is easy to review (not too big, includes comments)
  • I have made updated relevant documentation files (in project README, docs/, etc)
  • I have added a decision log entry if the change affects the architecture or changes a significant technology
  • I have notified a reviewer

@JopMolenaar JopMolenaar force-pushed the feat/use-datocms-astro-components-instead-of-own-components branch from 7c8b6f5 to ad393eb Compare April 1, 2026 11:07
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 1, 2026

Deploying head-start with  Cloudflare Pages  Cloudflare Pages

Latest commit: efff68d
Status: ✅  Deploy successful!
Preview URL: https://4136403a.head-start.pages.dev
Branch Preview URL: https://feat-use-datocms-astro-compo.head-start.pages.dev

View logs

@JopMolenaar JopMolenaar self-assigned this Apr 1, 2026
@JopMolenaar JopMolenaar force-pushed the feat/use-datocms-astro-components-instead-of-own-components branch from bae5999 to 38dc91a Compare April 1, 2026 15:48
@JopMolenaar JopMolenaar marked this pull request as ready for review April 3, 2026 08:39
Copilot AI review requested due to automatic review settings April 3, 2026 08:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the project’s Structured Text and image rendering to the official @datocms/astro components, removing the custom StructuredText implementation and updating blocks/docs accordingly.

Changes:

  • Replaced the custom StructuredText renderer with a new src/components/Text/Text.astro wrapper around @datocms/astro/StructuredText, including node overrides and record/block mappings.
  • Updated the Image block to use @datocms/astro’s Image component and adjusted GraphQL fragments/tests for the new data shape.
  • Removed the legacy src/components/StructuredText/* implementation and updated usage/docs across blocks.

Reviewed changes

Copilot reviewed 33 out of 37 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/components/Text/Text.test.ts Updates the tested component import for the new Text wrapper.
src/components/Text/Text.astro New Structured Text wrapper using @datocms/astro/StructuredText with overrides/mappings.
src/components/Text/README.md Documents new Text/StructuredText usage and override behavior.
src/components/Text/nodes/Paragraph.astro Adds paragraph override with centered styling support.
src/components/Text/nodes/ItemLink.astro Aligns item-link rendering with record-based props.
src/components/Text/nodes/Heading.astro Keeps heading behavior while enforcing h2+ levels.
src/components/Text/nodes/Code.astro Updates code rendering to a safer <pre><code> output.
src/components/Text/nodes/Block.astro Adds block renderer to route structured-text blocks through ~/blocks/Blocks.astro.
src/components/StructuredText/StructuredText.d.ts Removes legacy StructuredText typing helper.
src/components/StructuredText/StructuredText.astro Removes legacy StructuredText component implementation.
src/components/StructuredText/README.md Removes legacy StructuredText documentation.
src/components/StructuredText/Nodes/ThematicBreak.astro Removes legacy node component.
src/components/StructuredText/Nodes/Span.astro Removes legacy node component.
src/components/StructuredText/Nodes/Root.astro Removes legacy node component.
src/components/StructuredText/Nodes/ListItem.astro Removes legacy node component.
src/components/StructuredText/Nodes/List.astro Removes legacy node component.
src/components/StructuredText/Nodes/Link.test.ts Removes legacy Link node test.
src/components/StructuredText/Nodes/Link.astro Removes legacy Link node component.
src/components/StructuredText/Nodes/InlineBlock.astro Removes legacy inline block node component.
src/components/StructuredText/Nodes/Blockquote.astro Removes legacy node component.
src/components/StructuredText/Node.astro Removes legacy recursive node renderer.
src/components/LinkToRecord/LinkToRecord.astro Extends record linking to support VariableRecord rendering.
src/blocks/TextImageBlock/TextImageBlock.astro Switches to shared ~/components/Text/Text.astro.
src/blocks/TextBlock/TextBlock.astro Switches to shared ~/components/Text/Text.astro.
src/blocks/TextBlock/Text.astro Removes legacy shared TextBlock StructuredText adapter.
src/blocks/TextBlock/README.md Updates docs to reflect the moved Text logic.
src/blocks/TextBlock/nodes/InlineItem.astro Removes legacy inline item renderer (variable/link handling).
src/blocks/TextBlock/nodes/Heading.astro Removes legacy heading override implementation.
src/blocks/ListBlock/ListBlockFragment.graphql Adds links selection for list-item structured text.
src/blocks/ListBlock/ListBlock.astro Switches to shared ~/components/Text/Text.astro.
src/blocks/ImageBlock/README.md Updates docs to reference DatoCMS Astro image handling.
src/blocks/ImageBlock/ImageBlock.test.ts Updates expectations for the new image output/styling behavior.
src/blocks/ImageBlock/ImageBlock.fragment.graphql Adds srcSet to the image responsive payload.
src/blocks/ImageBlock/Image.client.ts Removes custom element behavior previously used for load handling.
src/blocks/ImageBlock/Image.astro Migrates image rendering to @datocms/astro Image and updates fallback styling.
package.json Adds @datocms/astro dependency.
package-lock.json Locks @datocms/astro and transitive dependencies.
Comments suppressed due to low confidence (1)

src/components/Text/Text.test.ts:6

  • Text.astro expects a data prop, but this test renders the component without providing any props. That will pass undefined into @datocms/astro’s StructuredText and is likely to throw at runtime, causing the test to fail. Pass a minimal valid Structured Text value in renderToFragment options (or update Text.astro to safely handle missing/null data).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/blocks/ImageBlock/Image.astro Outdated
Comment thread src/blocks/ImageBlock/Image.astro Outdated
Comment thread src/blocks/ImageBlock/Image.astro Outdated
Comment thread src/components/LinkToRecord/LinkToRecord.astro
@JopMolenaar JopMolenaar force-pushed the feat/use-datocms-astro-components-instead-of-own-components branch 2 times, most recently from a3c1884 to 025863a Compare April 9, 2026 14:47
@JopMolenaar JopMolenaar force-pushed the feat/use-datocms-astro-components-instead-of-own-components branch from 025863a to 3223e9e Compare April 15, 2026 09:18
Comment thread src/blocks/ImageBlock/ImageBlock.fragment.graphql
Comment thread src/blocks/TextImageBlock/TextImageBlock.fragment.graphql
Comment thread src/components/LinkToRecord/LinkToRecord.astro Outdated
@JopMolenaar JopMolenaar changed the title Use datocms astro components instead of own components Use datocms astro structured text instead of own structured text component Apr 24, 2026
Comment thread src/blocks/TextImageBlock/TextImageBlock.fragment.graphql Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace structured text component with the one from @datocms/astro

3 participants