Enable Mermaid for Markdown Code Blocks

    Alice->>John: Hello John, how are you?
    John-->>Alice: Great!
    Alice-)John: See you later!

Mermaid is a Markdown-inspired tool that renders text into diagrams, which Github natively supports. But unfortunately, Github Pages does not support use of Mermaid by default. So the user has to manually integrate Mermaid into their Github Pages in order to use it.

Luckily, it isn’t that hard to do so with HydeJack theme.


You can check the commit directly if you’d like.


Simply puts below option to anywhere.
(Somewhere around # 3rd Party Integrations would be sufficient)

# file: "_config.yml"
mermaid: true


Use Hydejack event listener so the code can be executed every time the page gets loaded.

<!-- file: "_includes/my-scripts.html" -->
<script type="module">
  {% if site.mermaid %}
  import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs";
  let config = {
    startOnLoad: true,
    fontFamily: "JetBrains Mono",
    theme: "dark"
  mermaid.run({ querySelector: ".language-mermaid" });
  {% endif %}
    .addEventListener("hy-push-state-load", function () {
      {% if site.mermaid %} mermaid.run({ querySelector: ".language-mermaid" }); {% endif %}

I have manually changed theme to dark as default theme does not fit well with current dark mode of the Hydejack.
Also the fontFamily is changed to my favorite coding font of all time, JetBrains Mono.

Check Mermaid Config Schema for more information.