Skip to content

Commit fe3ddaf

Browse files
committed
feat: 支持 utterances 为评论系统
1 parent 6c2d00f commit fe3ddaf

File tree

9 files changed

+64
-30
lines changed

9 files changed

+64
-30
lines changed

README.en.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
## Table of Contents
88

9-
- [How to use](#How to use)
10-
- [Install](#Install)
11-
- [Configuration Item](#Configuration Item)
12-
- [Effect Preview](#Effect Preview)
13-
- [update](#update)
14-
- [Portable Version](#Portable Version)
9+
- [How to use](#how-to-use)
10+
- [Installation](#installation)
11+
- [Configuration items](#configuration-items)
12+
- [Effect preview](#effect-preview)
13+
- [Update](#update)
14+
- [Porting version](#porting-version)
1515
- [Todo](#todo)
16-
- [Participation](#Participation)
16+
- [Participate](#participate)
1717
- [LICENCE](#licence)
1818

1919
Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc)
@@ -140,15 +140,23 @@ social:
140140
- Comment module configuration
141141

142142
```bash
143-
# Commend module
143+
# comment module
144144
comment:
145145
enable: false # true to enable
146+
type: valine # value: valine | utterances
147+
148+
# valine params
146149
appId: your-app-id
147150
appKey: your-app-key
148151
placeholder: say something
149152
notify: false
150153
verify: false
151154
avatar: mp
155+
156+
# utterances (https://utteranc.es/) params
157+
repo: your github repo path which supports comment
158+
issue_term: your issue term
159+
theme: comment theme
152160
```
153161

154162
- Open math formula

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
## 目录
1212

1313
- [如何使用](#如何使用)
14-
- [安装](#安装)
15-
- [配置项](#配置项)
14+
- [安装](#安装)
15+
- [配置项](#配置项)
1616
- [效果预览](#效果预览)
1717
- [update](#update)
1818
- [移植版](#移植版)
@@ -144,15 +144,23 @@ social:
144144
- 评论模块配置
145145

146146
```bash
147-
# commend module
147+
# comment module
148148
comment:
149-
enable: false # true to enable
149+
enable: false
150+
type: valine # valine | utterances
151+
152+
# valine 需要的参数
150153
appId: your-app-id
151154
appKey: your-app-key
152155
placeholder: say something
153156
notify: false
154157
verify: false
155158
avatar: mp
159+
160+
# utterances (https://utteranc.es/) 需要的参数
161+
repo: your-repo-name
162+
issue_term: your-issue-term
163+
theme: your-comment-theme
156164
```
157165

158166
- 开启数学公式

_config.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,20 @@ main_color: default # forest | grass | sky | sun | sea
4343
# google Analytics
4444
google_analytics_id: xx-xxxxxxx-xx
4545

46-
# commend module
46+
# comment module
4747
comment:
4848
enable: false
49+
type: valine # valine | utterances
50+
51+
# valine 需要的参数
4952
appId: your-app-id
5053
appKey: your-app-key
5154
placeholder: say something
5255
notify: false
5356
verify: false
5457
avatar: mp
58+
59+
# utterances (https://utteranc.es/) 需要的参数
60+
repo: your-repo-name
61+
issue_term: your-issue-term
62+
theme: your-comment-theme

layout/includes/comments.pug

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
case theme.comment.type
2+
when 'valine'
3+
include ./scripts/valine-comment
4+
when 'utterances'
5+
include ./scripts/utterances-comment

layout/includes/layout.pug

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
- if (is_category()) pageTitle = 'Category: ' + page.category
77
- if (is_month()) pageTitle += ': ' + page.month + '/' + page.year
88
- if (is_year()) pageTitle += ': ' + page.year
9-
- pageTitle += ' [ ' + config.title + ' ] '
9+
- if (pageTitle == '') return config.title
10+
- pageTitle += ' - ' + config.title
1011
- return pageTitle
1112
- }
1213

@@ -57,7 +58,6 @@ html(lang=config.language)
5758
script(src=url defer)
5859

5960
include ./scripts/google-analytics-script
60-
include ./scripts/comments-script
6161
include ./scripts/toc-script
6262
include ./scripts/math-script
6363

layout/includes/scripts/comments-script.pug

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
script(src="https://utteranc.es/client.js"
2+
repo=`${theme.comment.repo}`
3+
issue-term=`${theme.comment.issue_term}`
4+
theme=`${theme.comment.theme}`
5+
crossorigin="anonymous" async)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#comments
2+
script(src="https://www.unpkg.com/valine/dist/Valine.min.js" defer)
3+
script.
4+
window.addEventListener('DOMContentLoaded', () => {
5+
new Valine({
6+
el: '#comments',
7+
appId: '#{theme.comment.appId}',
8+
appKey: '#{theme.comment.appKey}',
9+
notify: #{theme.comment.notify},
10+
verify: #{theme.comment.notify},
11+
avatar: '#{theme.comment.avatar}',
12+
placeholder: '#{theme.comment.placeholder}',
13+
})
14+
})

layout/post.pug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ block content
1919
.main__bottom
2020
include includes/pre-next.pug
2121
if page.content && theme.comment && theme.comment.enable
22-
#comments
22+
include includes/comments
2323

2424

0 commit comments

Comments
 (0)