给hexo博客添加gitment评论

说起gitment全是泪啊~~~多说6月1号说拜拜,刚7月3号的时候换了网易云跟帖,今天早上就收到个坏消息:

image

好吧,我再换
参考gitment作者博客说明:https://imsun.net/posts/gitment-introduction/

概括下使用说明 就两步就行 超简单

1. 注册github OAuth Application

在头像->setting下面


image

得到owner、client_id、client_secret
注意填写:若是绑定个人域名就不能使用yourname.github.io作为Homepage URL和Authorization callback URL。gitment会报Error: Comments Not Initialized错误

2. 引入 Gitment

将下面的代码添加到你的页面:

<div id="container"></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({
  id: '页面 ID', // 可选。默认为 location.href
  owner: '你的 GitHub ID',
  repo: '存储评论的 repo',
  oauth: {
    client_id: '你的 client ID',
    client_secret: '你的 client secret',
  },
})
gitment.render('container')

注意填写:参数错误会出现Error: Not Found报错

  • id可以直接删掉
  • repo只要填你的仓库名称就行,不用仓库的git或ssh。例如我的 repo: 'honjun.github.io',
  • id="container"和gitment.render('container')最好改下,比如gitment-container以防id重复

新建了个简书程序员交流群194472590,欢迎加入交流!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,845评论 18 139
  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    passiontim阅读 15,489评论 2 45
  • Swift版本点击这里欢迎加入QQ群交流: 594119878最新更新日期:18-09-17 About A cu...
    ylgwhyh阅读 25,522评论 7 249
  • 仿佛刚刚才度过了清明的三天假期,又马上要迎接五一的降临了,上半年的假期还真是不少,但是,在休息的间隙,会不会有人也...
    猫小样儿阅读 245评论 0 1
  • 最近很是勤快,每周五晚上都陪着一波小朋友认真玩。 很喜欢今天“雪花片片”的体验活动,大小朋友跟着指令撕纸,创造出完...
    陈蕾FZ阅读 958评论 0 51