Merge branch 'feature/multi-comments'
This commit is contained in:
commit
e466a643d5
6 changed files with 72 additions and 12 deletions
11
_config.yml
11
_config.yml
|
@ -87,9 +87,15 @@ avatar: '/commons/avatar.jpg'
|
|||
# boolean type, the global switch for ToC in posts.
|
||||
toc: true
|
||||
|
||||
comments:
|
||||
active: # The global switch for posts comments, e.g., 'disqus'. Keep it empty means disable
|
||||
# The active options are as follows:
|
||||
disqus:
|
||||
comments: false # boolean type, the global switch for posts comments.
|
||||
shortname: '' # Fill with your Disqus shortname. › https://help.disqus.com/en/articles/1717111-what-s-a-shortname
|
||||
shortname: # fill with the Disqus shortname. › https://help.disqus.com/en/articles/1717111-what-s-a-shortname
|
||||
# utterances settings › https://utteranc.es/
|
||||
utterances:
|
||||
repo: # <gh-username>/<repo>
|
||||
issue_term: # < url | pathname | title | ...>
|
||||
|
||||
paginate: 10
|
||||
|
||||
|
@ -111,7 +117,6 @@ collections:
|
|||
output: true
|
||||
sort_by: order
|
||||
|
||||
|
||||
defaults:
|
||||
-
|
||||
scope:
|
||||
|
|
5
_includes/comments.html
Normal file
5
_includes/comments.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
<!-- The comments switcher -->
|
||||
{% if page.comments and site.comments.active %}
|
||||
{% capture path %}comments/{{ site.comments.active }}.html{% endcapture %}
|
||||
{% include {{ path }} %}
|
||||
{% endif %}
|
|
@ -1,9 +1,6 @@
|
|||
<!--
|
||||
The Disqus lazy loading.
|
||||
-->
|
||||
|
||||
{% if site.disqus.comments and page.comments %}
|
||||
|
||||
<div id="disqus_thread" class="pt-2 pb-2">
|
||||
<p class="text-center text-muted small">
|
||||
Comments powered by <a href="https://disqus.com/">Disqus</a>.
|
||||
|
@ -11,6 +8,7 @@
|
|||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var disqus_config = function () {
|
||||
this.page.url = '{{ page.url | absolute_url }}';
|
||||
this.page.identifier = '{{ page.url }}';
|
||||
|
@ -22,7 +20,7 @@
|
|||
if(entries[0].isIntersecting) {
|
||||
(function () {
|
||||
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());
|
||||
(d.head || d.body).appendChild(s);
|
||||
})();
|
||||
|
@ -54,5 +52,3 @@
|
|||
}
|
||||
|
||||
</script>
|
||||
|
||||
{% endif %}
|
51
_includes/comments/utterances.html
Normal file
51
_includes/comments/utterances.html
Normal file
|
@ -0,0 +1,51 @@
|
|||
<!-- https://utteranc.es/ -->
|
||||
<script src="https://utteranc.es/client.js"
|
||||
repo="{{ site.comments.utterances.repo }}"
|
||||
issue-term="{{ site.comments.utterances.issue_term }}"
|
||||
crossorigin="anonymous"
|
||||
async>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
const origin = "https://utteranc.es";
|
||||
const iframe = "iframe.utterances-frame";
|
||||
const lightTheme = "github-light";
|
||||
const darkTheme = "github-dark";
|
||||
let initTheme = lightTheme;
|
||||
|
||||
if ($("html[mode=dark]").length > 0
|
||||
|| ($("html[mode]").length == 0
|
||||
&& window.matchMedia("(prefers-color-scheme: dark)").matches)) {
|
||||
initTheme = darkTheme;
|
||||
}
|
||||
|
||||
addEventListener("message", (event) => {
|
||||
let theme;
|
||||
|
||||
/* credit to <https://github.com/utterance/utterances/issues/170#issuecomment-594036347> */
|
||||
if (event.origin === origin) {
|
||||
/* page initial */
|
||||
theme = initTheme;
|
||||
|
||||
} else if (event.source === window && event.data &&
|
||||
event.data.direction === ModeToggle.ID) {
|
||||
/* global theme mode changed */
|
||||
const mode = event.data.message;
|
||||
theme = (mode === ModeToggle.DARK_MODE ? darkTheme : lightTheme);
|
||||
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
const message = {
|
||||
type: "set-theme",
|
||||
theme: theme
|
||||
};
|
||||
|
||||
const utterances = document.querySelector(iframe).contentWindow;
|
||||
utterances.postMessage(message, origin);
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
|
@ -5,7 +5,7 @@ pannel_includes:
|
|||
tail_includes:
|
||||
- related-posts
|
||||
- post-nav
|
||||
- disqus
|
||||
- comments
|
||||
---
|
||||
|
||||
{% include lang.html %}
|
||||
|
|
|
@ -233,9 +233,12 @@ nav[data-toggle=toc] {
|
|||
#tail-wrapper {
|
||||
min-height: 2rem;
|
||||
|
||||
> div:last-of-type {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
#disqus_thread {
|
||||
min-height: 7.5rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue