Skip to content

Commit

Permalink
Use cnjs for mermaid, add support for jszoom
Browse files Browse the repository at this point in the history
  • Loading branch information
gamingrobot committed Jul 3, 2024
1 parent 6428f36 commit aac15c7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ author_url = "https://fosstodon.org/@gamingrobot"
# https://www.goatcounter.com/
goatcounter = "grbt-doingstuff"

# https://github.com/francoischalifour/medium-zoom
jszoom = false

# https://mermaid.js.org/
mermaid_theme = "default"
mermaid_theme_dark = "dark"
Expand Down
3 changes: 3 additions & 0 deletions themes/hyde-hyde-hyde-zola/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ author_url = "https://example.com"
# https://www.goatcounter.com/
# goatcounter = "goatcounter-code-here"

# https://github.com/francoischalifour/medium-zoom
jszoom = false

# https://mermaid.js.org/
mermaid_theme = "default"
mermaid_theme_dark = "dark"
Expand Down
11 changes: 9 additions & 2 deletions themes/hyde-hyde-hyde-zola/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ <h1>{{ page.title }}</h1>

{% block js_body %}
{% if page.extra.mermaid %}
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
<script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/10.9.1/mermaid.min.js" integrity="sha512-6a80OTZVmEJhqYJUmYd5z8yHUCDlYnj6q9XwB/gKOEyNQV/Q8u+XeSG59a2ZKFEHGTYzgfOQKYEBtrZV7vBr+Q==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
var theme = '{{ config.extra.mermaid_theme }}'
if(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches){
theme = '{{ config.extra.mermaid_theme_dark }}'
Expand All @@ -94,5 +94,12 @@ <h1>{{ page.title }}</h1>
mermaid.initialize(config);
</script>
{% endif %}
{% if page.extra.jszoom %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/medium-zoom/1.1.0/medium-zoom.min.js" integrity="sha512-9ZKhgaFdKlsELap/dGw3Iaz5Bj+Las0XXZiRKYZaN9QArg6FtkD5rULNmNH4rTCTFxjPiBGr3MX8smRADRorDA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
const images = Array.from(document.querySelectorAll("img"));
images.forEach((img) => { mediumZoom(img, { margin: 0, background: "", scrollOffset: 40, container: null, template: null }); });
</script>
{% endif %}
{% endblock js_body %}

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<figure>
<div class="mermaid">
<div class="mermaid" style="text-align: {{ config.extra.mermaid_align }}">
{{ body }}
</div>
</figure>

0 comments on commit aac15c7

Please sign in to comment.