Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add gitalk plugin #306

Merged
merged 1 commit into from
Nov 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ var plugins = [
{ name: 'front-matter', entry: 'front-matter/index.js' },
{ name: 'zoom-image', entry: 'zoom-image.js' },
{ name: 'codesponsor', entry: 'codesponsor.js' },
{ name: 'disqus', entry: 'disqus.js' }
{ name: 'disqus', entry: 'disqus.js' },
{ name: 'gitalk', entry: 'gitalk.js' }
]

plugins.forEach(item => {
Expand Down
22 changes: 22 additions & 0 deletions docs/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,25 @@ Disqus comments. https://disqus.com/
</script>
<script src="//unpkg.com/docsify/lib/plugins/disqus.min.js"></script>
```

## Gitalk

Gitalk is a modern comment component based on Github Issue and Preact. https://github.com/gitalk/gitalk

```html
<link rel="stylesheet" href="//unpkg.com/gitalk/dist/gitalk.css">

<script src="//unpkg.com/docsify/lib/plugins/gitalk.min.js"></script>
<script src="//unpkg.com/gitalk/dist/gitalk.min.js"></script>
<script>
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
})
</script>
```
17 changes: 17 additions & 0 deletions src/plugins/gitalk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function install (hook, vm) {
const dom = Docsify.dom

hook.mounted(_ => {
const div = dom.create('div')
div.id = 'gitalk-container'
const main = dom.getNode('#main')
div.style = `width: ${main.clientWidth}px; margin: 0 auto 20px;`
dom.appendTo(dom.find('.content'), div)
const script = dom.create('script')
const content = `gitalk.render('gitalk-container')`
script.textContent = content
dom.appendTo(dom.body, script)
})
}

$docsify.plugins = [].concat(install, $docsify.plugins)