File tree Expand file tree Collapse file tree 2 files changed +10
-20
lines changed
packages/@vuepress/theme-default/src/client Expand file tree Collapse file tree 2 files changed +10
-20
lines changed Original file line number Diff line number Diff line change @@ -89,7 +89,12 @@ const renderChildren = (
89
89
export const SidebarChild : FunctionalComponent < {
90
90
item : ResolvedSidebarItem
91
91
depth ?: number
92
- } > = ( { item, depth = 0 } ) => {
92
+ } > = ( {
93
+ item,
94
+ // group depth should start from 0
95
+ // otherwise start from 1
96
+ depth = item . isGroup ? 0 : 1 ,
97
+ } ) => {
93
98
const route = useRoute ( )
94
99
const active = isActiveItem ( route , item )
95
100
@@ -134,6 +139,5 @@ SidebarChild.props = {
134
139
depth : {
135
140
type : Number ,
136
141
required : false ,
137
- default : 0 ,
138
142
} ,
139
143
}
Original file line number Diff line number Diff line change @@ -127,16 +127,16 @@ export const resolveArraySidebarItems = (
127
127
childItem = item as ResolvedSidebarItem
128
128
}
129
129
130
- if ( childItem . isGroup && childItem . children ) {
130
+ if ( childItem . children ) {
131
131
return {
132
132
...childItem ,
133
- children : childItem . children . map ( handleChildItem ) ,
133
+ children : childItem . children . map ( ( item ) => handleChildItem ( item ) ) ,
134
134
}
135
135
}
136
136
137
137
// if the sidebar item is current page and children is not set
138
138
// use headers of current page as children
139
- if ( childItem . link === route . path && childItem . children === undefined ) {
139
+ if ( childItem . link === route . path ) {
140
140
return {
141
141
...childItem ,
142
142
children : headersToSidebarItemChildren (
@@ -149,21 +149,7 @@ export const resolveArraySidebarItems = (
149
149
return childItem
150
150
}
151
151
152
- return sidebarConfig . map (
153
- ( item ) : ResolvedSidebarItem => {
154
- if ( isString ( item ) ) {
155
- return useNavLink ( item )
156
- }
157
- if ( ! item . isGroup ) {
158
- return item as ResolvedSidebarItem
159
- }
160
-
161
- return {
162
- ...item ,
163
- children : item . children . map ( handleChildItem ) ,
164
- }
165
- }
166
- )
152
+ return sidebarConfig . map ( ( item ) => handleChildItem ( item ) )
167
153
}
168
154
169
155
/**
You can’t perform that action at this time.
0 commit comments