-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API docs V2 only, no version dropdown (#506)
- Loading branch information
1 parent
59aaa12
commit 2a6122b
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
website/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react'; | ||
import DocsVersionDropdownNavbarItem from '@theme-original/NavbarItem/DocsVersionDropdownNavbarItem'; | ||
import type DocsVersionDropdownNavbarItemType from '@theme/NavbarItem/DocsVersionDropdownNavbarItem'; | ||
import type { WrapperProps } from '@docusaurus/types'; | ||
import { useLocation } from '@docusaurus/router'; | ||
|
||
type Props = WrapperProps<typeof DocsVersionDropdownNavbarItemType>; | ||
|
||
export default function DocsVersionDropdownNavbarItemWrapper(props: Props): JSX.Element { | ||
const location = useLocation(); | ||
|
||
const unversionedRoutes = [ | ||
// any route that starts with `/docs/api` | ||
/^\/docs\/api\/.*$/g, | ||
// If we want to disable it on the sdk reference too | ||
// /^\/docs\/sdk-reference\/.*$/g | ||
] | ||
|
||
function checkPathname(pathname) { | ||
// Check if the provided pathname matches any of the regexes in the list | ||
return unversionedRoutes.some(regex => regex.test(pathname)) | ||
} | ||
|
||
if (checkPathname(location.pathname)) { | ||
return null; | ||
} | ||
|
||
return <DocsVersionDropdownNavbarItem {...props} />; | ||
} |