mirror of
https://github.com/wavetermdev/docusaurus-og.git
synced 2026-08-05 13:46:35 -07:00
make the navigation sidebar on each version's landing page hidden by default. fixes #46.
This commit is contained in:
@@ -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 '/'
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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}>
|
||||
|
||||
Reference in New Issue
Block a user