File tree 1 file changed +17
-2
lines changed
src/client/theme-default/components
1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change 1
1
<script lang="ts" setup>
2
2
import type { DefaultTheme } from ' vitepress/theme'
3
+ import { computed } from ' vue'
3
4
import { useData } from ' ../composables/data'
4
5
import { isActive } from ' ../../shared'
5
6
import VPFlyout from ' ./VPFlyout.vue'
6
7
7
- defineProps <{
8
+ const props = defineProps <{
8
9
item: DefaultTheme .NavItemWithChildren
9
10
}>()
10
11
11
12
const { page } = useData ()
13
+
14
+ const isChildActive = (navItem : DefaultTheme .NavItem ) => {
15
+ if (' link' in navItem ) {
16
+ return isActive (
17
+ page .value .relativePath ,
18
+ navItem .link ,
19
+ !! props .item .activeMatch
20
+ )
21
+ } else {
22
+ return navItem .items .some (isChildActive )
23
+ }
24
+ }
25
+
26
+ const childrenActive = computed (() => isChildActive (props .item ))
12
27
</script >
13
28
14
29
<template >
@@ -19,7 +34,7 @@ const { page } = useData()
19
34
page.relativePath,
20
35
item.activeMatch,
21
36
!!item.activeMatch
22
- )
37
+ ) || childrenActive
23
38
}"
24
39
:button =" item.text"
25
40
:items =" item.items"
You can’t perform that action at this time.
0 commit comments