codeblock: replace prism-react-renderer with shiki#18194
Open
pettinarip wants to merge 1 commit into
Open
Conversation
✅ Deploy Preview for ethereumorg ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
wackerow
approved these changes
May 15, 2026
Member
wackerow
left a comment
There was a problem hiding this comment.
Couple non-blocking comments, but this looks great to me @pettinarip, thanks! This paired with #18195 will be a nice polish to all the codeblocks.
Comment on lines
+60
to
+61
| const shouldShowCopyWidget = | ||
| resolvedLang !== "text" && COPY_WIDGET_LANGS.has(resolvedLang) |
Member
There was a problem hiding this comment.
Looks like this is parity with existing, but wondering if we should just make the copy button available for all of these -- especially with this design, it doesn't really get in the way much.
Member
There was a problem hiding this comment.
Curious if there is a reason for not placing this directly inside index.tsx (vs the index.ts exporter)?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Replaces
prism-react-rendererwithshikifor code block syntax highlighting. The newCodeblockis an async server component; the client wrapper only owns the collapse + copy controls.Why
prism-react-renderer(and JS-only alternatives likesugar-high) mis-tokenise everything outside the JS family on the tutorials and docs pages — exactly where highlighting matters most. Shiki ships 692 grammars and handles all of them."use client"wrapper viadangerouslySetInnerHTML. Grammars/themes never cross the RSC boundary, so the client bundle does not grow.--shiki-light/--shiki-darkCSS variables; the dark theme is selected purely via the.darkancestor.Changes
src/components/Codeblock/(serverCodeblock.tsx+ clientCodeblockClient.tsx) replaces the old single-filesrc/components/Codeblock.tsx.src/lib/shiki.ts— singleton highlighter with a fixed lang/theme allowlist (one-light + one-dark-pro) to avoid lazy-import latency on cold starts.src/styles/codeblock.css— token styles + dark-mode variable swap, imported once fromglobal.css.Test plan
/developers/tutorials/uniswap-v2-annotated-code— 149 blocks, good stress test)shiki/codeToHtml/@shikijssymbols leak into.next/static/chunks/*.js