docs: hide sidebar button on pages with no sidebar (#4158)

This commit is contained in:
Shahed Nasser
2023-05-23 17:31:03 +03:00
committed by GitHub
parent ddc90db530
commit 8b83bf94b6
3 changed files with 5 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
import { createContext } from "react"
type SidebarContextType = {
hasSidebar: boolean
hiddenSidebar: boolean
setHiddenSidebar: (value: boolean) => void
hiddenSidebarContainer: boolean

View File

@@ -91,6 +91,8 @@ export default function DocPage(props: Props): JSX.Element {
}
})
console.log(sidebarName)
return (
<>
<DocPageMetadata {...props} />
@@ -107,6 +109,7 @@ export default function DocPage(props: Props): JSX.Element {
<DocsSidebarProvider name={sidebarName} items={sidebarItems}>
<SidebarContext.Provider
value={{
hasSidebar: sidebarName !== undefined,
hiddenSidebar,
setHiddenSidebar,
hiddenSidebarContainer,

View File

@@ -84,7 +84,7 @@ export default function NavbarContent(): JSX.Element {
<>
{!mobileSidebar.disabled && <NavbarMobileSidebarToggle />}
<NavbarLogo />
{hideable && (
{hideable && sidebarContext?.hasSidebar && (
<NavbarActions
items={[
{