utterances和isso两种评论系统搭建
isso
- 自建
- 数据存储在本地, 方便备份迁移
- 无需登陆
- 可配置审核等
搭建isso
1services:
2 isso:
3 container_name: isso
4 image: ghcr.io/isso-comments/isso:release
5 ports:
6 - "8080:8080"
7 restart: always
8 volumes:
9 - "/app/isso/data/config:/config"
10 - "/app/isso/data/db:/db"
配置: /app/isso/data/config/isso.cfg
1# Isso example configuration file
2# vim: set filetype=dosini
3
4[general]
5
6# Change dbpath to /db/comments.db if running in docker!
7dbpath = /db/comments.db
8host =
9 https://isso.akvicor.com
10 https://blog.akvicor.com
11max-age = 5
12notify = smtp
13gravatar = true
14gravatar-url = https://www.gravatar.com/avatar/{}?d=identicon&s=55
15
16[admin]
17enabled = true
18password = abced
19
20[guard]
21# 开启 SPAM 保护。防止一些恶意攻击。比如限制每个钟的新评论个数。
22enabled = true
23# 每分钟内最多五个新评论
24ratelimit = 5
25direct-reply = 7
26; 是否允许回复自己
27reply-to-self = true
28; 是否必须填写作者
29require-author = false
30; 是否必须填写邮箱
31require-email = false
32
33; 是否开启审核,true 是开启,30d 表示删除 30 天没有通过审核的评论
34[moderation]
35enabled = false
36approve-if-email-previously-approved = false
37purge-after = 30d
38
39[smtp]
40host = smtp.xxxx.com
41port = 465
42security = ssl
43username = xxx@xxxx.com
44password = xxxxxxx
45to = akvicor@xxxx.com
46from = "Akvicor's Blog" <xxx@xxxx.com>
47timeout = 10
48
49[rss]
50base = https://isso.akvicor.com
51limit = 100
配置博客
找到主题的layouts/_default/single.html
文件
在{{ define "main" }}
后面添加以下内容
1{{ $IsNav := eq .Title "Nav"}}
2{{ $IsSearch := eq .Title "Search"}}
3{{ $IsArchive := eq .Title "Archive"}}
4{{ $IsAbout := eq .Title "About"}}
5{{ $IsSecrets := eq .Section "secrets"}}
6<!-- 那些不需要文章相关功能(如目录层级,文章切换、字数时长统计等)的页面 -->
7<!-- {{ $IsPurePage := or $IsNav $IsSearch $IsArchive $IsAbout }} -->
8<!-- 正常博文 -->
9{{ $IsPostPage := and (not $IsNav) (not $IsSearch) (not $IsArchive) (not $IsAbout) }}
10{{ $IsCommentPage := and (not $IsNav) (not $IsSearch) (not $IsArchive) }}
11{{ $IS_DEV_ENV := eq .Site.BaseURL "http://localhost:1313/"}}
在<article>
内部的末尾添加
1{{ if and .IsPage $IsPostPage (not $IsSecrets) .Site.Params.isso.active (not $IS_DEV_ENV) }}
2 {{- partial "partials/_isso.html" . -}}
3{{ end }}
在layouts/partials
下添加_isso.html
文件
1<div class="container-comment">
2 <script data-isso="https://isso.akvicor.com"
3 data-isso-css="true"
4 data-isso-lang="en"
5 data-isso-reply-notifications="true"
6 data-isso-reply-to-self="true"
7 data-isso-require-author="false"
8 data-isso-require-email="false"
9 data-isso-max-comments-top="10"
10 data-isso-max-comments-nested="5"
11 data-isso-reveal-on-click="5"
12 data-isso-avatar="true"
13 data-isso-gravatar="true"
14 data-isso-vote="true"
15 data-vote-levels=""
16 src="https://isso.akvicor.com/js/embed.min.js"></script>
17 <section id="isso-thread"></section>
18</div>
在配置文件中添加
1[params.isso]
2 # 是否启用评论插件
3 active = true
utterances
- 借助Github保存评论
- 必须登陆Github
找到主题的layouts/_default/single.html
文件
在{{ define "main" }}
后面添加以下内容
1{{ $IsNav := eq .Title "Nav"}}
2{{ $IsSearch := eq .Title "Search"}}
3{{ $IsArchive := eq .Title "Archive"}}
4{{ $IsAbout := eq .Title "About"}}
5{{ $IsSecrets := eq .Section "secrets"}}
6<!-- 那些不需要文章相关功能(如目录层级,文章切换、字数时长统计等)的页面 -->
7<!-- {{ $IsPurePage := or $IsNav $IsSearch $IsArchive $IsAbout }} -->
8<!-- 正常博文 -->
9{{ $IsPostPage := and (not $IsNav) (not $IsSearch) (not $IsArchive) (not $IsAbout) }}
10{{ $IsCommentPage := and (not $IsNav) (not $IsSearch) (not $IsArchive) }}
11{{ $IS_DEV_ENV := eq .Site.BaseURL "http://localhost:1313/"}}
在<article>
内部的末尾添加
1{{ if and .IsPage $IsCommentPage (not $IsSecrets) .Site.Params.utterances.active (not $IS_DEV_ENV) }}
2 {{- partial "partials/_comment.html" . -}}
3{{ end }}
在layouts/partials
下添加_comment.html
文件
1<div class="container-comment">
2 <script src="https://utteranc.es/client.js"
3 repo="{{.Site.Params.utterances.repo}}"
4 issue-term="{{.Site.Params.utterances.issueTerm}}"
5 theme="{{.Site.Params.utterances.theme}}"
6 crossorigin="{{.Site.Params.utterances.crossorigin}}"
7 async>
8 </script>
9</div>
在配置文件中添加
1[params]
2 # 在开发环境下(http://localhost:1313/),不再启用评论插件,
3 # 如果想在开发环境下启用它,修改服务端口即可,如下
4 # hugo server -p=1314
5 [params.utterances]
6 # 是否启用评论插件
7 active = true
8 # 输入你的仓库名称
9 repo = "AkvicorEdwards/blog"
10 issueTerm = "pathname"
11 theme = "github-light"
12 crossorigin = "anonymous"
除另有声明外,本博客文章均采用 知识共享 (Creative Commons) 署名 4.0 国际许可协议 进行许可。转载请注明原作者与文章出处。