Coder Social home page Coder Social logo

sivanlaai / vuepress-plugin-comment-plus Goto Github PK

View Code? Open in Web Editor NEW
11.0 1.0 0.0 27 KB

Vuepress评论插件,当前支持Waline(推荐)、Gitalk、Valine,后续会增加更多,请关注。

Home Page: https://sivanlaai.github.io/

Vue 36.54% JavaScript 63.46%
waline valine vuepress vuepress-plugin vuepress-comment gitalk blog

vuepress-plugin-comment-plus's Introduction

Vuepress-comment-plugin-plus

说明文档 - [中文 | English]

version visitors

Vuepress评论插件,当前支持Waline(推荐)、Gitalk、Valine

特征

  • 支持Waline
  • 支持Gitalk, Valine
  • 动态导入
  • 响应路由改变并自动刷新
  • 用户可以使用文章中的$frontmatter

使用

安装

npm:

npm install --save vuepress-plugin-comment-plus

yarn:

yarn add vuepress-plugin-comment-plus -D

cnpm:

cnpm i --save vuepress-plugin-comment-plus

⚠️路由对象属性

不要使用window对象直接去获取路由信息.

frontmatter.tofrontmatter.from对象中,插件已经注册了路由信息. 所有的属性信息和vue-router的路由对象属性一致.

使用Waline

module.exports = {
  plugins: [
    [
      'vuepress-plugin-comment-plus',
      {
	     choosen: 'waline', 
         // options选项中的所有参数,会传给Waline的配置
         options: {
           el: '#valine-vuepress-comment',
           serverURL: 'your serverURL', //  例如 "https://***.vercel.app/"
	       path: '<%- frontmatter.commentid || frontmatter.permalink %>'
         }
      }
    ]
  ]
}

使用Gitalk

npm i --save gitalk
module.exports = {
  plugins: [
    [
      'vuepress-plugin-comment-plus',
      {
        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 
        }
      }
    ]
  ]
}

如果想获取参数,如$frontmatterwindow, 请使用EJS脚本语言

module.exports = {
  plugins: [
    [
      'vuepress-plugin-comment-plus',
      {
        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,
        }
      }
    ]
  ]
}

注意: vuepress会过滤调插件配置,所以不要在配置中使用回调函数。请使用EJS脚本语言。

使用Valine

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

如果想获取参数,如$frontmatterwindow, 请使用EJS脚本语言

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

隐藏评论栏

你如果想在指定页面隐藏评论栏,设置$frontmatter.comment或者$frontmatter.commentsfalse

例如:

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

这样一来,文章页面就不会出现评论栏。

设置详解

变量名 类型 备注 说明
choosen string 必须
options object 必须 对应使用的评论插件的配置
container string 可选,默认是'main.page' 包含评论插件的dom选择器

vuepress-plugin-comment-plus's People

Contributors

dongyuanxin avatar sivanlaai avatar wxsms avatar yiliang114 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

vuepress-plugin-comment-plus's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.