Skip to content

feat(blog): add code block component [INTORG-767]#328

Open
JonathanMatthey wants to merge 9 commits into
stagingfrom
jm/intorg-767-code-block
Open

feat(blog): add code block component [INTORG-767]#328
JonathanMatthey wants to merge 9 commits into
stagingfrom
jm/intorg-767-code-block

Conversation

@JonathanMatthey

@JonathanMatthey JonathanMatthey commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a code block component for blog posts, syntax highlighting via Shiki, copy button, optional title, 14 supported languages. Covers the Strapi component schema, MDX serializer, and Astro render component.

Related Issue

Fixes INTORG-767

Manual Test

  1. Add a Code Block to a blog post in Strapi and run MDX sync
  2. Check syntax highlighting and the copy button work in the browser

Checks

  • pnpm run format
  • pnpm run lint

PR Checklist

  • PR title follows Conventional Commits (e.g. feat: ..., fix: ...)
  • Linked issue included
  • Scope is focused (target ~10-20 files when possible)
  • Screenshots for UI changes (if applicable)

@JonathanMatthey JonathanMatthey self-assigned this Jun 4, 2026
@netlify

netlify Bot commented Jun 4, 2026

Copy link
Copy Markdown

Deploy Preview for interledger-org-v5 ready!

Name Link
🔨 Latest commit 07928bf
🔍 Latest deploy log https://app.netlify.com/projects/interledger-org-v5/deploys/6a3bb9bd3a814700087a6c2b
😎 Deploy Preview https://deploy-preview-328--interledger-org-v5.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@Infi-Knight Infi-Knight left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks like there is no import handler for CodeBlock? i.e the export path works but the parser will hard-fail without a registered handler

@JonathanMatthey

Copy link
Copy Markdown
Collaborator Author

looks like there is no import handler for CodeBlock? i.e the export path works but the parser will hard-fail without a registered handler

very true - hadn't run the import

@@ -0,0 +1,150 @@
---
import { codeToHtml } from 'shiki'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we should declare shiki in package.json

<div class="flex flex-col gap-space-xl">
{
resolvedBlocks.map(({ Component, props }) => (
<div class="w-full">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please confirm before merge this doesn't break the wrapping behaviour for other components

Comment on lines +33 to +37
function normalizeCodeIndent(code: string): string {
return code.replace(/^((?: {4})+)/gm, (indent) =>
' '.repeat(indent.length / 4)
)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this normalizeCodeIndent makes the round trip syncs asymetrical

Strapi -> Astro keeps original indent

Image

Astro -> Strapi normalizes indent

Image

@Anca2022 Anca2022 Jun 24, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The component doesn't quite match the Figma design yet. Could you please update the styles to align more closely with the design specs?
Figma

Image

vs branch

Image

data-component="code-block"
>
<div
class="flex items-center gap-space-xs px-space-s py-space-2xs bg-[#f6f8fa] border-b border-neutral-25 rounded-t-lg"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, could you use the existing design tokens instead of Tailwind variables(gap-space-s, `text-step--2)?

---

<figure
class="my-0 w-full min-w-0 rounded-lg border border-neutral-25 text-step--1"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
class="my-0 w-full min-w-0 rounded-lg border border-neutral-25 text-step--1"
class="my-2xl w-full min-w-0 rounded-lg border border-neutral-25 text-step--1"

This needs some margin - 2xl matches the margin paragraphs use :)

Comment on lines +144 to +147
setTimeout(() => {
btn.textContent = copyLabel
btn.setAttribute('aria-label', copyLabel)
}, 2000)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This only sets the text, it looses the svg

Image => Image

@Anca2022 Anca2022 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Left some comments, but great job! 🚀 🎉

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.

3 participants