make the navigation sidebar on each version's landing page hidden by default. fixes #46.

This commit is contained in:
Hossein Mehrabi
2022-10-09 17:22:30 +03:30
parent 75ebaf8f06
commit 8705778d3a
3 changed files with 23 additions and 10 deletions
+11
View File
@@ -0,0 +1,11 @@
import { useActivePluginAndVersion } from '@docusaurus/plugin-content-docs/client'
export const useActiveVersionPath = () => {
const data = useActivePluginAndVersion({ failfast: false })
if (data) {
return data.activeVersion.path
}
return '/'
}
+9
View File
@@ -0,0 +1,9 @@
import { useLocation } from '@docusaurus/router'
import { useActiveVersionPath } from './useActiveVersionPath'
export const useIsVersionIndexPage = () => {
const { pathname } = useLocation()
const versionPath = useActiveVersionPath()
return pathname === versionPath
}
+3 -10
View File
@@ -1,19 +1,12 @@
import { useLocation } from '@docusaurus/router'
import useDocusaurusContext from '@docusaurus/useDocusaurusContext'
import { globalStore } from '@site/src/containers/GlobalStore'
import { useIsVersionIndexPage } from '@site/src/lib/useIsVersionIndexPage'
import Layout from '@theme-original/Layout'
import React from 'react'
import './styles.scss'
export default function LayoutWrapper(props) {
const { pathname } = useLocation()
const {
siteConfig: { baseUrl },
} = useDocusaurusContext()
const store = globalStore.useCreateStore({
hiddenSidebar: pathname === baseUrl,
})
const isIndexPage = useIsVersionIndexPage()
const store = globalStore.useCreateStore({ hiddenSidebar: isIndexPage })
return (
<globalStore.Provider store={store}>