update comments

This commit is contained in:
xaoxuu 2021-07-23 23:44:25 +08:00
parent 37e0e9cc51
commit 4628aa4c50
5 changed files with 55 additions and 42 deletions

View File

@ -76,9 +76,12 @@ comments:
issue-term: pathname issue-term: pathname
issue-number: issue-number:
theme: preferred-color-scheme theme: preferred-color-scheme
label:
input-position: top # top/bottom 评论框位置 input-position: top # top/bottom 评论框位置
comment-order: desc # desc 排序 comment-order: desc # desc 排序
keep-theme: # true/false keep-theme: # true/false
loading: false
branch: main
# utterances # utterances
# https://utteranc.es/ # https://utteranc.es/
utterances: utterances:
@ -86,6 +89,7 @@ comments:
issue-term: pathname issue-term: pathname
issue-number: issue-number:
theme: preferred-color-scheme theme: preferred-color-scheme
label:
valine: valine:
js: https://cdn.jsdelivr.net/gh/XuxuGood/simple-blog-cdn@main/js/Valine.min.js js: https://cdn.jsdelivr.net/gh/XuxuGood/simple-blog-cdn@main/js/Valine.min.js
appId: # your appId appId: # your appId

View File

@ -1,25 +1,26 @@
<script> <script>
function beaudar(){ function loadBeaudar() {
if(!document.getElementById("beaudar"))return; const els = document.querySelectorAll("#comments #beaudar");
setTimeout(function() { if (els.length === 0) return;
var checkbeaudar = setInterval(function () { els.forEach((el, i) => {
var el = document.getElementById("beaudar");
if (!el) return
clearInterval(checkbeaudar)
try { try {
el.innerHTML=""; el.innerHTML = '';
} catch (error) {} } catch (error) {
console.log(error);
}
var script = document.createElement('script'); var script = document.createElement('script');
script.src = 'https://beaudar.lipk.org/client.js'; script.src = 'https://beaudar.lipk.org/client.js';
const keys = ['repo', 'issue-term', 'issue-number', 'theme', 'label', 'crossorigin', 'input-position', 'comment-order', 'keep-theme']; script.async = true;
keys.forEach((key, i) => { for (let key of Object.keys(el.attributes)) {
if (el.attributes[key] && el.attributes[key].value) { let attr = el.attributes[key];
script.setAttribute(key, el.attributes[key].value); if (['class', 'id'].includes(attr.name) === false) {
script.setAttribute(attr.name, attr.value);
}
} }
});
el.appendChild(script); el.appendChild(script);
}, 200)
}); });
} }
beaudar(); window.addEventListener('DOMContentLoaded', (event) => {
loadBeaudar();
});
</script> </script>

View File

@ -1,25 +1,26 @@
<script> <script>
function utterances(){ function loadUtterances() {
if(!document.getElementById("utterances"))return; const els = document.querySelectorAll("#comments #utterances");
setTimeout(function() { if (els.length === 0) return;
var checkUtterances = setInterval(function () { els.forEach((el, i) => {
var el = document.getElementById("utterances");
if (!el) return
clearInterval(checkUtterances)
try { try {
el.innerHTML=""; el.innerHTML = '';
} catch (error) {} } catch (error) {
console.log(error);
}
var script = document.createElement('script'); var script = document.createElement('script');
script.src = 'https://utteranc.es/client.js'; script.src = 'https://utteranc.es/client.js';
const keys = ['repo', 'issue-term', 'issue-number', 'theme', 'label', 'crossorigin']; script.async = true;
keys.forEach((key, i) => { for (let key of Object.keys(el.attributes)) {
if (el.attributes[key] && el.attributes[key].value) { let attr = el.attributes[key];
script.setAttribute(key, el.attributes[key].value); if (['class', 'id'].includes(attr.name) === false) {
script.setAttribute(attr.name, attr.value);
}
} }
});
el.appendChild(script); el.appendChild(script);
}, 200)
}); });
} }
utterances(); window.addEventListener('DOMContentLoaded', (event) => {
loadUtterances();
});
</script> </script>

View File

@ -0,0 +1,3 @@
.cmt-body.beaudar
margin: 0 -4px
width: 'calc(100% + %s)' % 8px

View File

@ -7,6 +7,10 @@ if hexo-config('plugins.scrollreveal.enable')
@import 'scrollreveal' @import 'scrollreveal'
// //
if hexo-config('comments.service') == 'beaudar'
@import 'comments/beaudar'
if hexo-config('comments.service') == 'twikoo'
@import 'comments/twikoo'
if hexo-config('comments.service') == 'utterances' if hexo-config('comments.service') == 'utterances'
@import 'comments/utterances' @import 'comments/utterances'
if hexo-config('comments.service') == 'valine' if hexo-config('comments.service') == 'valine'