Skip to content

Possible to have subdirectories in Nav? #87

Open
@Rombles

Description

@Rombles

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions