Sha256: fe7876c2db44e768d5361632561480df1e18c60d0b5d3258d17de4dc0642fdfe

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

<!-- https://utteranc.es/ -->
<script>
  (function () {
    const origin = 'https://utteranc.es';
    const themeMapper = Theme.getThemeMapper('github-light', 'github-dark');
    const initTheme = themeMapper[Theme.visualState];

    let script = document.createElement('script');
    script.src = 'https://utteranc.es/client.js';
    script.setAttribute('repo', '{{ site.comments.utterances.repo }}');
    script.setAttribute('issue-term', '{{ site.comments.utterances.issue_term }}');
    script.setAttribute('theme', initTheme);
    script.crossOrigin = 'anonymous';
    script.async = true;

    const $footer = document.querySelector('footer');
    $footer.insertAdjacentElement('beforebegin', script);

    addEventListener('message', (event) => {
      let newTheme;

      {%- comment -%}
        Credit to <https://github.com/utterance/utterances/issues/170#issuecomment-594036347>
      {%- endcomment -%}
      if (event.source === window && event.data && event.data.id === Theme.ID) {
        newTheme = themeMapper[Theme.visualState];

        const message = {
          type: 'set-theme',
          theme: newTheme
        };

        const utterances = document.querySelector('.utterances-frame').contentWindow;
        utterances.postMessage(message, origin);
      }
    });
  })();
</script>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-theme-chirpy-7.2.0 _includes/comments/utterances.html