vuepress - 如何使用寄存器组件自定义组件目录'.vuepress/components'的位置?

Ren*_*art 4 customization components vue.js vuepress

我尝试使用插件寄存器/组件在vuepress中添加组件的自定义目录,但似乎不可能.

我试过了

module.exports = {
  title: 'Hello VuePress',
  description: 'Just playing around',
  plugins: [
   [
     'register-components',
     {
       componentDir: '../components'
     }
   ]
  ]
}
Run Code Online (Sandbox Code Playgroud)

用这种架构(我想选择"组件"目录)

在此输入图像描述

但它似乎不起作用,因为组件未被识别

在此输入图像描述

我认为我在base-button.md中写好了我的组件

在此输入图像描述

有人能帮助我告诉我到达那里的步骤吗?

非常感谢

Ric*_*sen 6

您可以像在Vue应用程序中注册组件一样全局注册组件enhanceApp.js(应该位于/.vuepress/文件夹中).

enhanceApp.js

import BaseButton from '../../components/BaseButton'

export default ({
  Vue, // the version of Vue being used in the VuePress app
  options, // the options for the root Vue instance
  router, // the router instance for the app
  siteData // site metadata
}) => {
  Vue.component('BaseButton', BaseButton)
}
Run Code Online (Sandbox Code Playgroud)