From edd8a0242397fda3899f5b5b2bf428cd9196c744 Mon Sep 17 00:00:00 2001 From: Valerio Ageno Date: Thu, 15 Aug 2024 21:12:02 +0200 Subject: [PATCH] fix: documentation type checking --- .../components/breadcrumbs/breadcrumbs.tsx | 16 +++--- .../src/components/sidebar/sidebar-link.tsx | 49 ++++++++++--------- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/apps/documentation/src/components/breadcrumbs/breadcrumbs.tsx b/apps/documentation/src/components/breadcrumbs/breadcrumbs.tsx index 847942a5..1d47d126 100644 --- a/apps/documentation/src/components/breadcrumbs/breadcrumbs.tsx +++ b/apps/documentation/src/components/breadcrumbs/breadcrumbs.tsx @@ -38,14 +38,16 @@ export function BreadcrumbElement({ href, label, }: BreadcrumbElementProps): JSX.Element { + if (href) { + return ( + + ) + } + return ( - ) diff --git a/apps/documentation/src/components/sidebar/sidebar-link.tsx b/apps/documentation/src/components/sidebar/sidebar-link.tsx index facab497..a1a662a5 100644 --- a/apps/documentation/src/components/sidebar/sidebar-link.tsx +++ b/apps/documentation/src/components/sidebar/sidebar-link.tsx @@ -18,28 +18,29 @@ export default function SidebarLink( const { pathname } = useRouter() const [isOpen, setIsOpen] = useState(!!props.defaultOpened) - return ( - { - e.preventDefault() - e.stopPropagation() - setIsOpen((state) => !state) - }} - /> - ) - } - opened={isOpen} - autoContrast - {...props} - /> - ) + const internalProps = { + active: pathname === props.href, + className: styles.link, + rightSection: props.children && ( + { + e.preventDefault() + e.stopPropagation() + setIsOpen((state) => !state) + }} + /> + ), + opened: isOpen, + autoContrast: true, + ...props, + } + + if (props.href.startsWith('#')) { + return + } + + return }