Sha256: 0a1bb4ced4913ab971069ecdc6eba393569938874762cb6c4e1cc00e6da486ff

Contents?: true

Size: 1.57 KB

Versions: 8

Compression:

Stored size: 1.57 KB

Contents

<!--
  mermaid-js loader
-->

<script src="{{ site.data.assets[origin].mermaid.js | relative_url }}"></script>

<script>
  $(function() {
    function updateMermaid(event) {
      if (event.source === window && event.data &&
            event.data.direction === ModeToggle.ID) {

        const mode = event.data.message;

        if (typeof mermaid === "undefined") {
          return;
        }

        let expectedTheme = (mode === ModeToggle.DARK_MODE? "dark" : "default");
        let config = { theme: expectedTheme };

        /* Re-render the SVG › <https://github.com/mermaid-js/mermaid/issues/311#issuecomment-332557344> */
        $(".mermaid").each(function() {
          let svgCode = $(this).prev().children().html();
          $(this).removeAttr("data-processed");
          $(this).html(svgCode);
        });

        mermaid.initialize(config);
        mermaid.init(undefined, ".mermaid");
      }
    }

    let initTheme = "default";

    if ($("html[data-mode=dark]").length > 0
      || ($("html[data-mode]").length == 0
        && window.matchMedia("(prefers-color-scheme: dark)").matches ) ) {
      initTheme = "dark";
    }

    let mermaidConf = {
      theme: initTheme  /* <default|dark|forest|neutral> */
    };

    /* Markdown converts to HTML */
    $("pre").has("code.language-mermaid").each(function() {
      let svgCode = $(this).children().html();
      $(this).addClass("unloaded");
      $(this).after(`<div class=\"mermaid\">${svgCode}</div>`);
    });

    mermaid.initialize(mermaidConf);

    window.addEventListener("message", updateMermaid);
  });
</script>

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
jekyll-theme-chirpy-5.3.1 _includes/mermaid.html
jekyll-theme-chirpy-clarkezone-5.3.2 _includes/mermaid.html
jekyll-theme-chirpy-5.3.0 _includes/mermaid.html
jekyll-theme-abd3lraouf-5.2.9 _includes/mermaid.html
jekyll-theme-abd3lraouf-5.2.8 _includes/mermaid.html
jekyll-theme-abd3lraouf-5.2.7 _includes/mermaid.html
jekyll-theme-chirpy-5.2.1 _includes/mermaid.html
jekyll-theme-chirpy-5.2.0 _includes/mermaid.html