feat: add support for setting sidebarDepth in themeConfig

pull/495/head
Divyansh Singh 4 years ago
parent 4109acf67e
commit ee1d960412

@ -15,7 +15,10 @@ export const SideBarLink: FunctionalComponent<{
const route = useRoute() const route = useRoute()
const { site, frontmatter } = useData() const { site, frontmatter } = useData()
const depth = props.depth || 1 const depth = props.depth || 1
const maxDepth = frontmatter.value.sidebarDepth || Infinity const maxDepth =
frontmatter.value.sidebarDepth ||
site.value.themeConfig.sidebarDepth ||
Infinity
const headers = route.data.headers const headers = route.data.headers
const text = props.item.text const text = props.item.text

@ -15,7 +15,8 @@ export function useSideBar() {
// at first, we'll check if we can find the sidebar setting in frontmatter. // at first, we'll check if we can find the sidebar setting in frontmatter.
const headers = route.data.headers const headers = route.data.headers
const frontSidebar = route.data.frontmatter.sidebar const frontSidebar = route.data.frontmatter.sidebar
const sidebarDepth = route.data.frontmatter.sidebarDepth const sidebarDepth =
route.data.frontmatter.sidebarDepth || site.value.themeConfig.sidebarDepth
// if it's `false`, we'll just return an empty array here. // if it's `false`, we'll just return an empty array here.
if (frontSidebar === false) { if (frontSidebar === false) {

@ -3,6 +3,7 @@ export namespace DefaultTheme {
logo?: string logo?: string
nav?: NavItem[] | false nav?: NavItem[] | false
sidebar?: SideBarConfig | MultiSideBarConfig sidebar?: SideBarConfig | MultiSideBarConfig
sidebarDepth?: number
/** /**
* GitHub repository following the format <user>/<project>. * GitHub repository following the format <user>/<project>.

Loading…
Cancel
Save