5
5
@touchstart =" onTouchStart"
6
6
@touchend =" onTouchEnd"
7
7
>
8
- <Navbar
9
- v-if =" shouldShowNavbar"
10
- @toggle-sidebar =" toggleSidebar"
11
- />
12
-
13
- <div
14
- class =" sidebar-mask"
15
- @click =" toggleSidebar(false)"
16
- />
17
-
18
- <Sidebar
19
- :items =" sidebarItems"
20
- @toggle-sidebar =" toggleSidebar"
21
- >
8
+ <BetaBanner />
9
+ <Navbar v-if =" shouldShowNavbar" @toggle-sidebar =" toggleSidebar" />
10
+
11
+ <div class =" sidebar-mask" @click =" toggleSidebar(false)" />
12
+
13
+ <Sidebar :items =" sidebarItems" @toggle-sidebar =" toggleSidebar" >
22
14
<template #top >
23
15
<slot name =" sidebar-top" />
24
16
</template >
29
21
30
22
<Home v-if =" $page.frontmatter.home" />
31
23
32
- <Page
33
- v-else
34
- :sidebar-items =" sidebarItems"
35
- >
24
+ <Page v-else :sidebar-items =" sidebarItems" >
36
25
<template #top >
37
26
<slot name =" page-top" />
38
27
</template >
@@ -60,40 +49,38 @@ export default {
60
49
Navbar
61
50
},
62
51
63
- data () {
52
+ data () {
64
53
return {
65
54
isSidebarOpen: false
66
55
}
67
56
},
68
57
69
58
computed: {
70
- shouldShowNavbar () {
59
+ shouldShowNavbar () {
71
60
const { themeConfig } = this .$site
72
61
const { frontmatter } = this .$page
73
- if (
74
- frontmatter .navbar === false
75
- || themeConfig .navbar === false ) {
62
+ if (frontmatter .navbar === false || themeConfig .navbar === false ) {
76
63
return false
77
64
}
78
65
return (
79
- this .$title
80
- || themeConfig .logo
81
- || themeConfig .repo
82
- || themeConfig .nav
83
- || this .$themeLocaleConfig .nav
66
+ this .$title ||
67
+ themeConfig .logo ||
68
+ themeConfig .repo ||
69
+ themeConfig .nav ||
70
+ this .$themeLocaleConfig .nav
84
71
)
85
72
},
86
73
87
- shouldShowSidebar () {
74
+ shouldShowSidebar () {
88
75
const { frontmatter } = this .$page
89
76
return (
90
- ! frontmatter .home
91
- && frontmatter .sidebar !== false
92
- && this .sidebarItems .length
77
+ ! frontmatter .home &&
78
+ frontmatter .sidebar !== false &&
79
+ this .sidebarItems .length
93
80
)
94
81
},
95
82
96
- sidebarItems () {
83
+ sidebarItems () {
97
84
return resolveSidebarItems (
98
85
this .$page ,
99
86
this .$page .regularPath ,
@@ -102,7 +89,7 @@ export default {
102
89
)
103
90
},
104
91
105
- pageClasses () {
92
+ pageClasses () {
106
93
const userPageClass = this .$page .frontmatter .pageClass
107
94
return [
108
95
{
@@ -115,27 +102,27 @@ export default {
115
102
}
116
103
},
117
104
118
- mounted () {
105
+ mounted () {
119
106
this .$router .afterEach (() => {
120
107
this .isSidebarOpen = false
121
108
})
122
109
},
123
110
124
111
methods: {
125
- toggleSidebar (to ) {
112
+ toggleSidebar (to ) {
126
113
this .isSidebarOpen = typeof to === ' boolean' ? to : ! this .isSidebarOpen
127
114
this .$emit (' toggle-sidebar' , this .isSidebarOpen )
128
115
},
129
116
130
117
// side swipe
131
- onTouchStart (e ) {
118
+ onTouchStart (e ) {
132
119
this .touchStart = {
133
120
x: e .changedTouches [0 ].clientX ,
134
121
y: e .changedTouches [0 ].clientY
135
122
}
136
123
},
137
124
138
- onTouchEnd (e ) {
125
+ onTouchEnd (e ) {
139
126
const dx = e .changedTouches [0 ].clientX - this .touchStart .x
140
127
const dy = e .changedTouches [0 ].clientY - this .touchStart .y
141
128
if (Math .abs (dx) > Math .abs (dy) && Math .abs (dx) > 40 ) {
0 commit comments