javascript 将base /docs/路径更改为/home/|多库龙属

sg3maiej  于 2023-06-20  发布在  Java
关注(0)|答案(2)|浏览(143)

我正在尝试将默认的docs路径重命名为home,以便所有“文档”文件都可以在主目录下找到,如home/doc1。所以,我遵循了这个指南:https://docusaurus.io/docs/docs-multi-instance和改变了我的docusaurus.config.js文件如下:

module.exports = {
  title: 'Neuro Guide',
  tagline: 'The tagline of my site',
  url: 'https://neuro-guide.vercel.app',
  baseUrl: '/',
  favicon: 'img/favicon.ico',
  organizationName: 'aakhilv', // Usually your GitHub org/user name.
  projectName: 'neuro-guide', // Usually your repo name.
  themeConfig: {
    navbar: {
      title: 'Neuro Guide',
      logo: {
        alt: 'Logo',
        src: 'img/logo.svg',
      },
      links: [{
        to: 'home/doc1',
        activeBasePath: 'home',
        label: 'Home',
        position: 'left',
      }, ],
    },
    footer: {
      style: 'dark',
      copyright: `© ${new Date().getFullYear()} aakhilv`,
    },
  },
  plugins: [
    [
      '@docusaurus/plugin-content-docs',
      {
        id: 'home',
        path: 'home',
        routeBasePath: 'home',
        docs: {
          sidebarPath: require.resolve('./sidebars.js'),
        },
        theme: {
          customCss: require.resolve('./src/css/custom.css'),
        },
      },
    ],
  ],
};

但是,我总是得到这个错误:

有谁知道我该怎么修吗?

euoag5mw

euoag5mw1#

我认为错误是因为你需要至少一个主题激活。如果使用经典预设(https://docusaurus.io/docs/presets#docusauruspreset-classic),则只需设置以下配置:

presets: [
  [
    '@docusaurus/preset-classic',
    {
      docs: {
        path: 'home',
        routeBasePath: 'home',
      },
    },
  ],
],
t2a7ltrp

t2a7ltrp2#

添加以下代码后

presets: [
  [
    '@docusaurus/preset-classic',
    {
      docs: {
         path: './docs', //This should be the path to your docs folder
         routeBasePath: 'home'  //This should be the word that you want to set
       },
    },
  ],
],

删除node_modulespackage-lock.json,如果不直接为您工作,则再次执行npm install

相关问题