diff --git a/components/Sidebar.tsx b/components/Sidebar.tsx index f034a1849..f48966ce0 100644 --- a/components/Sidebar.tsx +++ b/components/Sidebar.tsx @@ -16,18 +16,21 @@ const DocLink = ({ label, onClick, setOpen, + matchPaths, }: { uri: string; label: string | React.ReactNode; onClick?: () => void; setOpen: (open: boolean) => void; + matchPaths?: string[]; }) => { const router = useRouter(); const url = new URL(`${router.asPath}`, HOST); url.search = ''; url.hash = ''; const stringUrl = url.toString().substr(HOST.length, Infinity); - const isActive = uri === extractPathWithoutFragment(stringUrl); + const path = extractPathWithoutFragment(stringUrl); + const isActive = matchPaths ? matchPaths.includes(path) : uri === path; return ( { @@ -184,6 +198,8 @@ export const SidebarLayout = ({ children }: { children: React.ReactNode }) => { const handleRotate = () => setRotateChevron(!rotateChevron); const rotate = rotateChevron ? 'rotate(180deg)' : 'rotate(0)'; const pathWtihoutFragment = extractPathWithoutFragment(router.asPath); + const shouldHideSidebar = pathWtihoutFragment === '/md-style-guide'; + useEffect(() => { if (window) { window.addEventListener('resize', () => { @@ -254,16 +270,20 @@ export const SidebarLayout = ({ children }: { children: React.ReactNode }) => {