Skip to content

Commit 87d1dd8

Browse files
committed
Use configurable mermaid theme (default dark)
I’ve added CSS to change edge labels to use a blurred backdrop rather than having a solid fill, as it makes them feel like entities on their own in the diagram with the theme defaults.
1 parent f60db09 commit 87d1dd8

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

_config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ reveal_path: reveal.js/
3636

3737
# mermaid.js diagram integration
3838
mermaid_diagrams: true
39+
mermaid_theme: dark # See https://mermaid-js.github.io/mermaid/#/theming?id=deployable-themes
3940

4041
# Exclude directories and/or files from the conversion
4142
exclude:

_layouts/reveal.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@
5252
<script type="text/template">
5353
{%
5454
assign lines = post.content | newline_to_br | strip_newlines | split: "<br />"
55+
%}{%
56+
assign mermaid_theme = site.mermaid_theme | default: 'dark'
57+
%}{%
58+
assign mermaid_span = '<!-- .slide: class="diagram-slide" data-transition="none"--><span class="diagram-data" style="display:none;">%%{init: {&#39;theme&#39;:&#39;' | append: mermaid_theme | append: '&#39;}}%%'
5559
%}{%
5660
for line in lines
5761
%}{%
@@ -63,7 +67,7 @@
6367
| replace:'</backgroundimage>','" --> '
6468
| replace:'<backgroundimageopacity>','<!-- .slide: data-background-opacity="'
6569
| replace:'</backgroundimageopacity>','" -->'
66-
| replace:'<mermaid>','<!-- .slide: class="diagram-slide" data-transition="none"--><span class="diagram-data" style="display:none;">'
70+
| replace:'<mermaid>',mermaid_span
6771
| replace:'</mermaid>','</span><div class="diagram-display" style="height: 300px;"></div>'
6872
%}{%
6973
assign first_char = line | strip

_posts/0000-01-09-svg-diagrams.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# SVG Diagrams
22

3-
<background>white</background>
4-
53
You can use [mermaid-js](https://mermaid-js.github.io/mermaid/) to create SVG diagrams.
64

7-
(enable the feature by setting `mermaid_diagrams` to `true` in `_config.yml`)
5+
(in `_config.yml` enable the feature by setting `mermaid_diagrams` to `true`, and override the [theme](https://mermaid-js.github.io/mermaid/#/theming?id=deployable-themes) with `mermaid_theme`)
86

97
<!-- .element: style="font-size: 50%;" -->
108

@@ -14,7 +12,7 @@ graph TD;
1412
A-->C;
1513
B-->D;
1614
C-->D;
17-
D-->E
15+
D-->|an edge label| E
1816
</mermaid>
1917
<!-- .element: style="height: 250px;" -->
2018

assets/css/mermaid.css

+5
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,9 @@ div.diagram-display svg {
88
max-width: 100% !important;
99
width: 100%;
1010
height: 100%;
11+
}
12+
span.edgeLabel, .edgeLabel rect {
13+
background: none !important;
14+
backdrop-filter: blur(10px);
15+
fill: none !important;
1116
}

0 commit comments

Comments
 (0)