From c60ec2eedd34fdd571e0dc95a2519fff993fd18a Mon Sep 17 00:00:00 2001 From: 3y3 <3y3@ya.ru> Date: Wed, 3 Apr 2024 19:13:03 +0300 Subject: [PATCH] fix: Fix toc navigation items sequence --- src/components/TocNavPanel/TocNavPanel.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/TocNavPanel/TocNavPanel.tsx b/src/components/TocNavPanel/TocNavPanel.tsx index 0674c4bb..579081cf 100644 --- a/src/components/TocNavPanel/TocNavPanel.tsx +++ b/src/components/TocNavPanel/TocNavPanel.tsx @@ -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[]); }