|
| 1 | +> Support popluar comment plugins in Vuepress. |
| 2 | +
|
| 3 | +## Features |
| 4 | + |
| 5 | +- Support Gitalk |
| 6 | +- Response router change and refresh automatic |
| 7 | +- User can use passage's `$frontmatter` |
| 8 | + |
| 9 | +## Todo |
| 10 | + |
| 11 | +- Support Valine, Disqus |
| 12 | + |
| 13 | +## Usage |
| 14 | + |
| 15 | +### Options |
| 16 | + |
| 17 | +- **choosen** `string` |
| 18 | + **Required**. |
| 19 | + |
| 20 | +- **options** `object` |
| 21 | + **Required**. The options of choosen comment plugin. |
| 22 | + |
| 23 | +- **container** `string` |
| 24 | + **Optional, default as `'main.page'`**. The dom selector that contains choosen comment plugin. |
| 25 | + |
| 26 | + |
| 27 | +### If you choose `Gitalk` |
| 28 | + |
| 29 | +The `options` is exactly the same as `Gitalk` configuration. |
| 30 | + |
| 31 | +```javascript |
| 32 | +module.exports = { |
| 33 | + plugins: [ |
| 34 | + 'vuepress-plugin-comment', |
| 35 | + { |
| 36 | + choosen: 'gitalk', |
| 37 | + options: { |
| 38 | + clientID: 'GitHub Application Client ID', |
| 39 | + clientSecret: 'GitHub Application Client Secret', |
| 40 | + repo: 'GitHub repo', |
| 41 | + owner: 'GitHub repo owner', |
| 42 | + admin: ['GitHub repo owner and collaborators, only these guys can initialize github issues'], |
| 43 | + distractionFreeMode: false |
| 44 | + } |
| 45 | + } |
| 46 | + ] |
| 47 | +} |
| 48 | +``` |
| 49 | + |
| 50 | +If you want to access variables, such as `$frontmatter` and `window`, please use **EJS** syntax. |
| 51 | + |
| 52 | +```javascript |
| 53 | +module.exports = { |
| 54 | + plugins: [ |
| 55 | + 'vuepress-plugin-comment', |
| 56 | + { |
| 57 | + choosen: 'gitalk', |
| 58 | + options: { |
| 59 | + id: '<%- frontmatter.commentid || frontmatter.permalink %>', |
| 60 | + title: '「Comment」<%- frontmatter.title %>', |
| 61 | + body: '<%- frontmatter.title %>:<%-window.location.origin%><%- window.location.pathname %>', |
| 62 | + clientID: 'GitHub Application Client ID', |
| 63 | + clientSecret: 'GitHub Application Client Secret', |
| 64 | + repo: 'GitHub repo', |
| 65 | + owner: 'GitHub repo owner', |
| 66 | + admin: ['GitHub repo owner and collaborators, only these guys can initialize github issues'], |
| 67 | + distractionFreeMode: false, |
| 68 | + } |
| 69 | + } |
| 70 | + ] |
| 71 | +} |
| 72 | +``` |
| 73 | + |
| 74 | +**Note**: Never use callback function in plugin configuration, that will be filtered by vuepress. So I have to support EJS syntax. |
| 75 | + |
0 commit comments