Skip to content

Commit 06285a3

Browse files
committed
fix: show directories with a single child in tree
1 parent d98943d commit 06285a3

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

example/content/pages/index.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/NestedCollection.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,13 @@ const TreeNode = (props) => {
8585
});
8686

8787
return sortedData.map((node) => {
88-
const leaf = node.children.length <= 1 && !node.children[0]?.isDir && depth > 0;
89-
if (leaf) {
88+
if (!node.isDir) {
9089
return null;
9190
}
9291

9392
const title = getNodeTitle(node);
9493

95-
const hasChildren = depth === 0 || node.children.some((c) => c.children.some((c) => c.isDir));
96-
94+
const hasChildren = depth === 0 || node.children.some((c) => c.isDir);
9795
return (
9896
<React.Fragment key={node.path}>
9997
<TreeNavLink

src/ParentWidget.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ export class ParentControl extends React.Component {
121121
}
122122

123123
render() {
124-
const { forID, classNameWrapper, setActiveStyle, setInactiveStyle } = this.props;
124+
const { forID, classNameWrapper, setActiveStyle, setInactiveStyle, collection } = this.props;
125125

126126
const fullPath = this.getFullPath();
127127
const parentPath = this.getParent(fullPath) || '';
128128
const parent = this.state.entries.find((e) => this.getPath(e.path) === parentPath);
129-
const label = (parent && parent.data.title) || '';
129+
const label = (parent && parent.data.title) || collection.get('label');
130130

131131
const options = [
132132
{

0 commit comments

Comments
 (0)