Sha256: 6ef5ca2b1f13442214ebb554d5c04a14da054a580ed7c1fcc03c16dd63adb48d

Contents?: true

Size: 1.8 KB

Versions: 54

Compression:

Stored size: 1.8 KB

Contents

<!-- mermaid-js loader -->
<script type="text/javascript">
  (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';
    const html = document.documentElement;

    if (
      (html.hasAttribute('data-mode') && html.getAttribute('data-mode') === 'dark') ||
      (!html.hasAttribute('data-mode') && window.matchMedia('(prefers-color-scheme: dark)').matches)
    ) {
      initTheme = 'dark';
    }

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

    /* Create mermaid tag */
    document.querySelectorAll('pre>code.language-mermaid').forEach((elem) => {
      const svgCode = elem.textContent;
      const backup = elem.parentElement;
      backup.classList.add('unloaded');
      /* create mermaid node */
      let mermaid = document.createElement('pre');
      mermaid.classList.add('mermaid');
      const text = document.createTextNode(svgCode);
      mermaid.appendChild(text);
      backup.after(mermaid);
    });

    mermaid.initialize(mermaidConf);

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

Version data entries

54 entries across 54 versions & 5 rubygems

Version Path
jekyll-theme-chirpy-6.5.5 _includes/mermaid.html
jekyll-theme-chirpy-customized-upe-4.0.0 _includes/mermaid.html
jekyll-theme-chirpy-customized-upe-4.0.0.pre.beta2 _includes/mermaid.html
doc-theme-0.1.0 _includes/mermaid.html
jekyll-theme-chirpy-6.5.3 _includes/mermaid.html
jekyll-theme-chirpy-6.5.2 _includes/mermaid.html
jekyll-theme-chirpy-customized-upe-3.2.0 _includes/mermaid.html
jekyll-theme-chirpy-customized-upe-3.2.0.pre.beta3 _includes/mermaid.html
jekyll-theme-chirpy-customized-upe-3.2.0.pre.beta2 _includes/mermaid.html
jekyll-theme-chirpy-customized-upe-3.2.0.pre.beta1 _includes/mermaid.html
jekyll-theme-chirpy-customized-upe-3.1.4 _includes/mermaid.html
jekyll-theme-chirpy-customized-upe-3.1.2 _includes/mermaid.html
jekyll-theme-chirpy-customized-upe-3.1.1 _includes/mermaid.html
jekyll-theme-chirpy-customized-upe-3.1.0 _includes/mermaid.html
jekyll-theme-chirpy-customized-upe-3.0.1 _includes/mermaid.html
jekyll-theme-chirpy-customized-upe-3.0.0 _includes/mermaid.html
jekyll-theme-chirpy-customized-upe-1.0.2 _includes/mermaid.html
jekyll-theme-chirpy-customized-upe-1.0.1 _includes/mermaid.html
jekyll-theme-chirpy-customized-upe-1.0.0 _includes/mermaid.html
jekyll-theme-chirpy-customized-upe-0.1.2 _includes/mermaid.html