用GitHub Issue取代多说,是否是很厉害?

摘要: 别了,多说,拥抱Gitmentcss

2017年6月1日,多说正式下线,这多少让人感受有些遗憾。在比较了多个博客评论系统,我最终选择了Gitment做为本站的博客评论系统:html

  • UI简洁,适合个人博客风格
  • 使用GitHub帐号登录,适合技术博客
  • 使用GitHub Issues写评论,符合程序员的习惯

1. 注册OAuth Application

由于Gitment使用了GitHub的服务,所以须要注册OAuth application。其中,Authorization callback URL必须填写博客的域名(我填的是http://kiwenlau.com/)。注册成功以后将获取Client IDClient Secret,后面将会用到。git

2. 加载Gitment的CSS与JS文件

下载gitment.cssgitment.js,分别放入主题目录的source/csssource/js目录中程序员

layout/partial/head.ejs中添加github

<!-- 加载gitment的css和js文件 -->
<link rel="stylesheet" href="/css/gitment.css"> 
<script src="/js/gitment.js"></script>

3. 配置Gitment

添加layout/partial/gitment.ejsapp

<div id="gitment"></div>

<!-- 主页不要加载gitment -->
<% if (!index){ %>

<script>
var gitment = new Gitment({
  owner: 'kiwenlau',
  repo: 'blog',
  oauth: {
    client_id: '619731e02d908157a502',
    client_secret: '79d021512d492496a0729177b9acd807c579b1b6',
  },
})
gitment.render('gitment')
</script>
 
<% } %>
  • client_idclient_secret为第1步注册OAuth Application所获取的Client IDClient Secret
  • owner为你的GitHub帐户名
  • repo为你保存评论的GitHub仓库名称,全部的评论将保存在该仓库的Issues

layout/partial/article.ejs中添加:post

<%- partial('gitment') %>

4. 初始化Gitment

部署以后,就能够在博客页面的下方看到评论框。登录GitHub帐号以后,就能够对评论进行初始化,这样就能够开始写评论了。.net

每一篇博客的评论,对应于GitHub仓库一个issue。可是这些issue是不存在的,所以须要经过初始化Gitment去建立issue。这一点比较麻烦,由于对于每一篇博客都须要进行初始化。debug

实现细节能够参考个人博客源码blog,咱们博客评论保存在这个仓库的Issuescode

参考连接

Gitment:使用 GitHub Issues 搭建评论系统

欢迎加入咱们Fundebug全栈BUG监控交流群: 622902485

版权声明:

转载时请注明做者Fundebug以及本文地址:

https://blog.fundebug.com/2017/06/16/how-to-use-gitment/

相关文章
相关标签/搜索