Hugo学习笔记四,干特图初体验

在markdown下可以写出流程图,甘特图之类的,可采用mermaid这个插件,今天在hugo下试用

采用LoviIt皮肤,按网上配置肿是不行。后来发现themes/LoveIt/layouts/shortcodes/下有mermaid.html文件,说明这个主题己经配置好了mermaid,只是格式不同。正好在Doit主题说明书里看到了,是写的语法不对改为以下

甘特图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 甘特图
{{< mermaid >}}gantt
dateFormat YYYY-MM-DD
title 利用mermaid功能,增加一个甘特图
section 第一节
己完成任务 :done, des1, 2014-01-06,2014-01-08
正在进行的任务 :active, des2, 2014-01-09, 3d
未来任务1 : des3, after des2, 5d
未来任务2 : des4, after des3, 5d
section Critical tasks
Completed task in the critical line :crit, done, 2014-01-06,24h
Implement parser and jison :crit, done, after des1, 2d
Create tests for parser :crit, active, 3d
Future task in critical line :crit, 5d
Create tests for renderer :2d
Add to mermaid :1d
{{< /mermaid >}}

类图
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

{{< mermaid >}}classDiagram
Class01 <|-- AveryLongClass : Cool
Class03 *-- Class04
Class05 o-- Class06
Class07 .. Class08
Class09 --> C2 : Where am i?
Class09 --* C3
Class09 --|> Class07
Class07 : equals()
Class07 : Object[] elementData
Class01 : size()
Class01 : int chimp
Class01 : int gorilla
Class08 <--> C2: Cool label
{{< /mermaid >}}

旅行图,但看起来比甘特图更好
1
2
3
4
5
6
7
8
9
10
{{< mermaid >}} journey
title My working day
section Go to work
Make tea: 5: Me
Go upstairs: 3: Me
Do work: 1: Me, Cat
section Go home
Go downstairs: 5: Me
Sit down: 5: Me
{{< /mermaid >}}
流程图
1
2
3
4
5
6
{{< mermaid >}}graph LR;
A[Hard edge] -->|Link text| B(Round edge)
B --> C{Decision}
C -->|One| D[Result one]
C -->|Two| E[Result two]
{{< /mermaid >}}
时序图
1
2
3
4
5
6
7
8
9
10
11
12
{{< mermaid >}}sequenceDiagram
participant Alice
participant Bob
Alice->>John: Hello John, how are you?
loop Healthcheck
John->John: Fight against hypochondria
end
Note right of John: Rational thoughts <br/>prevail...
John-->Alice: Great!
John->Bob: How about you?
Bob-->John: Jolly good!
{{< /mermaid >}}