-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: render context-aware version dropdown (#235)
Switches version dropdown based on currently active docs. ## Demo https://github.com/user-attachments/assets/acddcbad-6450-4038-92dd-0cf10b3e96b4
- Loading branch information
1 parent
0d3201f
commit 4c4ad0b
Showing
2 changed files
with
27 additions
and
5 deletions.
There are no files selected for viewing
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
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,22 @@ | ||
import React from 'react'; | ||
import {useActiveDocContext} from '@docusaurus/plugin-content-docs/client'; | ||
import DocsVersionDropdownNavbarItem from '@theme-original/NavbarItem/DocsVersionDropdownNavbarItem'; | ||
|
||
import type DocsVersionDropdownNavbarItemType from '@theme/NavbarItem/DocsVersionDropdownNavbarItem'; | ||
import type {WrapperProps} from '@docusaurus/types'; | ||
|
||
type Props = WrapperProps<typeof DocsVersionDropdownNavbarItemType>; | ||
|
||
export default function DocsVersionDropdownNavbarItemWrapper(props: Props): JSX.Element { | ||
const activeDocContext = useActiveDocContext(props.docsPluginId); | ||
|
||
if (!activeDocContext?.activeDoc) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<> | ||
<DocsVersionDropdownNavbarItem {...props} /> | ||
</> | ||
); | ||
} |