mirror of https://github.com/onweru/compose.git

weru
09.04.2023 7abb9c355c1210fdee06e37cb9da4ccafb1ef081
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 
{{ if in .Content "mermaid" }}
<script type="module">
  import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
  let theme_input = elem('.color_choice');
  let key = theme_input.value;
 
  function getTheme(mode) {
    return key == 'dark' ? 'dark' : 'base';
  }
 
  function initializeMermaid(mode) {
    mermaid.initialize(
    { startOnLoad: true, theme: getTheme(mode) }
  );
  }
 
  initializeMermaid(key);
 
  theme_input.addEventListener('change', e => {
    location.reload();
    initializeMermaid(e.target.value);
  });
</script>
{{ end }}