feat: update mermaid shortcode

This commit is contained in:
Henk Verlinde 2021-06-30 20:32:28 +02:00
parent f7867376fb
commit b7eda85593
4 changed files with 36 additions and 19 deletions

View File

@ -3,8 +3,6 @@ var config = {
fontFamily: '"Jost", -apple-system, blinkmacsystemfont, "Segoe UI", roboto, "Helvetica Neue", arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";',
};
/* eslint-disable no-undef */
mermaid.initialize(config);
/* eslint-enable no-undef */
document.addEventListener('DOMContentLoaded', () => {
mermaid.initialize(config);
});

View File

@ -92,6 +92,3 @@ rel = "sitemap"
[[module.mounts]]
source = "node_modules/mermaid"
target = "assets/js/vendor/mermaid"
[[module.mounts]]
source = "node_modules/mermaid"
target = "static/js/vendor/mermaid"

View File

@ -15,6 +15,16 @@ toc: true
## Flow
```md
{{</* mermaid class="bg-light text-center" */>}}
graph TD
A[Hard] -->|Text| B(Round)
B --> C{Decision}
C -->|One| D[Result 1]
C -->|Two| E[Result 2]
{{</* /mermaid */>}}
```
{{< mermaid class="bg-light text-center">}}
graph TD
A[Hard] -->|Text| B(Round)
@ -54,14 +64,21 @@ gantt
{{< mermaid >}}
classDiagram
classA --|> classB : Inheritance
classC --* classD : Composition
classE --o classF : Aggregation
classG --> classH : Association
classI -- classJ : Link(Solid)
classK ..> classL : Dependency
classM ..|> classN : Realization
classO .. classP : Link(Dashed)
Class01 <|-- AveryLongClass : Cool
<<interface>> Class01
Class09 --> C2 : Where am i?
Class09 --* C3
Class09 --|> Class07
Class07 : equals()
Class07 : Object[] elementData
Class01 : size()
Class01 : int chimp
Class01 : int gorilla
class Class10 {
<<service>>
int id
size()
}
{{< /mermaid >}}
## State

View File

@ -1,3 +1,8 @@
<div class="mermaid{{ with .Get "class" }} {{ . }}{{ end }}">
{{- .Inner -}}
</div>
{{ if .Site.Params.options.mermaid -}}
<div class="mermaid{{ with .Get "class" }} {{ . }}{{ end }}">
{{ $data := replaceRE "(^\\s+```)" "" .Inner -}}
{{ replaceRE "(```\\s+$)" "" $data -}}
</div>
{{ else }}
{{ errorf "Set `mermaid = true` in `./config/_default/params.toml`"}}
{{ end }}