feat: add Mermaid

This commit is contained in:
st1020 2023-10-22 18:00:08 +08:00
parent 66b48ea8d7
commit 933cc3efa5
5 changed files with 48 additions and 21 deletions

View file

@ -16,6 +16,7 @@ This theme is based on Hugo theme [hugo-paper](https://github.com/nanxiaobei/hug
- SEO Friendly - SEO Friendly
- Comments using [Giscus](https://giscus.app/) - Comments using [Giscus](https://giscus.app/)
- Mathematical notations using [KaTeX](https://katex.org/) - Mathematical notations using [KaTeX](https://katex.org/)
- Diagrams and charts using [Mermaid](https://mermaid.js.org/)
## Installation ## Installation

View file

@ -4,6 +4,8 @@ date = "2019-03-11"
description = "Sample article showcasing basic Markdown syntax and formatting for HTML elements." description = "Sample article showcasing basic Markdown syntax and formatting for HTML elements."
[taxonomies] [taxonomies]
tags = ["markdown", "css", "html"] tags = ["markdown", "css", "html"]
[extra]
mermaid = true
+++ +++
This article offers a sample of basic Markdown syntax that can be used in Zola content files, also it shows whether basic HTML elements are decorated with CSS in a Zola theme. This article offers a sample of basic Markdown syntax that can be used in Zola content files, also it shows whether basic HTML elements are decorated with CSS in a Zola theme.
@ -128,3 +130,19 @@ X<sup>n</sup> + Y<sup>n</sup> = Z<sup>n</sup>
Press <kbd><kbd>CTRL</kbd>+<kbd>ALT</kbd>+<kbd>Delete</kbd></kbd> to end the session. Press <kbd><kbd>CTRL</kbd>+<kbd>ALT</kbd>+<kbd>Delete</kbd></kbd> to end the session.
Most <mark>salamanders</mark> are nocturnal, and hunt for insects, worms, and other small creatures. Most <mark>salamanders</mark> are nocturnal, and hunt for insects, worms, and other small creatures.
## Mermaid
{% 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!
{% end %}

View file

@ -1176,6 +1176,10 @@ body {
margin-bottom: 0.375rem; margin-bottom: 0.375rem;
} }
.mb-12 {
margin-bottom: 3rem;
}
.mb-16 { .mb-16 {
margin-bottom: 4rem; margin-bottom: 4rem;
} }
@ -1232,10 +1236,6 @@ body {
margin-top: 4rem; margin-top: 4rem;
} }
.mb-12 {
margin-bottom: 3rem;
}
.block { .block {
display: block; display: block;
} }
@ -1415,6 +1415,11 @@ body {
background-color: rgb(0 0 0 / 3%); background-color: rgb(0 0 0 / 3%);
} }
.bg-white {
--tw-bg-opacity: 1;
background-color: rgb(255 255 255 / var(--tw-bg-opacity));
}
.bg-white\/50 { .bg-white\/50 {
background-color: rgb(255 255 255 / 0.5); background-color: rgb(255 255 255 / 0.5);
} }
@ -1439,6 +1444,11 @@ body {
padding: 1.5rem; padding: 1.5rem;
} }
.px-2 {
padding-left: 0.5rem;
padding-right: 0.5rem;
}
.px-4 { .px-4 {
padding-left: 1rem; padding-left: 1rem;
padding-right: 1rem; padding-right: 1rem;
@ -1479,11 +1489,6 @@ body {
padding-bottom: 1rem; padding-bottom: 1rem;
} }
.px-2 {
padding-left: 0.5rem;
padding-right: 0.5rem;
}
.pb-1 { .pb-1 {
padding-bottom: 0.25rem; padding-bottom: 0.25rem;
} }
@ -1504,6 +1509,10 @@ body {
padding-left: 0.75rem; padding-left: 0.75rem;
} }
.pl-4 {
padding-left: 1rem;
}
.pr-2 { .pr-2 {
padding-right: 0.5rem; padding-right: 0.5rem;
} }
@ -1516,18 +1525,6 @@ body {
padding-top: 8rem; padding-top: 8rem;
} }
.pl-2 {
padding-left: 0.5rem;
}
.pl-6 {
padding-left: 1.5rem;
}
.pl-4 {
padding-left: 1rem;
}
.text-center { .text-center {
text-align: center; text-align: center;
} }

View file

@ -56,6 +56,14 @@
{% endif %} {% endif %}
<!----> <!---->
<!-- Mermaid -->
{% if page.extra.mermaid %}
<script type="module">
import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs";
mermaid.initialize({ startOnLoad: true });
</script>
{% endif %}
<!-- Favicon --> <!-- Favicon -->
<link rel="icon" href="{{ get_url(path=`favicon.ico`) }}" /> <link rel="icon" href="{{ get_url(path=`favicon.ico`) }}" />
<link rel="apple-touch-icon" href="{{ get_url(path=`apple-touch-icon.png`) }}" /> <link rel="apple-touch-icon" href="{{ get_url(path=`apple-touch-icon.png`) }}" />

View file

@ -0,0 +1,3 @@
<pre class="mermaid bg-white">
{{ body }}
</pre>