美文网首页hexo程序员
给hexo博客添加gitment评论

给hexo博客添加gitment评论

作者: hojun | 来源:发表于2017-07-10 23:32 被阅读141次

    说起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,欢迎加入交流!

    相关文章

      网友评论

      • d32f5e5c80b3:多谢,之前一直Error: Comments Not Initialized,原来Authorization callback URL应该配置成自定义的域名
      • Ashen_:您好,<div id="container"></div>
        ,这段代码具体添加到哪个页面呢?
        hojun: @littleShi 你博客不是hexo搭建的吗?找到文章对应的那个模板页面加上div就行
        Ashen_:在md里面写这个?
        hojun: @littleShi 一般是在文章的最后
      • hojun:简书的md对html元素支持的不是很好啊

      本文标题:给hexo博客添加gitment评论

      本文链接:https://www.haomeiwen.com/subject/gwxphxtx.html