Skip to content

Commit

Permalink
API docs V2 only, no version dropdown (#506)
Browse files Browse the repository at this point in the history
  • Loading branch information
laliconfigcat authored Nov 27, 2024
1 parent 59aaa12 commit 2a6122b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions website/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx
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} />;
}

0 comments on commit 2a6122b

Please sign in to comment.