[feat] add waline v3

This commit is contained in:
xaoxuu 2024-02-23 15:27:45 +08:00
parent 575fc5fef0
commit 8f61d81eef
4 changed files with 1 additions and 47 deletions

View File

@ -208,7 +208,7 @@ comments:
css: https://gcore.jsdelivr.net/npm/@waline/client@3.1.2/dist/waline.css
meta_css: https://gcore.jsdelivr.net/npm/@waline/client@3.1.2/dist/waline-meta.css
# Waline server address url, you should set this to your own link
serverURL:
serverURL: https://waline.vercel.app
# If false, comment count will only be displayed in post page, not in home page
commentCount: true
# Pageviews count, Note: You should not enable both `waline.pageview` and `leancloud_visitors`.
@ -243,10 +243,6 @@ comments:
# token: # 图床验证
# resp: # 图片地址返回值的字段
waline_v3:
# Waline server address url, you should set this to your own link
serverURL: https://waline.vercel.app
# Artalk
# https://artalk.js.org/
artalk:

View File

@ -1,23 +0,0 @@
<%
function layoutDiv() {
var el = ''
el += '<div id="waline_container" class="waline_thread"'
const cfg = theme.comments['waline_v3']
var attrs = {}
if (page.comment_id) {
attrs['comment_id'] = page.comment_id
}
// 参数在这里进行传递
attrs.serverURL = cfg?.serverURL
for (let key of Object.keys(attrs)) {
if (attrs[key]) {
el += ' ' + key + '="' + attrs[key] + '"'
}
}
el += `>${icon('default:loading')}</div>`
return el
}
%>
<%- layoutDiv() %>

View File

@ -1,17 +0,0 @@
<script defer type="module">
import { init } from 'https://unpkg.com/@waline/client@v3/dist/waline.js';
window.addEventListener('DOMContentLoaded', (event) => {
utils.css('https://unpkg.com/@waline/client@v3/dist/waline.css');
const id = 'waline_container';
const el = document.getElementById(id);
var path = el.getAttribute('comment_id');
if (!path) {
path = decodeURI(window.location.pathname);
}
const waline = init({
el: `#${id}`,
path: path,
serverURL: el.getAttribute('serverURL'),
});
});
</script>

View File

@ -28,7 +28,5 @@ if hexo-config('comments.service') == 'utterances'
@import 'comments/utterances'
if hexo-config('comments.service') == 'waline'
@import 'comments/waline'
if hexo-config('comments.service') == 'waline_v3'
@import 'comments/waline'
if hexo-config('comments.service') == 'artalk'
@import 'comments/artalk'