gatsby-gitbook-starter icon indicating copy to clipboard operation
gatsby-gitbook-starter copied to clipboard

Possible to have subdirectories in Nav?

Open Rombles opened this issue 3 years ago • 1 comments

Greetings -

I've been working with this project for a few weeks now and it's great, however I was wondering if there was a simple way to configure all treenodes to be collapsed by default. I've tried making a few modifications myself, but none of them have been successful (sometimes they'll work on gatsby develop, but won't launch in Gitlab pages). Here's the layout of the content directory that I'm using:

.

├── index.mdx
├── lab
│   ├── architecture
│   │   ├── 1-hardware.md
│   │   └── 1-network-topology.md
│   └── architecture.md
└── systems-administration
    └── Resize-Filesystem.md

I've been looking around src/components/sidebar/tree.js and was thinking of modifying it like this:


  treeData.items.forEach(item => {
    if (config.sidebar.collapsedNav && config.sidebar.collapsedNav.includes(item.url)) {
      defaultCollapsed[item.url] = true;
    } else if (item.items.length !== 0) { // Assume page has children that should be collapsed
        item.items.forEach(child => {
          defaultCollapsed[child.url] = true;
    } else {
      defaultCollapsed[item.url] = false;
    }

Any tips? Default behavior with subdirectories is pretty unsightly and it would be great to be able to set them collapsed by default.

Rombles avatar Dec 06 '20 00:12 Rombles

the description of this issue is misleading... consider changing it to "possible to collapse nav bar by default?" ?

swarupdonepudi avatar Apr 07 '21 11:04 swarupdonepudi