feat: Use beautiful-mermaid for rendering Mermaid diagrams#2904
Merged
bezbac merged 1 commit intoMay 11, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@claude review |
e34c57b to
3c06f02
Compare
3c06f02 to
5779935
Compare
5779935 to
34018d6
Compare
34018d6 to
ec63483
Compare
ec63483 to
ce71efc
Compare
ce71efc to
167eae2
Compare
167eae2 to
bb80177
Compare
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.
Disclaimer: Experimental PR review
Greptile Summary
This PR replaces the CDN-loaded
mermaid.jsclient-side rendering approach withbeautiful-mermaid, a lightweight SSR-compatible library that generates SVGs synchronously without DOM dependencies. It also cleans up manual wrapper divs in the MDX docs and adds CSS class hooks for integrating mermaid diagrams inside theLangTabsshell.Mermaid.tsxdrops"use client", callsrenderMermaidSVGat render time with CSS-variable theming, and falls back to aCodeBlockdisplay on parse failure — eliminating the previous CDN script-injection pattern and enabling SSR.style.cssadds.mermaid-diagramstyles and:has()rules that stripCornerBoxchrome (border, background, padding) when a diagram appears inside aLangTabsshell.<div className="border rounded p-2">wrappers that are now handled by the component itself.Confidence Score: 4/5
Safe to merge — the core rendering change is well-structured and the new library is purpose-built for SSR use. The two style-level issues (conflicting Tailwind classes and a stray indentation) are cosmetic and don't affect functionality.
The migration from CDN-loaded mermaid to
beautiful-mermaidis clean and the fallback path is handled correctly. The conflictingrounded-lg/rounded-noneclasses inMermaid.tsxare inert in practice (Tailwind's CSS ordering ensuresrounded-nonewins) but are misleading. The indentation inconsistency inLangTabs.tsxis purely cosmetic. No logic or data-integrity concerns were found.components/Mermaid.tsx — conflicting border-radius utilities; components/LangTabs.tsx — stray indentation on the return statement.
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[MDX Page renders mermaid code block] --> B[Mermaid component receives chart string] B --> C{renderMermaidSVG\nbeautiful-mermaid} C -- success --> D[Returns SVG string\nwith CSS-variable theming] C -- throws --> E[Fallback: CodeBlock\nwith raw chart text] D --> F[dangerouslySetInnerHTML\ninjects SVG into div.mermaid-diagram] F --> G{Inside LangTabs?} G -- yes --> H[CSS :has rule strips\nCornerBox chrome] G -- no --> I[Normal bordered\ndiagram container]Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "feat: Use beautiful-mermaid for renderin..." | Re-trigger Greptile