feat(sidebar): use base when creating link (#74)

pull/77/head
Carlos Rodrigues 4 years ago committed by GitHub
parent 092ee772da
commit 79bc9fb15a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +1,9 @@
import { usePageData, useRoute, useSiteDataByRoute } from 'vitepress' import {
usePageData,
useRoute,
useSiteDataByRoute,
useSiteData
} from 'vitepress'
import { computed, h, FunctionalComponent, VNode } from 'vue' import { computed, h, FunctionalComponent, VNode } from 'vue'
import { Header } from '../../../../types/shared' import { Header } from '../../../../types/shared'
import { isActive, getPathDirName } from '../utils' import { isActive, getPathDirName } from '../utils'
@ -9,12 +14,14 @@ const SideBarItem: FunctionalComponent<{
item: ResolvedSidebarItem item: ResolvedSidebarItem
}> = (props) => { }> = (props) => {
const { const {
item: { link, text, children } item: { link: relLink, text, children }
} = props } = props
const route = useRoute() const route = useRoute()
const pageData = usePageData() const pageData = usePageData()
const siteData = useSiteData()
const link = `${siteData.value.base}${relLink || ''}`
const active = isActive(route, link) const active = isActive(route, link)
const headers = pageData.value.headers const headers = pageData.value.headers

Loading…
Cancel
Save