Mermaid Diagram Generator
Generate diagrams for Hugo posts using the LoveIt theme's mermaid shortcode.
Output Format
hugo
{{< mermaid >}}
<mermaid code>
{{< /mermaid >}}
Diagram Type Selection
| Concept | Diagram Type | Keyword |
|---|---|---|
| Pipeline/workflow states | stateDiagram-v2 | States with transitions |
| System architecture | graph LR or graph TB | Boxes and arrows |
| API/event sequences | sequenceDiagram | Actor interactions over time |
| Data models | erDiagram | Tables with relationships |
| Project timelines | gantt | Tasks with dates |
| Decision trees | flowchart | Conditions and branches |
Examples
State diagram (user journey, pipeline stages):
code
stateDiagram-v2
[*] --> Raw
Raw --> Staged: validate
Staged --> Curated: transform
Curated --> [*]
Flowchart (architecture, data flow):
code
graph LR
A[Source] --> B{Validate}
B -->|Pass| C[Transform]
B -->|Fail| D[DLQ]
C --> E[(Warehouse)]
Sequence (API calls, message flow):
code
sequenceDiagram
Producer->>Kafka: publish
Kafka->>Consumer: poll
Consumer->>DB: write
ER diagram (schema relationships):
code
erDiagram
USER ||--o{ ORDER : places
ORDER ||--|{ ITEM : contains
Guidelines
- •Choose diagram type based on what's being illustrated, not user's exact words
- •Keep diagrams simple: 5-10 nodes max
- •Use short, clear labels
- •Direction:
LRfor processes,TBfor hierarchies - •No titles in diagram - post context provides it