由来
gitment使用 github issue 保存评论
准备
右键新标签页打开 https://github.com/settings/applications/new
创建
获取 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
点击打赏
会心一笑