summaryrefslogtreecommitdiff
path: root/layouts/partials/disqus_script.html
blob: 4840d142dee20ff89017c1352239d2f464a01a0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<script type="text/javascript">
  var disqus_config = function () {
    this.page.url = '{{ .Page.Permalink }}';  // Replace PAGE_URL with your page's canonical URL variable
    this.page.identifier = '{{ .Page.Permalink | path.Base }}'; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
  };

  (function () {
    let disqusEmbedLoaded = window.disqusEmbedLoaded;
    if (disqusEmbedLoaded) {
      // Use DISQUS.reset instead of reloading embed.js please.
      // https://help.disqus.com/en/articles/1717163-using-disqus-on-ajax-sites
      DISQUS.reset({
        reload: true,
        config: disqus_config,
      });
    } else {
      var d = document, s = d.createElement('script');
      s.src = '//' + '{{ site.Params.commentSystem.disqus.shortname }}' + '.disqus.com/embed.js';
      s.setAttribute('data-timestamp', +new Date());
      // prevent the <script> from loading mutiple times by InstantClick
      s.setAttribute('data-no-instant', '')
      d.head.appendChild(s);

      window.disqusEmbedLoaded = true;
    }
  })();
</script>