### [我的博客](https://lzz1.top)
今天发现git提供了评论的api,立马舍弃原来的valine?,毕竟这个站托管在git,当然要全部git化。
- 申请github应用,点击我**[传送门](https://github.com/settings/applications/new)**
- 申请好以后,在模板里引入下面代码
````
<% if (theme.comments.enable && page.comments){ %>
<section id="comments">
<div id="gitalk-container" style="margin: 30px;"></div>
<link rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css">
<script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>
<script>
var gitalk = new Gitalk({
clientID: '<%= theme.comments.clientID %>',
clientSecret: '<%= theme.comments.clientSecret %>',
repo: '<%= theme.comments.repo %>',
owner: '<%= theme.comments.owner %>',
admin: ['<%= theme.comments.admin.join(',') %>'],
id: '<%= page.title %>', // Ensure uniqueness and length less than 50
distractionFreeMode: false // Facebook-like distraction free mode
})
gitalk.render('gitalk-container')
</script>
</section>
<% } %>
````
- 主题配置
````
comments:
enable: true
clientID: 上面申请的
clientSecret: 上面申请的
repo: lnew.github.io 仓库,这是我的,添你自己的
owner: lnew 拥有者
admin:
- lnew 管理员
````
#### 好了,这就ok了,用自己github登录初始化一下试试吧
Hexo使用gitalk评论
最新推荐文章于 2021-11-08 17:04:37 发布