基于Github_Isscue的评论插件Gitalk安装

基于Github_Isscue的评论插件Gitalk安装

闲着将Next主题升到目前最新的7.7.1,并更换了一些插件,如评论插件,不蒜子统计.

安装Gitalk

Next主题已经内置集成了Gitalk,只需要在Github上创建一个 GitHub Application,然后在主题配置文件中启用并修改配置文件即可.

1.创建 GitHub Application需要 GitHub Application,如果没有 点击这里申请Authorization callback URL 填写博客域名域名.其他随便填写均可.

GitHub Application

之后会得到Client IDClient Secret

Client ID

修改主题配置文件,如D:\wwwroot\nobige\themes\next\_config.yml

1
2
3
4
5
6
7
8
9
10
11
12
gitalk:
enable: true
github_id: jackch3n # GitHub 账号id,如我的github主页为https://github.com/JackCh3n id便是:JackCh3n
repo: aiguo_jingye # issues所属的那个仓
client_id: 7uYxGE9VCeQObg0Z1pfF2yiq8RHUwdl6 # GitHub Application Client ID
client_secret: Ta0YwizufyUEHb7mpIjCQ2SV5JvXKo6eOdG1ZqW8rMlBchtLR94DgPAks3NFxn5a # GitHub Application Client Secret
admin_user: jackch3n # 管理员账号,通账号ID即可
distraction_free_mode: true # Facebook-like distraction free mode
# Gitalk's display language depends on user's browser or system environment
# If you want everyone visiting your site to see a uniform language, you can set a force language value
# Available values: en | es-ES | fr | ru | zh-CN | zh-TW
language: en #语言

修改成类似上面的配置就已经可以正常的使用了,如需使用更高级的方法可以参考开发者文档,其js文件在D:\wwwroot\nobige\themes\next\layout\_third-party\comments\gitalk.swig

已知的几个问题,其一每篇文章需要在发布后由管理员手动开启.如下图

管理员开启评论

其二,可能会出现网络问题,暂时没有很好地解决方法.理论上可以用cdn或是反代理的方式来解决问题.

网络错误

不蒜子统计

​ 不蒜子统计更为简单,只需将其false改成true即可.

插件

1
2
3
4
5
6
# 图片处理插件
npm install git+https://github.com/JackCh3n/hexo-asset-image.git
# 本地搜索
npm install hexo-generator-searchdb --save
# 地图生成
npm install hexo-generator-sitemap --save

错误

​ 在升级的过程中出现雷士下面的错误,找了半天都没有很好地解决,一开始猜测是主题修改的问题在新建的干净环境中还是存在一样的问题就,认为是文章的,虽说文章不多但还是花了点时间来找到对应的2篇,其原因在于

​ 可能有大括号之类或是格式不正确,如图片是[]()漏了某一个符号就报错了,hexo也没有指明哪一篇文章的错误这点相当的坑.也是很奇怪昨天写的文章都可以正常的发布,但今天居然找到的是两篇之前很久的文章,蜜汁操作.

问题原因:文章中谋篇可能有大括号之类或是格式不正确,如图片是[]()漏了某一个符号

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
TypeError [ERR_INVALID_URL]: Invalid URL: http://host:port/jsonrpc
at onParseError (internal/url.js:243:9)
at new URL (internal/url.js:319:5)
at D:\wwwroot\nobige\node_modules\hexo-util\lib\is_external_link.js:21:18
at Cache.apply (D:\wwwroot\nobige\node_modules\hexo-util\lib\cache.js:27:46)
at isExternalLink (D:\wwwroot\nobige\node_modules\hexo-util\lib\is_external_
link.js:19:16)
at D:\wwwroot\nobige\node_modules\hexo\lib\plugins\filter\after_render\exter
nal_link.js:23:35
at String.replace (<anonymous>)
at Hexo.externalLinkFilter (D:\wwwroot\nobige\node_modules\hexo\lib\plugins\
filter\after_render\external_link.js:22:15)
at Hexo.tryCatcher (D:\wwwroot\nobige\node_modules\bluebird\js\release\util.
js:16:23)
at Hexo.<anonymous> (D:\wwwroot\nobige\node_modules\bluebird\js\release\meth
od.js:15:34)
at D:\wwwroot\nobige\node_modules\hexo\lib\extend\filter.js:62:52
at tryCatcher (D:\wwwroot\nobige\node_modules\bluebird\js\release\util.js:16
:23)
at Object.gotValue (D:\wwwroot\nobige\node_modules\bluebird\js\release\reduc
e.js:166:18)
at Object.gotAccum (D:\wwwroot\nobige\node_modules\bluebird\js\release\reduc
e.js:155:25)
at Object.tryCatcher (D:\wwwroot\nobige\node_modules\bluebird\js\release\uti
l.js:16:23)
at Promise._settlePromiseFromHandler (D:\wwwroot\nobige\node_modules\bluebir
d\js\release\promise.js:547:31)
at Promise._settlePromise (D:\wwwroot\nobige\node_modules\bluebird\js\releas
e\promise.js:604:18)
at Promise._settlePromiseCtx (D:\wwwroot\nobige\node_modules\bluebird\js\rel
ease\promise.js:641:10)
at _drainQueueStep (D:\wwwroot\nobige\node_modules\bluebird\js\release\async
.js:97:12)
at _drainQueue (D:\wwwroot\nobige\node_modules\bluebird\js\release\async.js:
86:9)
at Async._drainQueues (D:\wwwroot\nobige\node_modules\bluebird\js\release\as
ync.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (D:\wwwroot\nobige\node_mod
ules\bluebird\js\release\async.js:15:14)

参考