Skip to content

Commit

Permalink
fix: Fix toc navigation items sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
3y3 committed Apr 3, 2024
1 parent e19e553 commit 689111d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/components/TocNavPanel/TocNavPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ interface FlatTocItem {

function getFlatToc(items: TocItem[]): FlatTocItem[] {
return items.reduce((result, {href, name, items: subItems}) => {
const part: FlatTocItem[] = subItems ? getFlatToc(subItems) : [];

if (href) {
part.push({name, href});
result.push({name, href});
}

return result.concat(part);
return result.concat(getFlatToc(subItems || []));
}, [] as FlatTocItem[]);
}

Expand Down

0 comments on commit 689111d

Please sign in to comment.