评论

由来

gitment使用 github issue 保存评论

准备

右键新标签页打开 https://github.com/settings/applications/new

创建
app-id

获取 id secret
参数

hexo Theme

根据 个人主题 添加

样式

source/css/gitment.css

source/js/gitment.js

布局调用

调用认证
/layout/_partial/comments/gitment.ejs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<div id="gitment"></div>
<!-- 主页不要加载gitment -->
<%if (!index){ %>
<script>
var gitment = new Gitment({
owner: 'chengshea',
repo: 'chengshea.github.io',
oauth: {
client_id: '3478952f5e3ade06xxxxx',
client_secret: '3ca8b3ada58c7993cbb385839f83ba8xxxxxx',
},
})
gitment.render('gitment')
</script>
<% } %>

添加评论
/layout/_partial/article.ejs

1
2
3
4
5
6
7
8
9
10
11
12
13
<% if (!index && post.comments){ %>
<% if (theme.gitment.on) { %>
<%- partial('comments/gitment') %>
<% } else if (theme.disqus.on) { %>
<%- partial('comments/disqus', {
shortname: theme.disqus.shortname
}) %>
<% } else if (config.disqus_shortname) { %>
<%- partial('comments/disqus', {
shortname: config.disqus_shortname
}) %>
<% } %>
<% } %>

_config.yml 配置添加gitment开启

1
2
3
4
5
6
7
gitment:
on: true
enable: true
owner: chengshea
repo: chengshea.github.io
client_id: 3478952f5e3adexxxxx
client_secret: 3ca8b3ada58c7993cbb385839f83bxxxxx

管理OAuth Apps

https://github.com/settings/developers

点击打赏
文章目录
  1. 1. 由来
  2. 2. 准备
  3. 3. hexo Theme
    1. 3.1. 样式
    2. 3.2. 布局调用
载入天数...载入时分秒... ,