feat(blog): add code block component [INTORG-767]#328
Conversation
✅ Deploy Preview for interledger-org-v5 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Infi-Knight
left a comment
There was a problem hiding this comment.
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
98015bb to
8a35ac2
Compare
very true - hadn't run the import |
404b291 to
da453de
Compare
da453de to
8e20457
Compare
8e20457 to
40e3cb2
Compare
| @@ -0,0 +1,150 @@ | |||
| --- | |||
| import { codeToHtml } from 'shiki' | |||
There was a problem hiding this comment.
we should declare shiki in package.json
| <div class="flex flex-col gap-space-xl"> | ||
| { | ||
| resolvedBlocks.map(({ Component, props }) => ( | ||
| <div class="w-full"> |
There was a problem hiding this comment.
please confirm before merge this doesn't break the wrapping behaviour for other components
| function normalizeCodeIndent(code: string): string { | ||
| return code.replace(/^((?: {4})+)/gm, (indent) => | ||
| ' '.repeat(indent.length / 4) | ||
| ) | ||
| } |
| 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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
| 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 :)
| setTimeout(() => { | ||
| btn.textContent = copyLabel | ||
| btn.setAttribute('aria-label', copyLabel) | ||
| }, 2000) |
Anca2022
left a comment
There was a problem hiding this comment.
Left some comments, but great job! 🚀 🎉






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
Checks
pnpm run formatpnpm run lintPR Checklist
feat: ...,fix: ...)