Skip to content

Commit 17eac04

Browse files
joaoh82claude
andauthored
feat(web): syntax highlighting for blog MDX + SDK showcase (SQLR-44) (#121)
* feat(web): syntax highlighting for blog MDX (SQLR-44) Wire rehype-pretty-code + Shiki into the MDXRemote pipeline in web/src/components/blog-mdx.tsx and map Shiki's --shiki-token-* CSS variables onto the blog's existing palette tokens in globals.css so themes stay coherent. Inline code keeps its chip styling (bypassInlineCode) and unlanguaged fences fall back to plaintext. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(web): syntax highlighting for SDK showcase on landing Pre-render the six SDK snippets with shiki at build time and ship the resulting HTML to the existing client-side tab switcher. The shiki theme (createCssVariablesTheme) and helper move to a shared src/lib/highlight.ts so the blog MDX and the landing page reuse the same --shiki-token-* → palette mapping. The .code-body rule in globals.css declares the same shiki var mapping the blog does. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 2d15aef commit 17eac04

8 files changed

Lines changed: 649 additions & 92 deletions

File tree

web/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,30 @@ backticks or escape (`&lt;`, `\{`). The MDX renderer auto-routes
146146
internal `[link](/foo)` markdown links through `next/link`; external
147147
links open in a new tab via `rel="noreferrer"`.
148148

149+
### Code block highlighting
150+
151+
Code is tokenized at build time by [Shiki](https://shiki.style/). The
152+
shared theme + helper live in
153+
[`src/lib/highlight.ts`](src/lib/highlight.ts) and use
154+
`createCssVariablesTheme()` so Shiki emits inline styles like
155+
`color: var(--shiki-token-keyword)`. Each surface that needs
156+
highlighting then maps the `--shiki-*` variables onto the blog's
157+
palette tokens (`--color-kw`, `--color-str`, `--color-num`, …) in
158+
[`src/app/globals.css`](src/app/globals.css) — adjust colors there,
159+
not in the components. Two consumers:
160+
161+
- **Blog MDX** (`src/components/blog-mdx.tsx`) — uses
162+
[`rehype-pretty-code`](https://github.com/rehype-pretty/rehype-pretty-code)
163+
inside the `MDXRemote` pipeline. Inline `` `code` `` keeps its chip
164+
styling (`bypassInlineCode: true`); fences without a language tag
165+
fall back to `plaintext` so a missing language never breaks the
166+
build. Mapping lives on `.blog-article-body pre`.
167+
- **SDK showcase** (`src/components/sdk-showcase.tsx`
168+
server-rendered, paired with a small client wrapper for the tab
169+
state) pre-renders each language snippet with `highlightCode()` and
170+
embeds the resulting HTML inside `.code-body`. Mapping lives on
171+
`.code-body`.
172+
149173
The design tokens (colors, typography, spacing) live in `globals.css`'s
150174
`@theme` block. The page-level CSS (sections, terminal, feature grid,
151175
roadmap timeline, etc.) is intentionally hand-rolled — it ports the

0 commit comments

Comments
 (0)