前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Vuepress框架 插件包收藏

Vuepress框架 插件包收藏

作者头像
郭顺发
发布2023-07-07 11:29:00
3130
发布2023-07-07 11:29:00
举报
文章被收录于专栏:pandacode_cnpandacode_cn

一、插件包收藏

二、各插件包使用说明

2.1. vuepress-plugin-comment 平台评论

先放官网链接:https://github.com/dongyuanxin/vuepress-plugin-comment

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

With npm:

代码语言:javascript
复制
npm install --save vuepress-plugin-comment

With yarn:

代码语言:javascript
复制
yarn add vuepress-plugin-comment -D

With cnpm:

代码语言:javascript
复制
cnpm i --save vuepress-plugin-comment
⚠️Route object properties

Don’t use window object directly to get route information.

Plugin has registered correct route information in frontmatter.to object and frontmatter.from object. Their properties are the same as vue-router’s route object.

Use in Gitalk

The options is exactly the same as Gitalk configuration.

代码语言:javascript
复制
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.

代码语言:javascript
复制
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

https://github.com/DesertsP/Valine-Admin

The options is exactly the same as Valine configuration.

代码语言:javascript
复制
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.

代码语言:javascript
复制
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:

代码语言:javascript
复制
---
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.
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2022-07-01 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 一、插件包收藏
  • 二、各插件包使用说明
    • 2.1. vuepress-plugin-comment 平台评论
      • Features
      • Usage
      • Options Detail
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档