0

Is it possible to to use http://localhost:3000/reference/ or any other path instead of http://localhost:3000/docs/ to point to the documentation *.md structure?

I configured the preset-classic inside docusaurus.config.js like this:

module.exports = {
  presets: [
    [
      '@docusaurus/preset-classic',
      {
        docs: {
          path: 'reference/',
          sidebarPath: require.resolve('./reference/sidebars.js')
        },
        theme: {
          customCss: require.resolve('./src/css/custom.css'),
        },
      },
    ],
  ],
};

but I get:

test.md 1:2
Module parse failed: Assigning to rvalue (1:2)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> ---
| id: test
| title: Test
 @ ./.docusaurus/registry.js 1:2593-2646 1:2459-2559
...

I'm using Docusaurus V2, does it currently support this?

Jacob Krieg
  • 2,834
  • 15
  • 68
  • 140

1 Answers1

0

Yes, it is possible.

Your mistake was probably the / in path: 'reference/',.

Note: When you change the docusaurus.config.js you need to kill the docusaurus process and start again, it doesn't reload well --- at least not with me.

[...]
presets: [
    [
      '@docusaurus/preset-classic',
      {
        docs: {
          routeBasePath: 'reference',
          path: 'reference',
          sidebarPath: require.resolve('./reference/sidebars.js'),
          lastVersion: 'current',
          onlyIncludeVersions: ['current'],
        },
        theme: {
          customCss: require.resolve('./src/css/custom.css'),
        },
      },
    ],
  ],
[...]

You probably will need to change the navbar.

[...]
navbar: {
  [...]
  items: [
    {
      to: '/reference',
      label: 'Reference',
      position: 'left',
      activeBaseRegex: `/reference/`,
    },
  ],
},
[...]
D.Kastier
  • 2,640
  • 3
  • 25
  • 40