nextra icon indicating copy to clipboard operation
nextra copied to clipboard

The top level `docs` button opens the first `proper page` instead of the first `actual page`

Open Genesis3800 opened this issue 1 year ago • 2 comments

I am using Nextra at work, and first I just want to thank you for such an amazing open sourced product. I want to report a bug however.

Expected behaviour:

  • The default docs button should redirect to the first page in the docs, regardless of whether it is a proper page or a folder with an index page.

Actual behaviour:

  • Check out this website at https://docs.availproject.org/. When you click on the docs button on the top-right, it redirects to the Avail DA page, instead of the page associated with the folder introduction-to-avail.

Genesis3800 avatar Apr 12 '24 09:04 Genesis3800

@dimaMachina tagging for visibility.

Genesis3800 avatar Apr 20 '24 07:04 Genesis3800

Having the same issue, there's a workaround that can be applied in theme.config.tsx though:

import {Navbar} from 'nextra-theme-docs';

// ...

  navbar: {
    component: function CustomNavbar({
      items,
      ...rest
    }: ComponentProps<typeof Navbar>) {
      // https://github.com/shuding/nextra/issues/2836
      const props = {
        items: items.map((item) => {
          if (item.route === '/docs') {
            return {
              ...item,
              firstChildRoute: '/docs'
            };
          } else {
            return item;
          }
        }),
        ...rest
      };

      return <Navbar {...props} />;
    }
  },

amannn avatar May 09 '24 16:05 amannn