Skip to content

Commit 77a1a20

Browse files
authored
fix: Improve <TableOfContents> to allow empty sections (#13171)
Not sure why I even added this, but this seems unnecessary!
1 parent 51894fe commit 77a1a20

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/components/tableOfContents.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ export function TableOfContents({ignoreIds = []}: Props) {
4848
.filter(Boolean) as TreeNode[];
4949

5050
// Now group them together
51-
// We only support 2 levels of nesting,
52-
// where the first level is assumed to be headings, and the second one is assumed to be options
51+
// We only support 2 levels of nesting for now
5352
const _tocItems: TreeItem[] = [];
5453
let currentItem: TreeItem | undefined;
5554
for (let node of nodes) {
@@ -70,7 +69,7 @@ export function TableOfContents({ignoreIds = []}: Props) {
7069
}
7170

7271
// Remove groups without children
73-
setTreeItems(_tocItems.filter(item => item.children.length > 0));
72+
setTreeItems(_tocItems);
7473
}, [ignoreIds]);
7574

7675
return (

0 commit comments

Comments
 (0)