diff options
| author | Reorx <novoreorx@gmail.com> | 2022-05-27 21:33:40 +0800 |
|---|---|---|
| committer | Reorx <novoreorx@gmail.com> | 2022-05-27 21:33:40 +0800 |
| commit | 28511efd081dba9dac8cbf8fa2c8135216264243 (patch) | |
| tree | 6fe8e74f91dbc1ae25d848d552cc0e3357d3b53d /layouts/partials/disqus_script.html | |
| parent | 9f8b0c319412a75f703d98e9a36cc91e8d7ccdda (diff) | |
control comment system in partials/comments.html
Diffstat (limited to 'layouts/partials/disqus_script.html')
| -rw-r--r-- | layouts/partials/disqus_script.html | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/layouts/partials/disqus_script.html b/layouts/partials/disqus_script.html new file mode 100644 index 0000000..4840d14 --- /dev/null +++ b/layouts/partials/disqus_script.html @@ -0,0 +1,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> |
