Gitalk is a modern comment component based on Github Issue and Preact.
- Authentication with github account
- Serverless, all comments will be stored as github issues
- Both personal and organization github projects can be used to store comments
- Localization, support multiple languages [en, zh-CN, zh-TW, es-ES, fr]
- Facebook-like distraction free mode (Can be enabled via the
distractionFreeModeoption) - Hotkey submit comment (cmd|ctrl + enter)
Two ways.
- links
<link rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css"> <script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>- npm install
npm i --save gitalkimport 'gitalk/dist/gitalk.css' import Gitalk from 'gitalk'A Github Application is needed for authorization, if you don't have one, Click here to register a new one.
Note: You must specify the website domain url in the Authorization callback URL field.
const gitalk = new Gitalk({ clientID: 'Github Application Client ID', clientSecret: 'Github Application Client Secret', repo: 'Github repo', owner: 'Github repo owner', admin: ['Github repo collaborators, only these guys can initialize github issues'], // facebook-like distraction free mode distractionFreeMode: false }) gitalk.render('gitalk-container')-
clientID
StringRequired. Github Application Client ID.
-
clientSecret
StringRequired. Github Application Client Secret.
-
repo
StringRequired. Github repository.
-
owner
StringRequired. Github repository owner. Can be personal user or organization.
-
admin
ArrayRequired. Github repository collaborators. (Ensure having write access to this repository)
-
id
StringDefault:
location.href.The unique id of the page.
-
labels
ArrayDefault:
['Gitalk'].Github issue labels.
-
title
StringDefault:
document.title.Github issue title.
-
body
StringDefault:
location.href + header.meta[description].Github issue body.
-
language
StringDefault:
navigator.language || navigator.userLanguage.Localization language key,
en,zh-CNandzh-TWare currently available. -
perPage
NumberDefault:
10.Pagination size, with maximum 100.
-
distractionFreeMode
BooleanDefault: false.
Facebook-like distraction free mode.
-
pagerDirection
StringDefault: 'last'
Comment sorting direction, available values are
lastandfirst. -
createIssueManually
BooleanDefault:
false.By default, Gitalk will create a corresponding github issue for your every single page automatically when the logined user is belong to the
adminusers. You can create it manually by setting this option totrue. -
proxy
StringDefault:
https://cors-anywhere.herokuapp.com/https://github.com/login/oauth/access_token.Github oauth request reverse proxy for CORS. Why need this?
-
flipMoveOptions
ObjectDefault:
{ staggerDelayBy: 150, appearAnimation: 'accordionVertical', enterAnimation: 'accordionVertical', leaveAnimation: 'accordionVertical', }
Comment list animation. Reference
-
enableHotKey
BooleanDefault:
true.Enable hot key (cmd|ctrl + enter) submit comment.
-
render(String/HTMLElement)
Init render and mount plugin.
- Fork the repository and create your branch from master
- If you've added code that should be tested, add tests!
- If you've changed APIs, update the documentation.
- Ensure the test suite passes (npm test).
- Make sure your code lints (npm run lint).
- Commit your changes (git commit) Commit Message Format Reference
MIT