From d3b75338c4a239307cbbd681dd14541dd1eccf2c Mon Sep 17 00:00:00 2001 From: Matt Auer Date: Wed, 17 Jul 2024 10:20:24 -0500 Subject: [PATCH] feat: doc nav open --- src/components/SidebarSubmenu.tsx | 44 +++++++++---------------------- 1 file changed, 12 insertions(+), 32 deletions(-) diff --git a/src/components/SidebarSubmenu.tsx b/src/components/SidebarSubmenu.tsx index bf3b6ae8e..533665f6a 100644 --- a/src/components/SidebarSubmenu.tsx +++ b/src/components/SidebarSubmenu.tsx @@ -18,9 +18,6 @@ export function SidebarSubmenu({ submenu, onClick, }: SidebarSubmenuProps) { - const pathname = usePathname(); - const [isOpened, setIsOpened] = useState(); - const thisItem = { label, slug: submenu![0].slug, @@ -28,43 +25,26 @@ export function SidebarSubmenu({ breadcrumbs: [], }; - useEffect(() => { - if (pathname.includes('/guides/') && pathname !== '/guides/') { - setIsOpened(true); - } else { - let actualSlug = thisItem.slug; - if (!hasIndex) { - const split = thisItem.slug.split('/'); - split.pop(); - actualSlug = split.join('/'); - } - const active = pathname.startsWith(`/${actualSlug}/`); - setIsOpened(active); - } - }, [pathname]); - return ( - {isOpened && ( - - {submenu?.map((item, index) => { - if (!hasIndex || index > 0) { - return ( - - - - ); - } - })} - - )} + + {submenu?.map((item, index) => { + if (!hasIndex || index > 0) { + return ( + + + + ); + } + })} + ); }