Gitalk

Gitalk 是一个基于 GitHub Issue 和 Preact 开发的评论插件。

特性


  • 使用 GitHub 登录
  • 支持多语言 [en, zh-CN, zh-TW, es-ES, fr, ru]
  • 支持个人或组织
  • 无干扰模式(设置 distractionFreeMode 为 true 开启)
  • 快捷键提交评论 (cmd|ctrl + enter)
    在线示例

安装


两种方式

  • 直接引入
    1
    2
    <link rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css"> 
    <script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>
  • npm安装
    1
    npm i --save gitalk
    1
    2
    import 'gitalk/dist/gitalk.css'
    import Gitalk from 'gitalk'

    使用


需要 GitHub Application,如果没有 点击这里申请,Authorization callback URL 填写当前使用插件页面的域名。

1
2
3
4
5
6
7
8
9
10
11
var gitalk = new Gitalk({
clientID: 'GitHub Application Client ID',
clientSecret: 'GitHub 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, // Ensure uniqueness and length less than 50
distractionFreeMode: false // Facebook-like distraction free mode
})

gitalk.render('gitalk-container')

设置


  • clientID String

必须. GitHub Application Client ID.

  • clientSecret String

必须. GitHub Application Client Secret.

  • repo String

必须. GitHub repository.