File tree 7 files changed +18
-34
lines changed
7 files changed +18
-34
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ const sidebar: DefaultTheme.Config['sidebar'] = {
4
4
'/' : [
5
5
{
6
6
text : 'Frontmatter' ,
7
- collapsible : true ,
7
+ collapsed : false ,
8
8
items : [
9
9
{
10
10
text : 'Multiple Levels Outline' ,
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ function sidebarGuide() {
79
79
return [
80
80
{
81
81
text : 'Introduction' ,
82
- collapsible : true ,
82
+ collapsed : false ,
83
83
items : [
84
84
{ text : 'What is VitePress?' , link : '/guide/what-is-vitepress' } ,
85
85
{ text : 'Getting Started' , link : '/guide/getting-started' } ,
@@ -91,7 +91,7 @@ function sidebarGuide() {
91
91
} ,
92
92
{
93
93
text : 'Writing' ,
94
- collapsible : true ,
94
+ collapsed : false ,
95
95
items : [
96
96
{ text : 'Markdown' , link : '/guide/markdown' } ,
97
97
{ text : 'Asset Handling' , link : '/guide/asset-handling' } ,
@@ -102,7 +102,7 @@ function sidebarGuide() {
102
102
} ,
103
103
{
104
104
text : 'Theme' ,
105
- collapsible : true ,
105
+ collapsed : false ,
106
106
items : [
107
107
{ text : 'Introduction' , link : '/guide/theme-introduction' } ,
108
108
{ text : 'Nav' , link : '/guide/theme-nav' } ,
@@ -121,7 +121,7 @@ function sidebarGuide() {
121
121
} ,
122
122
{
123
123
text : 'Migrations' ,
124
- collapsible : true ,
124
+ collapsed : false ,
125
125
items : [
126
126
{
127
127
text : 'Migration from VuePress' ,
Original file line number Diff line number Diff line change @@ -147,16 +147,11 @@ export type SidebarItem = {
147
147
items? : SidebarItem []
148
148
149
149
/**
150
- * If `true`, toggle button is shown .
150
+ * If not specified, group is not collapsible .
151
151
*
152
- * @default false
153
- */
154
- collapsible? : boolean
155
-
156
- /**
157
- * If `true`, collapsible group is collapsed by default.
152
+ * If `true`, group is collapsible and collapsed by default
158
153
*
159
- * @default false
154
+ * If ` false`, group is collapsible but expanded by default
160
155
*/
161
156
collapsed? : boolean
162
157
}
Original file line number Diff line number Diff line change @@ -149,20 +149,15 @@ export default {
149
149
150
150
## Collapsible Sidebar Groups
151
151
152
- By adding ` collapsible ` option to the sidebar group, it shows a toggle button to hide/show each section.
152
+ By adding ` collapsed ` option to the sidebar group, it shows a toggle button to hide/show each section.
153
153
154
154
``` js
155
155
export default {
156
156
themeConfig: {
157
157
sidebar: [
158
158
{
159
159
text: ' Section Title A' ,
160
- collapsible: true ,
161
- items: [... ]
162
- },
163
- {
164
- text: ' Section Title B' ,
165
- collapsible: true ,
160
+ collapsed: false ,
166
161
items: [... ]
167
162
}
168
163
]
@@ -178,7 +173,6 @@ export default {
178
173
sidebar: [
179
174
{
180
175
text: ' Section Title A' ,
181
- collapsible: true ,
182
176
collapsed: true ,
183
177
items: [... ]
184
178
}
Original file line number Diff line number Diff line change @@ -59,8 +59,8 @@ function onCaretClick() {
59
59
<component :is =" textTag" class =" text" v-html =" item.text" />
60
60
</VPLink >
61
61
62
- <div class =" caret" role =" button" @click =" onCaretClick" >
63
- <VPIconChevronRight v-if = " item.collapsible " class =" caret-icon" />
62
+ <div v-if = " item.collapsed != null " class =" caret" role =" button" @click =" onCaretClick" >
63
+ <VPIconChevronRight class =" caret-icon" />
64
64
</div >
65
65
</div >
66
66
Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ export function useSidebarControl(
126
126
const collapsed = ref ( false )
127
127
128
128
const collapsible = computed ( ( ) => {
129
- return ! ! item . value . collapsible
129
+ return item . value . collapsed != null
130
130
} )
131
131
132
132
const isLink = computed ( ( ) => {
@@ -152,15 +152,15 @@ export function useSidebarControl(
152
152
} )
153
153
154
154
watchEffect ( ( ) => {
155
- collapsed . value = ! ! ( item . value . collapsible && item . value . collapsed )
155
+ collapsed . value = ! ! ( collapsible . value && item . value . collapsed )
156
156
} )
157
157
158
158
watchEffect ( ( ) => {
159
159
; ( isActiveLink . value || hasActiveLink . value ) && ( collapsed . value = false )
160
160
} )
161
161
162
162
function toggle ( ) {
163
- if ( item . value . collapsible ) {
163
+ if ( collapsible . value ) {
164
164
collapsed . value = ! collapsed . value
165
165
}
166
166
}
Original file line number Diff line number Diff line change @@ -183,16 +183,11 @@ export namespace DefaultTheme {
183
183
items ?: SidebarItem [ ]
184
184
185
185
/**
186
- * If `true`, toggle button is shown .
186
+ * If not specified, group is not collapsible .
187
187
*
188
- * @default false
189
- */
190
- collapsible ?: boolean
191
-
192
- /**
193
- * If `true`, collapsible group is collapsed by default.
188
+ * If `true`, group is collapsible and collapsed by default
194
189
*
195
- * @default false
190
+ * If ` false`, group is collapsible but expanded by default
196
191
*/
197
192
collapsed ?: boolean
198
193
}
You can’t perform that action at this time.
0 commit comments