Skip to content

Commit 170fcb3

Browse files
committed
feat: Add valine comment
1 parent 7667e19 commit 170fcb3

File tree

5 files changed

+68
-7
lines changed

5 files changed

+68
-7
lines changed

_config.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ reward:
341341
# ---------------------------------------------------------------
342342

343343
# Gitment
344-
# See: https://github.com/imsun/gitment
344+
# See: https://github.com/imsun/gitment/
345345
gitment:
346346
enable: false
347347
# Github username.
@@ -356,7 +356,7 @@ gitment:
356356
lazy: true
357357

358358
# Gittalk
359-
# See: https://github.com/gitalk/gitalk
359+
# See: https://github.com/gitalk/gitalk/
360360
gitalk:
361361
enable: false
362362
# Github username.
@@ -377,6 +377,33 @@ gitalk:
377377
# Available values: en, zh-CN, es-ES, fr, ru, zh-TW
378378
language:
379379

380+
# Valine
381+
# See: https://valine.js.org/quickstart.html
382+
valine:
383+
enable: false
384+
# Your leancloud application appid.
385+
appid:
386+
# Your leancloud application appkey.
387+
appkey:
388+
# Mail notifier.
389+
notify: true
390+
# Verification code.
391+
verify: true
392+
# Comment box placeholder.
393+
placeholder: Just go go
394+
# Gravatar style.
395+
avatar: mp
396+
# Custom comment header.
397+
meta: nick,mail,link
398+
# Pagination size.
399+
pageSize: 10
400+
# Article reading statistics.
401+
visitor: false
402+
# Whether to record the commenter IP.
403+
recordIP: false
404+
# language, available values: en, zh-cn.
405+
language:
406+
380407
# Livere
381408
# See: https://www.livere.com/
382409
livere:
@@ -394,8 +421,10 @@ disqus:
394421
# Statistics and Analytics config
395422
# ---------------------------------------------------------------
396423

424+
# Busuanzi statistics
425+
# See: https://busuanzi.ibruce.info/
397426
busuanzi:
398-
enable: true
427+
enable: false
399428
site:
400429
# Only show by icon.
401430
icon_only: false

layout/_components/comments.pug

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ else if theme.livere && theme.livere.enable
1515
else if theme.disqus && theme.disqus.enable
1616
div#comments.comments.main-content-layout
1717
div#disqus_thread
18+
else if theme.valine && theme.valine.enable
19+
div#comments.comments.main-content-layout

layout/_third-party/comments/index.pug

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ if page.comments
77
include ./livere.pug
88
else if theme.disqus && theme.disqus.enable
99
include ./disqus.pug
10+
else if theme.valine && theme.valine.enable
11+
include ./valine.pug
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
script(src='https://cdn1.lncld.net/static/js/3.0.4/av-min.js')
2+
script(src='https://cdn.jsdelivr.net/npm/valine@latest/dist/Valine.min.js')
3+
4+
script.
5+
window.onload = function() {
6+
var GUEST_INFO = ['nick', 'mail', 'link'];
7+
var guest_info = '!{ theme.valine.meta }';
8+
9+
guest_info = guest_info.split(',').filter(function(item) {
10+
return GUEST_INFO.indexOf(item) > -1;
11+
});
12+
13+
new Valine({
14+
el: '#comments',
15+
appId: '!{ theme.valine.appid }',
16+
appKey: '!{ theme.valine.appkey }',
17+
notify: !{ theme.valine.notify },
18+
verify: !{ theme.valine.verify },
19+
placeholder: '!{ theme.valine.placeholder }',
20+
avatar: '!{ theme.valine.avatar }',
21+
meta: guest_info,
22+
pageSize: '!{ theme.valine.pageSize }' || 10,
23+
visitor: !{ theme.valine.visitor },
24+
recordIP: !{ theme.valine.recordIP },
25+
lang: '!{ theme.valine.language }' || 'zh-cn'
26+
});
27+
};

source/css/_components/comments.styl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
.comments
22
display: flex
33
margin: 1.5rem 0 0
4+
flex-direction: column
45

56
a
67
text-decoration: none !important
78

89
// Gitment
910
#gitment-container
1011
width: 100%
11-
12+
1213
#gitment-button
1314
margin: 0 auto
1415
border-radius: 10px
@@ -23,15 +24,15 @@
2324
background-color: $blue-light
2425

2526
a.gitment-editor-avatar
26-
clearAStyle()
27+
clearAStyle()
2728

2829
// Gitalk
2930
#gitalk-container
3031
width: 100%
31-
32+
3233
& > :first-child
3334
margin: 0 auto
34-
35+
3536
// Livere
3637
#lv-container
3738
width: 100%

0 commit comments

Comments
 (0)