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

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

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

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

1. 注册OAuth Application

由于Gitment使用了GitHub的服务,所以须要注册OAuth application。其中,Authorization callback URL必须填写博客的域名(我填的是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.ejs小程序

<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中添加:微信小程序

<%- partial('gitment') %>
复制代码

4. 初始化Gitment

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

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

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

参考连接

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

关于Fundebug

Fundebug专一于JavaScript、微信小程序、微信小游戏、支付宝小程序、React Native、Node.js和Java实时BUG监控。 自从2016年双十一正式上线,Fundebug累计处理了6亿+错误事件,获得了Google、360、金山软件等众多知名用户的承认。欢迎免费试用!

版权声明

转载时请注明做者Fundebug以及本文地址:
blog.fundebug.com/2017/06/14/…

相关文章
相关标签/搜索