summaryrefslogtreecommitdiff
path: root/layouts/partials/disqus.html
diff options
context:
space:
mode:
authorReorx <novoreorx@gmail.com>2022-05-31 22:41:10 +0800
committerReorx <novoreorx@gmail.com>2022-05-31 22:41:10 +0800
commit5c47607d23d31bda44f2f660df372a924daa2381 (patch)
tree314fb7db71f0a7b57d342ace9efdb20035d93e12 /layouts/partials/disqus.html
parent81f885a7b99ac845348ba750a9419f50632fa985 (diff)
support specifying comment system in both config and front matter
in config: site.Params.defaultCommentSystems in front matter: pageCommentSystems
Diffstat (limited to 'layouts/partials/disqus.html')
-rw-r--r--layouts/partials/disqus.html27
1 files changed, 27 insertions, 0 deletions
diff --git a/layouts/partials/disqus.html b/layouts/partials/disqus.html
index dc86fc2..e6b9b33 100644
--- a/layouts/partials/disqus.html
+++ b/layouts/partials/disqus.html
@@ -1,3 +1,30 @@
<div class="disqus-container">
<div id="disqus_thread"></div>
</div>
+
+<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 () {
+ const disqus = window.DISQUS
+ if (disqus) {
+ // 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 = '//' + '{{ .disqus.shortname }}' + '.disqus.com/embed.js';
+ s.defer = true;
+ s.setAttribute('data-timestamp', +new Date());
+ // prevent the <script> from loading mutiple times by InstantClick
+ s.setAttribute('data-no-instant', '')
+ d.head.appendChild(s);
+ }
+ })();
+</script>