chaooo / hexo-theme-BlueLake

A simple theme for Hexo with great performance on different devices .
MIT License
329 stars 121 forks source link

主题添加 Gitment 评论 #54

Closed dbarobin closed 6 years ago

dbarobin commented 6 years ago

看了 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')
</script>

非常感谢。

dbarobin commented 6 years ago

已解决,感谢。

841809077 commented 6 years ago

您好,请问您是怎么解决的?有哪些注意事项吗?期待您的留言

dbarobin commented 6 years ago

themes/BlueLake/_config.yml 文件添加:

  #Cmments
  comment:
    gitment:
    id: window.location.pathname
    owner:
    repo: 
    client_id:
    client_secret:

themes/BlueLake/layout/_partial/comments.jade 文件添加

 if theme.comment.gitment && theme.comment.gitment.owner && theme.comment.gitment.repo && theme.comment.gitment.client_id && theme.comment.gitment.client_secret
   #container
   link(rel='stylesheet', href='https://imsun.github.io/gitment/style/default.css')
   script(src='https://imsun.github.io/gitment/dist/gitment.browser.js')
   script.
     var gitment = new Gitment({
       owner: '#{theme.comment.gitment.owner}',
       repo: '#{theme.comment.gitment.repo}',
       oauth: {
         client_id: '#{theme.comment.gitment.client_id}',
         client_secret: '#{theme.comment.gitment.client_secret}',
       },
     })
     gitment.render('container')

需要注意的是,gitment 不支持 GitHub 组织添加评论。