From c3ccc0d318d0e4844e38f5db7190d969184750b0 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Tue, 3 Sep 2024 09:54:53 +0200 Subject: [PATCH] fix: collapsible trigger only if more than 2 subitems --- src/components/Nav/NavCategory.tsx | 36 ++++++++++++++++-------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/components/Nav/NavCategory.tsx b/src/components/Nav/NavCategory.tsx index 20ff63b5..bdea861b 100644 --- a/src/components/Nav/NavCategory.tsx +++ b/src/components/Nav/NavCategory.tsx @@ -31,6 +31,8 @@ export function NavCategory({ document.documentElement.style.setProperty('--collapsible-up-duration', dur) }, []) + const nonIndexItems = docsEntries.filter(([page]) => page !== INDEX_PAGE) + return ( {category.replace(/\-/g, ' ')} - -
- -
-
+ {nonIndexItems.length > 0 && ( + +
+ +
+
+ )}
    - {docsEntries - .filter(([page]) => page !== INDEX_PAGE) - .map(([page, doc]) => ( -
  • - - {doc.title} - -
  • - ))} + {nonIndexItems.map(([page, doc]) => ( +
  • + + {doc.title} + +
  • + ))}