Skip to content
Comment plugin for vuepress, support for Gitalk, Valine...
Branch: master
Clone or download
Latest commit f7c0cc3 Jul 7, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore README Jun 11, 2019
Comment.vue add: support to valine && lazy load Jul 7, 2019
README.md update: README Jul 7, 2019
comment.js add: vuepress plugin config Jun 11, 2019
index.js add: vuepress plugin config Jun 11, 2019
package.json update: README Jul 7, 2019
util.js add: support to valine && lazy load Jul 7, 2019

README.md

Vuepress-comment-plugin

version

Support popluar comment plugins in Vuepress, sucn as Gitalk, Valine, Disqus.

Features

  • Support Gitalk, Valine
  • Dynamic Import
  • Response router change and refresh automatic
  • User can use passage's $frontmatter

Usage

Install

With npm:

npm install --save vuepress-plugin-comment

With yarn:

yarn add vuepress-plugin-comment -D

With cnpm:

cnpm i --save vuepress-plugin-comment

Use in Gitalk

The options is exactly the same as Gitalk configuration.

module.exports = {
  plugins: [
    [
      'vuepress-plugin-comment',
      {
        choosen: 'gitalk', 
        options: {
          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'],
          distractionFreeMode: false 
        }
      }
    ]
  ]
}

If you want to access variables, such as $frontmatter and window, please use EJS syntax.

module.exports = {
  plugins: [
    [
      'vuepress-plugin-comment',
      {
        choosen: 'gitalk', 
        options: {
          id: '<%- frontmatter.commentid || frontmatter.permalink %>',
          title: '「Comment」<%- frontmatter.title %>',
          body: '<%- frontmatter.title %>:<%-window.location.origin %><%- frontmatter.to.path || window.location.pathname %>',
          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'],
          distractionFreeMode: false,
        }
      }
    ]
  ]
}

Note: Never use callback function in plugin configuration, that will be filtered by vuepress. So I have to support EJS syntax.

Use in Valine

The options is exactly the same as Valine configuration.

module.exports = {
  plugins: [
    [
      'vuepress-plugin-comment',
      {
        choosen: 'valine', 
        options: {
          el: '#valine-vuepress-comment',
          appId: 'Your own appId',
          appKey: 'Your own appKey'
        }
      }
    ]
  ]
}

If you want to access variables, such as $frontmatter and window, please use EJS syntax.

module.exports = {
  plugins: [
    [
      'vuepress-plugin-comment',
      {
        choosen: 'valine', 
        options: {
          el: '#valine-vuepress-comment',
          appId: 'Your own appId',
          appKey: 'Your own appKey'
          path: '<%- frontmatter.commentid || frontmatter.permalink %>'
        }
      }
    ]
  ]
}

How to hide page comment

If you want to hide comment plugin in specified page, set $frontmatter.comment or $frontmatter.comments to false.

For example:

---
comment: false 
# comments: false 
---

Comment won't appear in the page of this passage.

Options Detail

  • choosen string

    Required.

  • options object

    Required. The options of choosen comment plugin.

  • container string

    Optional, default as 'main.page'. The dom selector that contains choosen comment plugin.

Todo

  • Support Disqus
  • 中文说明
You can’t perform that action at this time.