egoist / docute

📚 Effortless documentation, done right.
https://docute.egoist.dev
MIT License
3.8k stars 427 forks source link

Children in children not working #274

Open steptro opened 4 years ago

steptro commented 4 years ago

Children inside children does not seem to be working. I'm using the following sidebar configuration

[
    {
        "title": "name",
        "children": [
            {
                "title": "item 1",
                "link": "#"
            },
            {
                "title": "item 2",
                "link": "#"
            },
            {
                "title": "another list",
                "children": [
                    {
                        "title": "item 3",
                        "link": "#"
                    }
                ]
            }
        ]
    }
]

When using this sidebar configuration, I get the following error: Screenshot 2019-12-11 at 14 13 46

When I remove the item with the children it works as expected.

zakrzk commented 4 years ago

Same here, is there any other way to implement multi-level menu?

steptro commented 4 years ago

The problem is that SideBarItem cannot have any children. See https://github.com/egoist/docute/blob/master/src/components/SidebarItem.vue#L37-L52.

This could probably be fixed by adding a SideBarItem if it detects that the item has children:

<div
      class="ItemChildren"
      v-if="children && (open || item.collapsable === false)"
    >

      <div class="ItemChild" v-for="(link, index) of children" :key="index">
        ...

        <sidebar-item
          v-if="link.children"
          :item="link"
          :open="closedItems.indexOf(index) === -1"
          @toggle="toggleItem(index)"
        />
      </div>
    </div>