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:
```mermaid flowchart TD A[Start] --> B{Is it working?} B -->|Yes| C[Great!] B -->|No| D[Debug] D --> E[Fix Issue] E --> B C --> F[End] ```
This diagram shows our new branch protection workflow:
Here's how the fork management process works:
Code for this diagram:
```mermaid sequenceDiagram participant U as User participant F as Fork participant M as Main Repo participant CI as GitHub Actions U->>F: Create fork U->>F: Add personal content U->>F: Make improvements F->>M: Create pull request M->>CI: Run automated checks CI->>M: Validation results M->>M: Review and selective merge M->>F: Provide feedback ```
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:
```mermaid graph TB User[👤 Blog Users] --> Blog[Next.js Blog Template] Developer[👨💻 Developers] --> Blog Blog --> Cloudflare[☁️ Cloudflare Workers] Blog --> GitHub[📦 GitHub Repository] Blog --> CDN[🌍 Global CDN] subgraph "External Systems" Cloudflare GitHub CDN end subgraph "Next.js Blog Template" NextJS[Next.js 15 App] MDX[MDX Content] MUI[Material-UI] Mermaid[Mermaid Diagrams] end style Blog fill:#e1f5fe style Cloudflare fill:#fff3e0 style GitHub fill:#f3e5f5 style NextJS fill:#e8f5e8 style MDX fill:#fff8e1 style MUI fill:#fce4ec style Mermaid fill:#e8eaf6 ```
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:
// Regular code block (not Mermaid) function generateMermaidId() { return `mermaid-${Math.random().toString(36).substr(2, 9)}`; } console.log('This should be syntax highlighted, not rendered as a diagram');
And here's some TypeScript:
interface MermaidProps { chart: string; id?: string; } const MermaidComponent: React.FC<MermaidProps> = ({ chart, id }) => { // Component implementation return <div>Mermaid diagram here</div>; };
flowchart TD or graph TBsequenceDiagramclassDiagramstateDiagram-v2gitGraphpie title "Chart Title"journeystyle commands for better visual hierarchyCreate your diagram using Mermaid syntax in a code block:
```mermaid flowchart LR A[Write Post] --> B[Add Diagram] B --> C[Test in mermaid.live] C --> D[Publish] ```
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.