Prepare for multiple comment systems

This commit is contained in:
Cotes Chung 2021-12-10 21:12:52 +08:00
parent ebb3dc940c
commit 75176522e3
4 changed files with 12 additions and 10 deletions

View File

@ -87,9 +87,11 @@ avatar: '/commons/avatar.jpg'
# boolean type, the global switch for ToC in posts. # boolean type, the global switch for ToC in posts.
toc: true toc: true
disqus: comments:
comments: false # boolean type, the global switch for posts comments. active: # The global switch for posts comments, e.g., 'disqus'. Keep it empty means disable
shortname: '' # Fill with your Disqus shortname. https://help.disqus.com/en/articles/1717111-what-s-a-shortname # The comment active options are as follows
disqus:
shortname: # fill with the Disqus shortname. https://help.disqus.com/en/articles/1717111-what-s-a-shortname
paginate: 10 paginate: 10

4
_includes/comments.html Normal file
View File

@ -0,0 +1,4 @@
<!-- The comments switcher -->
{% if page.comments and site.comments.active %}
{% include {{ site.comments.active | append: '.html' }} %}
{% endif %}

View File

@ -1,9 +1,6 @@
<!-- <!--
The Disqus lazy loading. The Disqus lazy loading.
--> -->
{% if site.disqus.comments and page.comments %}
<div id="disqus_thread" class="pt-2 pb-2"> <div id="disqus_thread" class="pt-2 pb-2">
<p class="text-center text-muted small"> <p class="text-center text-muted small">
Comments powered by <a href="https://disqus.com/">Disqus</a>. Comments powered by <a href="https://disqus.com/">Disqus</a>.
@ -11,6 +8,7 @@
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
var disqus_config = function () { var disqus_config = function () {
this.page.url = '{{ page.url | absolute_url }}'; this.page.url = '{{ page.url | absolute_url }}';
this.page.identifier = '{{ page.url }}'; this.page.identifier = '{{ page.url }}';
@ -22,7 +20,7 @@
if(entries[0].isIntersecting) { if(entries[0].isIntersecting) {
(function () { (function () {
var d = document, s = d.createElement('script'); var d = document, s = d.createElement('script');
s.src = 'https://{{ site.disqus.shortname }}.disqus.com/embed.js'; s.src = 'https://{{ site.comments.disqus.shortname }}.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date()); s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s); (d.head || d.body).appendChild(s);
})(); })();
@ -54,5 +52,3 @@
} }
</script> </script>
{% endif %}

View File

@ -5,7 +5,7 @@ pannel_includes:
tail_includes: tail_includes:
- related-posts - related-posts
- post-nav - post-nav
- disqus - comments
--- ---
{% include lang.html %} {% include lang.html %}