报错原因:因为 github 对 Issues label 的长度有了要求,如果超过 50 个字符串则会报错.

解决方案:

  定位到博客主题中的 gitalk.ejs 文件
1
2
3
4
5
6
7
8
9
10
11
12
13
//...省略其他代码
const gitalk = new Gitalk({
clientID: "<%= theme.gitalk.clientID %>",
clientSecret: "<%= theme.gitalk.clientSecret %>",
repo: "<%= theme.gitalk.repo %>",
owner: "<%= theme.gitalk.owner %>",
// id使用location.pathname 肯定超出50字符
id: location.pathname,
admin: ["<%= theme.gitalk.admin %>"],
// facebook-like distraction free mode
distractionFreeMode: false,
});
//...省略其他代码

思路是对 id 进行 md5 加密

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// step1 引用md5.js
<script src="https://cdn.bootcdn.net/ajax/libs/blueimp-md5/2.16.0/js/md5.min.js"></script>;

// step2 对id加密, 加密后的代码如下

//...省略其他代码
var id = md5(window.location.pathname).toUpperCase();
const gitalk = new Gitalk({
clientID: "<%= theme.gitalk.clientID %>",
clientSecret: "<%= theme.gitalk.clientSecret %>",
repo: "<%= theme.gitalk.repo %>",
owner: "<%= theme.gitalk.owner %>",
// id使用location.pathname 肯定超出50字符
id: id,
admin: ["<%= theme.gitalk.admin %>"],
// facebook-like distraction free mode
distractionFreeMode: false,
});

//...省略其他代码

重新发布,重建 Issues,问题解决