shuding / nextra

Simple, powerful and flexible site generation framework with everything you love from Next.js.
https://nextra.site
MIT License
11.72k stars 1.27k forks source link

Splitting out top navigation and side navigation with separate settings #2235

Open tatukoivisto opened 1 year ago

tatukoivisto commented 1 year ago

I just had a problem with the current nextra, where I could not have pages with children in top navigation that had index pages and were not just “virtual” menus.

We have two type settings that I can use to impact whether something is on the top navigation type: page and type: menu.

If I set up the type to page, I loose the left side menu from the page. 



On the other hand, if I setup the type menu, it’s only working if I don’t have index page for the parent folder.
In my case, I want to have the index page with children in the top nav, while keeping the rest of the functionality. 



For example in the page swr’s page I want to have an index page for the https://swr.vercel.app/examples/, while keeping it in the top navigation. 



Current bundling of the navigation bar and sidebar functionality does not allow to do this. 



We could solve this with a separate setting. (shownavitem:boolean)



We could still maintain the default functionality with the type: menu and type: page, but if the optional shownavitem is set, that would be the overriding setting.

To complete the separation of the sidebar and navbar visibility, we could change display:hidden into showsideitem:false etc. to be more explicit about the functionality.

carlgieringer commented 1 year ago

I am also encountering this. I have a policies.mdx and policies/user-agreement.mdx, policies/privacy-policy.mdx, etc. on docs.howdju.com. The closest I can get is to do something like:

  ...
  "policies": "",
  "policies_page": {
    "title": "Policies",
    "type": "page",
    "href": "/policies"
  },
  ...

This doesn't remove the Policies section from the page-wide left-hand navbar, but it does add a link in the top navbar. Clicking on the top navbar or the top-level section name takes the user to the directory index page (policies.mdx), and that page has left-hand nav to see the sub-pages.

The downsides to this approach are: