Skip to content

Commit ab27fd3

Browse files
committed
hide components with no nav; skip empty top level in nav tree
1 parent 7341de1 commit ab27fd3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/js/01-nav.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
var componentsListEl = createElement('ul', 'components_list')
3535
group.components.forEach(function (componentName) {
3636
var componentNavData = navData[componentName]
37+
var hasNavTrees
3738
var componentsListItemsEl = createElement('li', 'components_list-items')
3839
var componentVersionsEl = createElement('div', 'component_list-version')
3940
// FIXME we would prefer if the navigation data identified the latest version itself
@@ -60,10 +61,12 @@
6061
if (page.component !== componentName || page.version !== componentVersion.version) {
6162
componentVersionNavEl.classList.add('hide')
6263
}
63-
buildNavTree(componentVersion.sets, componentVersionNavEl, page, [])
64+
var items = componentVersion.sets
65+
if (items.length === 1 && !items.content) items = items[0].items
66+
if (buildNavTree(items, componentVersionNavEl, page, [])) hasNavTrees = true
6467
componentsListItemsEl.appendChild(componentVersionNavEl)
6568
})
66-
componentsListEl.appendChild(componentsListItemsEl)
69+
if (hasNavTrees) componentsListEl.appendChild(componentsListItemsEl)
6770
})
6871
groupEl.appendChild(componentsListEl)
6972
container.appendChild(groupEl)

0 commit comments

Comments
 (0)