0%

Gitalk in Gitbook

论如何为 Gitbook 添加评论功能。

https://github.com/settings/applications/new 里面注册,链接均填入 rCore_tutorial 文档主页 https://wyfcyx.github.io/rCore_tutorial_doc/

得到

1
2
3
4
Client ID
c3b20e343ac397f1b67c
Client Secret
be4dd3f990da0c80c9592f38327ac4eb4854a31b

一段 HTML 用来插入 gitalk。repo 写你托管评论的仓库的名字。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<!-- gitalk.html -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css">
<script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
"clientID": "clientId",
"clientSecret": "clientSecret",
"repo": "GitHub repo",
"owner": "GitHub repo owner",
"admin": ["GitHub repo admin"],
"id": location.pathname,
"distractionFreeMode": false
});
gitalk.render("gitalk-container");
</script>

使用 localized-footer 插件。

1
2
3
4
5
6
7
8
9
// book.json
{
"plugins": ["localized-footer"],
"pluginsConfig": {
"localized-footer": {
"filename": "gitalk.html"
}
}
}

最后 gitbook build ,传到 git 上完全工作!