New isso comments system

This commit is contained in:
Mimi 2020-11-28 15:49:40 +08:00
parent 7e49895470
commit 7a4890f165
3 changed files with 42 additions and 7 deletions

View File

@ -520,11 +520,11 @@ fancybox: false
# A JavaScript library for zooming images like Medium.
# Warning: Do not enable both `fancybox` and `mediumzoom`.
# For more information: https://github.com/francoischalifour/medium-zoom
# For more information: https://medium-zoom.francoischalifour.com
mediumzoom: false
# Vanilla JavaScript plugin for lazyloading images.
# For more information: https://github.com/ApoorvSaxena/lozad.js
# For more information: https://apoorv.pro/lozad.js/demo/
lazyload: false
# Pangu Support
@ -533,7 +533,7 @@ lazyload: false
pangu: false
# Quicklink Support
# For more information: https://github.com/GoogleChromeLabs/quicklink
# For more information: https://getquick.link
# Front-matter variable (unsupport home archive).
quicklink:
enable: false
@ -580,15 +580,14 @@ comments:
# order: -2
# Disqus
# For more information: https://disqus.com
disqus:
enable: false
shortname:
count: true
# DisqusJS
# Alternative Disqus - Render comment component using Disqus API.
# Demo: https://disqusjs.skk.moe
# For more information: https://github.com/SukkaW/DisqusJS
# For more information: https://disqusjs.skk.moe
disqusjs:
enable: false
# API Endpoint of Disqus API (https://disqus.com/api/docs/).
@ -600,6 +599,7 @@ disqusjs:
shortname: # See: https://disqus.com/admin/settings/general/
# Changyan
# For more information: https://changyan.kuaizhan.com
changyan:
enable: false
appid:
@ -610,7 +610,7 @@ changyan:
livere_uid: # <your_uid>
# Gitalk
# For more information: https://gitalk.github.io, https://github.com/gitalk/gitalk
# For more information: https://gitalk.github.io
gitalk:
enable: false
github_id: # GitHub repo owner
@ -634,6 +634,11 @@ utterances:
# Available values: github-light | github-dark | preferred-color-scheme | github-dark-orange | icy-dark | dark-blue | photon-dark | boxy-light
theme: github-light
# Isso
# For more information: https://posativ.org/isso/
isso: # <data_isso>
# ---------------------------------------------------------------
# Post Widgets & Content Sharing Services
# See: https://theme-next.js.org/docs/third-party-services/post-widgets

10
layout/_third-party/comments/isso.njk vendored Normal file
View File

@ -0,0 +1,10 @@
{%- if page.comments %}
<script>
NexT.utils.loadComments('#isso-thread', () => {
const script = document.createElement('script');
script.src = '{{ theme.isso }}js/embed.min.js';
script.dataset.isso = '{{ theme.isso }}';
document.querySelector('#isso-thread').appendChild(script);
});
</script>
{%- endif %}

View File

@ -0,0 +1,20 @@
/* global hexo */
'use strict';
const path = require('path');
// Add comment
hexo.extend.filter.register('theme_inject', injects => {
const theme = hexo.theme.config;
if (!theme.isso) return;
injects.comment.raw('isso', `
<div class="comments">
<div id="isso-thread"></div>
</div>
`, {}, { cache: true });
injects.bodyEnd.file('isso', path.join(hexo.theme_dir, 'layout/_third-party/comments/isso.njk'));
});