-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat: add PreviewableCode component with Mermaid and PlantUML support #1131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@xianminx is attempting to deploy a commit to the timlrx's projects Team on Vercel. A member of the Team first needs to authorize it. |
@timlrx For client-side Mermaid rendering, I understand it can be heavy. However, if we render Mermaid diagrams at build time, the mermaid.js library requires a browser environment for layout. Running it in Node.js would necessitate heavier tools like Puppeteer or Playwright. In comparison, client-side rendering seems like the more efficient option. For PlantUML rendering, due to its heavy dependency on Java, the simplest approach is to leverage the official online service for previewing diagrams. Looking forward to your thoughts! Link issue #394 and PR #971 |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There's a bunch of warning and errors:
You could try building locally to ensure that there are no issues before pushing |
Hi @xianminx, thanks for the PR and nice to see that you managed to integrate both mermaid and plantUML diagrams to the template! Since, I believe most users of the blog will probably not use such diagrammatic features, my preference would be to exclude them and have users extend to include additional features as required. Having said that, the examples of the integration would be very useful though and we could link the preview build as an example for users who want to implement something similar - they can then copy the code from your branch. |
Fair enough. I also believe it's best to keep the product focused and simple. I'm still happy to experiment and contribute. |
Overview
This PR introduces a new
PreviewableCode
component that enhances code block rendering in MDX by providing an interactive tabbed interface for previewable content. It supports rendering of Mermaid diagrams and PlantUML diagrams directly in the browser.Key Features
Technical Details
PreviewableCode.tsx
: Main component for handling previewable code blocksMermaid.tsx
: Client-side Mermaid diagram rendererPlantUML.tsx
: Server-side PlantUML diagram rendererMDXComponents.tsx
to use the new PreviewableCode componentmermaid
: For client-side diagram renderingplantuml-encoder
: For PlantUML diagram encoding@types/plantuml-encoder
: TypeScript type definitionsUsage Examples
The component can be used in MDX files with the following syntax:
Testing
previewable_code.mdx
with examples and documentationNotes