为hexo搭建的博客主题为aero-dual添加流量统计和gitment评论功能
添加不蒜子流量统计
- 在主题的layout–>_partial–>header.ejs文件添加
1
2<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
如下图所示
- 在主题的layout–>_partial–>footer.ejs文件添加
1
2
3<span id="busuanzi_container_site_pv">
本站总访问量 <span id="busuanzi_value_site_pv"></span>次
</span>
如下图所示
- 在themes/aero-dual/layout/_partial/post/article.ejs添加
1
2
3<span id="busuanzi_container_page_pv">
本文浏览量<span id="busuanzi_value_page_pv"></span>次
</span>
如下图所示
添加gitment评论
此部分主要参考 搭建 Github 个人博客(四):配置博客评论功能,已经讲解的很详细,这里只针对areo-dual主题添加代码的位置进行记录。
themes/aero-dual/layout/_partial/post/article.ejs添加
1
2
3
4
5
6
7
8
9
10
11
12
13
14<div id="gitmentContainer"></div>
<link rel="stylesheet" href="https://imsun.github.io/gitment/style/default.css">
<script src="https://imsun.github.io/gitment/dist/gitment.browser.js"></script>
<script>
var gitment = new Gitment({
owner: 'Your GitHub username',
repo: 'The repo to store comments',
oauth: {
client_id: ''Your client ID'',
client_secret: 'Your client secret',
},
});
gitment.render('gitmentContainer');
</script>说明:以上代码有四个需要修改的地方:
1
2
3
4Your GitHub username:填写你的博客所在的 GitHub 账户名;
The repo to store comments:填写存放评论的 GitHub 仓库名(由于 gitment 的评论是通过 issues 来存放的,所以建议这里填写个人博客所在的仓库)。
Your client ID:前面所申请到的 Client ID。
Your client secret:前面所申请到的 Client Secret。更改结果如图所示