[feat] add artalk
This commit is contained in:
parent
2eac759435
commit
851c23cedc
42
_config.yml
42
_config.yml
|
@ -84,7 +84,7 @@ search:
|
|||
|
||||
######## Comments ########
|
||||
comments:
|
||||
service: # beaudar, utterances, twikoo, waline
|
||||
service: # beaudar, utterances, giscus, twikoo, waline, artalk
|
||||
# beaudar
|
||||
# https://beaudar.lipk.org/
|
||||
beaudar:
|
||||
|
@ -128,22 +128,18 @@ comments:
|
|||
twikoo:
|
||||
js: https://fastly.jsdelivr.net/npm/twikoo@1.4.0/dist/twikoo.all.min.js # 建议锁定版本
|
||||
envId: https://xxx # vercel函数
|
||||
|
||||
# Waline
|
||||
# https://waline.js.org/
|
||||
waline:
|
||||
js: https://unpkg.com/@waline/client@v2/dist/waline.js
|
||||
css: https://unpkg.com/@waline/client@v2/dist/waline.css
|
||||
# Waline server address url, you should set this to your own link
|
||||
serverURL:
|
||||
|
||||
# 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`.
|
||||
pageview: false
|
||||
|
||||
# Custom locales
|
||||
# locale:
|
||||
# placeholder: Welcome to comment # Comment box placeholder
|
||||
|
||||
# Custom emoji
|
||||
# emoji:
|
||||
# - https://unpkg.com/@waline/emojis@1.1.0/weibo
|
||||
|
@ -153,28 +149,16 @@ comments:
|
|||
# - https://unpkg.com/@waline/emojis@1.1.0/tieba
|
||||
# - https://unpkg.com/@waline/emojis@1.1.0/tw-emoji
|
||||
# - https://unpkg.com/@waline/emojis@1.1.0/bmoji
|
||||
|
||||
# Artalk
|
||||
# https://artalk.js.org/
|
||||
artalk:
|
||||
css: https://unpkg.com/artalk@2.4.3/dist/Artalk.css
|
||||
js: https://unpkg.com/artalk@2.4.3/dist/Artalk.js
|
||||
server: # 后端服务地址
|
||||
placeholder: ''
|
||||
darkMode: auto
|
||||
|
||||
# Comment infomation, valid meta are nick, mail and link
|
||||
# meta:
|
||||
# - nick
|
||||
# - mail
|
||||
# - link
|
||||
|
||||
# Set required meta field, e.g.: [nick] | [nick, mail]
|
||||
# requiredMeta:
|
||||
# - nick
|
||||
|
||||
# Language, available values: en-US, zh-CN, zh-TW, pt-BR, ru-RU, jp-JP
|
||||
# lang: zh-CN
|
||||
|
||||
# Word limit, no limit when setting to 0
|
||||
# wordLimit: 0
|
||||
|
||||
# Whether enable login, can choose from 'enable', 'disable' and 'force'
|
||||
# login: enable
|
||||
|
||||
# comment per page
|
||||
# pageSize: 10
|
||||
|
||||
######## Footer ########
|
||||
footer:
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<%
|
||||
function layoutDiv() {
|
||||
var el = '';
|
||||
el += '<div id="artalk_container"';
|
||||
let cfg = {};
|
||||
if (page.comment_id) {
|
||||
cfg['comment_id'] = page.comment_id;
|
||||
}
|
||||
for (let key of Object.keys(cfg)) {
|
||||
if (cfg[key]) {
|
||||
el += ' ' + key + '="' + cfg[key] + '"';
|
||||
}
|
||||
}
|
||||
el += '><svg class="loading" style="vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2709"><path d="M832 512c0-176-144-320-320-320V128c211.2 0 384 172.8 384 384h-64zM192 512c0 176 144 320 320 320v64C300.8 896 128 723.2 128 512h64z" p-id="2710"></path></svg></div>';
|
||||
return el;
|
||||
}
|
||||
%>
|
||||
|
||||
<%- layoutDiv() %>
|
|
@ -0,0 +1,25 @@
|
|||
<script>
|
||||
function load_artalk() {
|
||||
if (!document.querySelectorAll("#artalk_container")[0]) return;
|
||||
stellar.loadCSS('<%- theme.comments.artalk.css %>');
|
||||
stellar.loadScript('<%- theme.comments.artalk.js %>', {defer: true}).then(function () {
|
||||
const el = document.getElementById("artalk_container");
|
||||
var path = el.getAttribute('comment_id');
|
||||
if (!path) {
|
||||
path = decodeURI(window.location.pathname);
|
||||
}
|
||||
var artalk = new Artalk({
|
||||
el: '#artalk_container',
|
||||
pageKey: path,
|
||||
pageTitle: '<%= page.title || page.seo_title %>',
|
||||
server: '<%= theme.comments.artalk.server %>',
|
||||
placeholder: '<%= theme.comments.artalk.placeholder %>',
|
||||
site: '<%= config.title %>',
|
||||
darkMode: '<%= theme.comments.artalk.darkMode %>'
|
||||
})
|
||||
});
|
||||
}
|
||||
window.addEventListener('DOMContentLoaded', (event) => {
|
||||
load_artalk();
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,4 @@
|
|||
.cmt-body.artalk .artalk
|
||||
--at-color-main: $color-theme
|
||||
.atk-main-editor
|
||||
border-radius: $border-block
|
|
@ -18,3 +18,5 @@ if hexo-config('comments.service') == 'utterances'
|
|||
@import 'comments/utterances'
|
||||
if hexo-config('comments.service') == 'waline'
|
||||
@import 'comments/waline'
|
||||
if hexo-config('comments.service') == 'artalk'
|
||||
@import 'comments/artalk'
|
||||
|
|
Loading…
Reference in New Issue