|
|
@ -1,15 +1,22 @@
|
|
|
|
<script lang="ts" setup generic="T extends DefaultTheme.NavItemWithLink">
|
|
|
|
<script lang="ts" setup generic="T extends DefaultTheme.NavItemWithLink">
|
|
|
|
import type { DefaultTheme } from 'vitepress/theme'
|
|
|
|
import type { DefaultTheme } from 'vitepress/theme'
|
|
|
|
|
|
|
|
import { computed } from 'vue'
|
|
|
|
import { useData } from '../composables/data'
|
|
|
|
import { useData } from '../composables/data'
|
|
|
|
import { isActive } from '../../shared'
|
|
|
|
import { isActive } from '../../shared'
|
|
|
|
import VPLink from './VPLink.vue'
|
|
|
|
import VPLink from './VPLink.vue'
|
|
|
|
|
|
|
|
|
|
|
|
defineProps<{
|
|
|
|
const props = defineProps<{
|
|
|
|
item: T
|
|
|
|
item: T
|
|
|
|
}>()
|
|
|
|
}>()
|
|
|
|
|
|
|
|
|
|
|
|
const { page } = useData()
|
|
|
|
const { page } = useData()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const href = computed(() =>
|
|
|
|
|
|
|
|
typeof props.item.link === 'function'
|
|
|
|
|
|
|
|
? props.item.link(page.value)
|
|
|
|
|
|
|
|
: props.item.link
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
defineOptions({ inheritAttrs: false })
|
|
|
|
defineOptions({ inheritAttrs: false })
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
@ -20,11 +27,11 @@ defineOptions({ inheritAttrs: false })
|
|
|
|
:class="{
|
|
|
|
:class="{
|
|
|
|
active: isActive(
|
|
|
|
active: isActive(
|
|
|
|
page.relativePath,
|
|
|
|
page.relativePath,
|
|
|
|
item.activeMatch || item.link,
|
|
|
|
item.activeMatch || href,
|
|
|
|
!!item.activeMatch
|
|
|
|
!!item.activeMatch
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}"
|
|
|
|
}"
|
|
|
|
:href="item.link"
|
|
|
|
:href
|
|
|
|
:target="item.target"
|
|
|
|
:target="item.target"
|
|
|
|
:rel="item.rel"
|
|
|
|
:rel="item.rel"
|
|
|
|
:no-icon="item.noIcon"
|
|
|
|
:no-icon="item.noIcon"
|
|
|
|