2024-08-24 by Remi Kristelijn
This post tests the Mermaid diagram functionality in our blog. Mermaid allows us to create diagrams and flowcharts using simple text syntax.
Here's a basic flowchart showing a decision process:
Code for this diagram:
1```mermaid 2flowchart TD 3 A[Start] --> B{Is it working?} 4 B -->|Yes| C[Great!] 5 B -->|No| D[Debug] 6 D --> E[Fix Issue] 7 E --> B 8 C --> F[End] 9```
This diagram shows our new branch protection workflow:
Here's how the fork management process works:
Code for this diagram:
1```mermaid 2sequenceDiagram 3 participant U as User 4 participant F as Fork 5 participant M as Main Repo 6 participant CI as GitHub Actions 7 8 U->>F: Create fork 9 U->>F: Add personal content 10 U->>F: Make improvements 11 F->>M: Create pull request 12 M->>CI: Run automated checks 13 CI->>M: Validation results 14 M->>M: Review and selective merge 15 M->>F: Provide feedback 16```
The architecture of our blog system:
Distribution of our documentation types:
The lifecycle of a blog post:
User experience with our blog template:
This shows our blog template in the context of its environment:
Code for this diagram:
1```mermaid 2graph TB 3 User[👤 Blog Users] --> Blog[Next.js Blog Template] 4 Developer[👨💻 Developers] --> Blog 5 6 Blog --> Cloudflare[☁️ Cloudflare Workers] 7 Blog --> GitHub[📦 GitHub Repository] 8 Blog --> CDN[🌍 Global CDN] 9 10 subgraph "External Systems" 11 Cloudflare 12 GitHub 13 CDN 14 end 15 16 subgraph "Next.js Blog Template" 17 NextJS[Next.js 15 App] 18 MDX[MDX Content] 19 MUI[Material-UI] 20 Mermaid[Mermaid Diagrams] 21 end 22 23 style Blog fill:#e1f5fe 24 style Cloudflare fill:#fff3e0 25 style GitHub fill:#f3e5f5 26 style NextJS fill:#e8f5e8 27 style MDX fill:#fff8e1 28 style MUI fill:#fce4ec 29 style Mermaid fill:#e8eaf6 30```
This shows the main containers within our blog system:
These diagrams should automatically adapt to both light and dark themes. The Mermaid component uses the current Material-UI theme to configure colors and styling.
For comparison, here's regular code syntax highlighting:
1// Regular code block (not Mermaid) 2function generateMermaidId() { 3 return `mermaid-${Math.random().toString(36).substr(2, 9)}`; 4} 5 6console.log('This should be syntax highlighted, not rendered as a diagram');
And here's some TypeScript:
1interface MermaidProps { 2 chart: string; 3 id?: string; 4} 5 6const MermaidComponent: React.FC<MermaidProps> = ({ chart, id }) => { 7 // Component implementation 8 return <div>Mermaid diagram here</div>; 9};
flowchart TD or graph TBsequenceDiagramclassDiagramstateDiagram-v2gitGraphpie title "Chart Title"journeystyle commands for better visual hierarchyCreate your diagram using Mermaid syntax in a code block:
1```mermaid 2flowchart LR 3 A[Write Post] --> B[Add Diagram] 4 B --> C[Test in mermaid.live] 5 C --> D[Publish] 6```
Before publishing, test your diagram at mermaid.live to ensure it renders correctly.
Simply paste the code block into your .mdx file and it will automatically render as a visual diagram.
If you can see properly rendered diagrams above (not just code blocks), then Mermaid integration is working correctly! The diagrams should:
This enables us to create rich, visual documentation and blog posts with flowcharts, architecture diagrams, and process flows directly in Markdown.