この
文字だけで
そんな
draw.ioのような
Mermaid が
さて、
法
実装方rehype-mermaidと
この
Mermaid の
とりあえずrehypePlugins
に
import rehypeMermaid from 'rehype-mermaid';
export default makeSource({ mdx: { rehypePlugins: [ [rehypeMermaid] ], },});
デフォルトの
rehype-mermaid
の
公式ドキュメントを
import type { RehypeMermaidOptions } from 'rehype-mermaid';
const mermaidConfig = { theme: 'base', fontFamily: 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"', fontSize: 13, themeVariables: { primaryColor: '#b0b0b0', secondaryColor: '#545480', primaryBorderColor: '#4c4c53', primaryTextColor: '#f4f4f5', secondaryTextColor: '#f4f4f5', lineColor: '#4c4c53', textColor: '#f4f4f5', ... },} satisfies RehypeMermaidOptions['mermaidConfig'];
export const rehypeMermaidOptions = { mermaidConfig,} satisfies RehypeMermaidOptions;
fontFamily
にはnext/font
themeVariables
はtheme
をbase
にしなければならない。
それぞれの
分量が
途方も
あとは、line-height: 1.1rem
を
例
Mermaid の前述した
Flowchart
```mermaidflowchart TB c1 --> a2
subgraph one a1 --> a2 end
subgraph two b1 --> b2 end
subgraph three c1 --> c2 end
one --> two three --> two two --> c2```
↓
Sequence diagrams
```mermaidsequenceDiagram autonumber
Alice ->> John: Hello John, how are you?
loop Healthcheck John ->> John: Fight against hypochondria end
Note right of John: Rational thoughts!
John -->> Alice: Great! John ->> Bob: How about you? Bob -->> John: Jolly good!```
↓
State diagrams
```mermaidstateDiagram-v2 state fork_state <<fork>> [*] --> fork_state fork_state --> State2 fork_state --> State3
state join_state <<join>> State2 --> join_state State3 --> join_state join_state --> State4 State4 --> [*]```
↓
Gitgraph Diagrams
```mermaidgitGraph commit id: "ZERO" branch develop branch release commit id: "A" checkout main commit id: "ONE" checkout develop commit id: "B" checkout main merge develop id: "MERGE" commit id: "TWO" checkout release cherry-pick id: "MERGE" parent:"B" commit id: "THREE" checkout develop commit id: "C"```
↓
こと メモ
やってみたい- コードと
プレビューを 切り 替えられるように する - 拡大・縮小を
できるように する