@vuepress/plugin-register-components

register-components plugin for vuepress

安装

  1. yarn add -D @vuepress/plugin-register-components@next
  2. # OR npm install -D @vuepress/plugin-register-components@next

使用

  1. module.exports = {
  2. plugins: ['@vuepress/register-components']
  3. }

选项

componentsDir

  • 类型: Array | String
  • 默认值: []在这个目录下的所有组件将会被注册为全局组件,组件的命名将遵循在 .vuepress/components 中找到的组件的命名。
  1. module.exports = {
  2. plugins: [
  3. [
  4. 'register-components',
  5. {
  6. componentsDir: somepath
  7. }
  8. ]
  9. ]
  10. }

components

  • 类型: { name: string, path: string }
  • 默认值: []通过明确的名称和路径来注册组件。
  1. module.exports = {
  2. plugins: [
  3. [
  4. 'register-components',
  5. {
  6. components: [
  7. {
  8. name: 'V-Card',
  9. path: 'path/to/card.vue'
  10. }
  11. ]
  12. }
  13. ]
  14. ]
  15. }

getComponentName

  • 类型: (file: string) => string
  • 默认值: file => file.replace(/\/|\/g, '-')自定义 componentsDir 中注册的组件的名称。