Material暴力安装Gitalk

2018-05-26 05:18

真香

创建OAuth Application

需要 OAuth Application,如果没有 点击这里申请,Authorization callback URL 填写博客域名。

安装

创建目录

在 'blog/themes/material/layout/_widget/comment/' 下创建gitalk文件夹

创建文件

在gitalk文件夹中创建以下文件:

  • common.ejs
<script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css">
  • enter.ejs
<div id="gitalk-container">
    <%- partial('_widget/comment/' + theme.comment.use + '/main') %>
</div>
<style>
    #gitalk-container{
        background-color: #eee;
        padding: 2pc;
    }
</style>
  • main.ejs(更多配置请查看Gitalk中文说明)
<%- partial('_widget/comment/' + theme.comment.use + '/common') %>
<script type="text/javascript">
var gitalk = new Gitalk({
  clientID: 'OAuth Application Client ID',   //自行修改
  clientSecret: 'OAuth Application Client Secret',  //自行修改
  repo: 'GitHub repo',  //自行修改
  owner: 'GitHub repo owner',  //自行修改
  admin: ['GitHub repo owner and collaborators, only these guys can initialize github issues'],  //自行修改
  id: location.pathname,
  distractionFreeMode: true
})

gitalk.render('gitalk-container')
</script>

启用

Material主题配置文件

comment:
    use: gitalk

参考资料

Gitalking ...

Markdown is supported

Be the first guy leaving a comment!