Skip to content

Commit 33f6d61

Browse files
DOC-5881 enable Mermaid diagrams
1 parent 64c3a82 commit 33f6d61

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

assets/css/index.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ section.prose {
8888
@apply bg-slate-900 rounded-lg;
8989
}
9090

91+
.prose pre.mermaid {
92+
background-color: white !important;
93+
border-radius: 0.5rem;
94+
padding: 1rem;
95+
}
96+
9197
.prose pre > code {
9298
@apply bg-none font-monogeist;
9399
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{{ $width := (index .Attributes "width") | default "75%" }}
2+
<div style="width: {{ $width }};">
3+
<pre class="mermaid" style="background-color: white; padding: 1rem; border-radius: 0.5rem;">
4+
{{ .Inner | htmlEscape | safeHTML }}
5+
</pre>
6+
</div>
7+
{{ .Page.Store.Set "hasMermaid" true }}

layouts/_default/baseof.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,20 @@
7979
{{ partial "toc-js.html" . }}
8080

8181
{{ partial "search-modal.html" . }}
82+
83+
{{ if .Store.Get "hasMermaid" }}
84+
<script type="module">
85+
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs';
86+
mermaid.initialize({
87+
startOnLoad: true,
88+
theme: 'base',
89+
themeVariables: {
90+
fontFamily: 'Space Mono',
91+
primaryColor: '#ffffff',
92+
primaryBorderColor: '#ee0000'
93+
}
94+
});
95+
</script>
96+
{{ end }}
8297
</body>
8398
</html>

0 commit comments

Comments
 (0)