@vuepress/theme-default 2.0.0-rc.20 → 2.0.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client/components/AutoLink.vue +11 -7
- package/lib/client/components/PageNav.vue +105 -11
- package/lib/client/composables/index.d.ts +1 -0
- package/lib/client/composables/index.js +1 -0
- package/lib/client/composables/useNavigate.d.ts +1 -0
- package/lib/client/composables/useNavigate.js +25 -0
- package/lib/client/styles/arrow.scss +18 -24
- package/lib/client/styles/page.scss +0 -27
- package/lib/shared/options.d.ts +8 -0
- package/package.json +19 -19
|
@@ -90,9 +90,11 @@ const isActive = computed(() => {
|
|
|
90
90
|
:aria-label="linkAriaLabel"
|
|
91
91
|
v-bind="$attrs"
|
|
92
92
|
>
|
|
93
|
-
<slot
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
<slot>
|
|
94
|
+
<slot name="before" />
|
|
95
|
+
{{ item.text }}
|
|
96
|
+
<slot name="after" />
|
|
97
|
+
</slot>
|
|
96
98
|
</RouteLink>
|
|
97
99
|
<a
|
|
98
100
|
v-else
|
|
@@ -103,9 +105,11 @@ const isActive = computed(() => {
|
|
|
103
105
|
:aria-label="linkAriaLabel"
|
|
104
106
|
v-bind="$attrs"
|
|
105
107
|
>
|
|
106
|
-
<slot
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
<slot>
|
|
109
|
+
<slot name="before" />
|
|
110
|
+
{{ item.text }}
|
|
111
|
+
<AutoLinkExternalIcon v-if="isBlankTarget" />
|
|
112
|
+
<slot name="after" />
|
|
113
|
+
</slot>
|
|
110
114
|
</a>
|
|
111
115
|
</template>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import AutoLink from '@theme/AutoLink.vue'
|
|
3
|
+
import { useEventListener } from '@vueuse/core'
|
|
3
4
|
import { computed } from 'vue'
|
|
4
5
|
import type { Router } from 'vuepress/client'
|
|
5
6
|
import { usePageFrontmatter, useRoute, useRouter } from 'vuepress/client'
|
|
@@ -9,7 +10,11 @@ import type {
|
|
|
9
10
|
NavLink,
|
|
10
11
|
ResolvedSidebarItem,
|
|
11
12
|
} from '../../shared/index.js'
|
|
12
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
useNavigate,
|
|
15
|
+
useSidebarItems,
|
|
16
|
+
useThemeLocaleData,
|
|
17
|
+
} from '../composables/index.js'
|
|
13
18
|
import { getNavLink } from '../utils/index.js'
|
|
14
19
|
|
|
15
20
|
/**
|
|
@@ -69,8 +74,10 @@ const resolveFromSidebarItems = (
|
|
|
69
74
|
|
|
70
75
|
const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
|
|
71
76
|
const sidebarItems = useSidebarItems()
|
|
77
|
+
const themeLocale = useThemeLocaleData()
|
|
72
78
|
const route = useRoute()
|
|
73
79
|
const router = useRouter()
|
|
80
|
+
const navigate = useNavigate()
|
|
74
81
|
|
|
75
82
|
const prevNavLink = computed(() => {
|
|
76
83
|
const prevConfig = resolveFromFrontmatterConfig(
|
|
@@ -100,22 +107,109 @@ const navbarLabel = computed(() => {
|
|
|
100
107
|
const themeLocale = useThemeLocaleData()
|
|
101
108
|
return themeLocale.value.pageNavbarLabel ?? 'page navigation'
|
|
102
109
|
})
|
|
110
|
+
|
|
111
|
+
useEventListener('keydown', (event): void => {
|
|
112
|
+
if (event.altKey)
|
|
113
|
+
if (event.key === 'ArrowRight') {
|
|
114
|
+
if (nextNavLink.value) {
|
|
115
|
+
navigate(nextNavLink.value.link)
|
|
116
|
+
event.preventDefault()
|
|
117
|
+
}
|
|
118
|
+
} else if (event.key === 'ArrowLeft') {
|
|
119
|
+
if (prevNavLink.value) {
|
|
120
|
+
navigate(prevNavLink.value.link)
|
|
121
|
+
event.preventDefault()
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
})
|
|
103
125
|
</script>
|
|
104
126
|
|
|
105
127
|
<template>
|
|
106
128
|
<nav
|
|
107
129
|
v-if="prevNavLink || nextNavLink"
|
|
108
|
-
class="page-nav"
|
|
130
|
+
class="vp-page-nav"
|
|
109
131
|
:aria-label="navbarLabel"
|
|
110
132
|
>
|
|
111
|
-
<
|
|
112
|
-
<
|
|
113
|
-
<
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
<
|
|
117
|
-
<
|
|
118
|
-
</
|
|
119
|
-
</
|
|
133
|
+
<AutoLink v-if="prevNavLink" class="prev" :item="prevNavLink">
|
|
134
|
+
<div class="hint">
|
|
135
|
+
<span class="arrow left" />
|
|
136
|
+
{{ themeLocale.prev ?? 'Prev' }}
|
|
137
|
+
</div>
|
|
138
|
+
<div class="link">
|
|
139
|
+
<span>{{ prevNavLink.text }}</span>
|
|
140
|
+
</div>
|
|
141
|
+
</AutoLink>
|
|
142
|
+
|
|
143
|
+
<AutoLink v-if="nextNavLink" class="next" :item="nextNavLink">
|
|
144
|
+
<div class="hint">
|
|
145
|
+
{{ themeLocale.next ?? 'Next' }}
|
|
146
|
+
<span class="arrow right" />
|
|
147
|
+
</div>
|
|
148
|
+
<div class="link">
|
|
149
|
+
<span>{{ nextNavLink.text }}</span>
|
|
150
|
+
</div>
|
|
151
|
+
</AutoLink>
|
|
120
152
|
</nav>
|
|
121
153
|
</template>
|
|
154
|
+
|
|
155
|
+
<style lang="scss">
|
|
156
|
+
@import '../styles/_variables';
|
|
157
|
+
|
|
158
|
+
.vp-page-nav {
|
|
159
|
+
display: flex;
|
|
160
|
+
flex-wrap: wrap;
|
|
161
|
+
|
|
162
|
+
max-width: var(--content-width, 740px);
|
|
163
|
+
min-height: 2rem;
|
|
164
|
+
margin-inline: auto;
|
|
165
|
+
margin-top: 0;
|
|
166
|
+
padding-block: 0.5rem;
|
|
167
|
+
padding-inline: 2rem;
|
|
168
|
+
border-top: 1px solid var(--c-border);
|
|
169
|
+
|
|
170
|
+
transition: border-top var(--t-color);
|
|
171
|
+
|
|
172
|
+
@media (max-width: $MQNarrow) {
|
|
173
|
+
padding-inline: 1rem;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
@media print {
|
|
177
|
+
display: none;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
padding-top: 1rem;
|
|
181
|
+
padding-bottom: 0;
|
|
182
|
+
|
|
183
|
+
@media print {
|
|
184
|
+
display: none;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.route-link {
|
|
188
|
+
display: inline-block;
|
|
189
|
+
flex-grow: 1;
|
|
190
|
+
|
|
191
|
+
margin: 0.25rem;
|
|
192
|
+
padding: 0.25rem 0.5rem;
|
|
193
|
+
border: 1px solid var(--c-border);
|
|
194
|
+
border-radius: 0.25rem;
|
|
195
|
+
|
|
196
|
+
&:hover {
|
|
197
|
+
background: var(--c-bg-light);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.hint {
|
|
201
|
+
color: var(--c-text-quote);
|
|
202
|
+
font-size: 0.875rem;
|
|
203
|
+
line-height: 2;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.prev {
|
|
208
|
+
text-align: start;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.next {
|
|
212
|
+
text-align: end;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useNavigate: () => (url: string) => void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { isLinkAbsolute, isLinkWithProtocol } from '@vuepress/helper/client';
|
|
2
|
+
import { useRoute, useRouter } from 'vuepress/client';
|
|
3
|
+
const FAKE_HOST = 'http://.';
|
|
4
|
+
export const useNavigate = () => {
|
|
5
|
+
const router = useRouter();
|
|
6
|
+
const route = useRoute();
|
|
7
|
+
return (url) => {
|
|
8
|
+
if (url)
|
|
9
|
+
if (isLinkAbsolute(url)) {
|
|
10
|
+
// Inner absolute path
|
|
11
|
+
if (route.path !== url)
|
|
12
|
+
router.push(url);
|
|
13
|
+
}
|
|
14
|
+
else if (isLinkWithProtocol(url)) {
|
|
15
|
+
// Outer url
|
|
16
|
+
if (window)
|
|
17
|
+
window.open(url);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
// Inner relative path
|
|
21
|
+
const loc = route.path.slice(0, route.path.lastIndexOf('/'));
|
|
22
|
+
router.push(new URL(`${loc}/${encodeURI(url)}`, FAKE_HOST).pathname);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -1,37 +1,31 @@
|
|
|
1
1
|
.arrow {
|
|
2
2
|
display: inline-block;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
vertical-align: middle;
|
|
4
|
+
|
|
5
|
+
width: 1em;
|
|
6
|
+
height: 1em;
|
|
7
|
+
|
|
8
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='rgba(0,0,0,0.5)' d='M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z'/%3E%3C/svg%3E");
|
|
9
|
+
background-position: center;
|
|
10
|
+
background-repeat: no-repeat;
|
|
11
|
+
|
|
12
|
+
line-height: normal;
|
|
13
|
+
|
|
14
|
+
transition: all 0.3s;
|
|
15
|
+
|
|
16
|
+
html.dark & {
|
|
17
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='rgba(255,255,255,0.5)' d='M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z'/%3E%3C/svg%3E");
|
|
12
18
|
}
|
|
13
19
|
|
|
14
20
|
&.down {
|
|
15
|
-
|
|
16
|
-
left: 4px solid transparent;
|
|
17
|
-
right: 4px solid transparent;
|
|
18
|
-
top: 6px solid var(--c-bg-arrow);
|
|
19
|
-
}
|
|
21
|
+
transform: rotate(180deg);
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
&.right {
|
|
23
|
-
|
|
24
|
-
top: 4px solid transparent;
|
|
25
|
-
bottom: 4px solid transparent;
|
|
26
|
-
left: 6px solid var(--c-bg-arrow);
|
|
27
|
-
}
|
|
25
|
+
transform: rotate(90deg);
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
&.left {
|
|
31
|
-
|
|
32
|
-
top: 4px solid transparent;
|
|
33
|
-
bottom: 4px solid transparent;
|
|
34
|
-
right: 6px solid var(--c-bg-arrow);
|
|
35
|
-
}
|
|
29
|
+
transform: rotate(-90deg);
|
|
36
30
|
}
|
|
37
31
|
}
|
|
@@ -58,30 +58,3 @@
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
.page-nav {
|
|
63
|
-
@include content_wrapper;
|
|
64
|
-
padding-top: 1rem;
|
|
65
|
-
padding-bottom: 0;
|
|
66
|
-
|
|
67
|
-
.inner {
|
|
68
|
-
min-height: 2rem;
|
|
69
|
-
margin-top: 0;
|
|
70
|
-
border-top: 1px solid var(--c-border);
|
|
71
|
-
transition: border-color var(--t-color);
|
|
72
|
-
padding-top: 1rem;
|
|
73
|
-
overflow: auto;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.prev {
|
|
77
|
-
a:before {
|
|
78
|
-
content: '←';
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
.next {
|
|
82
|
-
float: right;
|
|
83
|
-
a:after {
|
|
84
|
-
content: '→';
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
package/lib/shared/options.d.ts
CHANGED
|
@@ -276,4 +276,12 @@ export interface DefaultThemeLocaleData extends LocaleData {
|
|
|
276
276
|
* A11y text for sidebar toggle button
|
|
277
277
|
*/
|
|
278
278
|
toggleSidebar?: string;
|
|
279
|
+
/**
|
|
280
|
+
* text for prev link
|
|
281
|
+
*/
|
|
282
|
+
prev?: string;
|
|
283
|
+
/**
|
|
284
|
+
* text for next link
|
|
285
|
+
*/
|
|
286
|
+
next?: string;
|
|
279
287
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/theme-default",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.21",
|
|
4
4
|
"description": "Default theme of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress-theme",
|
|
@@ -42,28 +42,28 @@
|
|
|
42
42
|
"copy": "cpx \"src/**/*.{d.ts,vue,scss}\" lib"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@vuepress/helper": "~2.0.0-rc.
|
|
46
|
-
"@vuepress/plugin-active-header-links": "~2.0.0-rc.
|
|
47
|
-
"@vuepress/plugin-back-to-top": "~2.0.0-rc.
|
|
48
|
-
"@vuepress/plugin-container": "~2.0.0-rc.
|
|
49
|
-
"@vuepress/plugin-copy-code": "~2.0.0-rc.
|
|
50
|
-
"@vuepress/plugin-external-link-icon": "~2.0.0-rc.
|
|
51
|
-
"@vuepress/plugin-git": "~2.0.0-rc.
|
|
52
|
-
"@vuepress/plugin-links-check": "~2.0.0-rc.
|
|
53
|
-
"@vuepress/plugin-medium-zoom": "~2.0.0-rc.
|
|
54
|
-
"@vuepress/plugin-nprogress": "~2.0.0-rc.
|
|
55
|
-
"@vuepress/plugin-palette": "~2.0.0-rc.
|
|
56
|
-
"@vuepress/plugin-prismjs": "~2.0.0-rc.
|
|
57
|
-
"@vuepress/plugin-seo": "~2.0.0-rc.
|
|
58
|
-
"@vuepress/plugin-sitemap": "~2.0.0-rc.
|
|
59
|
-
"@vuepress/plugin-theme-data": "~2.0.0-rc.
|
|
45
|
+
"@vuepress/helper": "~2.0.0-rc.21",
|
|
46
|
+
"@vuepress/plugin-active-header-links": "~2.0.0-rc.21",
|
|
47
|
+
"@vuepress/plugin-back-to-top": "~2.0.0-rc.21",
|
|
48
|
+
"@vuepress/plugin-container": "~2.0.0-rc.21",
|
|
49
|
+
"@vuepress/plugin-copy-code": "~2.0.0-rc.21",
|
|
50
|
+
"@vuepress/plugin-external-link-icon": "~2.0.0-rc.21",
|
|
51
|
+
"@vuepress/plugin-git": "~2.0.0-rc.21",
|
|
52
|
+
"@vuepress/plugin-links-check": "~2.0.0-rc.21",
|
|
53
|
+
"@vuepress/plugin-medium-zoom": "~2.0.0-rc.21",
|
|
54
|
+
"@vuepress/plugin-nprogress": "~2.0.0-rc.21",
|
|
55
|
+
"@vuepress/plugin-palette": "~2.0.0-rc.21",
|
|
56
|
+
"@vuepress/plugin-prismjs": "~2.0.0-rc.21",
|
|
57
|
+
"@vuepress/plugin-seo": "~2.0.0-rc.21",
|
|
58
|
+
"@vuepress/plugin-sitemap": "~2.0.0-rc.21",
|
|
59
|
+
"@vuepress/plugin-theme-data": "~2.0.0-rc.21",
|
|
60
60
|
"@vueuse/core": "^10.9.0",
|
|
61
|
-
"sass": "^1.
|
|
61
|
+
"sass": "^1.72.0",
|
|
62
62
|
"vue": "^3.4.21"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"sass-loader": "^14.0.0",
|
|
66
|
-
"vuepress": "2.0.0-rc.
|
|
66
|
+
"vuepress": "2.0.0-rc.9"
|
|
67
67
|
},
|
|
68
68
|
"peerDependenciesMeta": {
|
|
69
69
|
"sass-loader": {
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"publishConfig": {
|
|
74
74
|
"access": "public"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "014780ab182c15249ac9d27cee31d080f9ac01cd"
|
|
77
77
|
}
|