@vuepress/client 2.0.0-rc.10 → 2.0.0-rc.12
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/dist/app.js +1 -1
- package/dist/{chunk-GA5RAHE7.js → chunk-ZQJPP2LC.js} +61 -77
- package/dist/index.d.ts +17 -102
- package/dist/index.js +3 -1
- package/package.json +2 -2
package/dist/app.js
CHANGED
|
@@ -60,30 +60,48 @@ if (__VUEPRESS_DEV__ && (import.meta.webpackHot || import.meta.hot)) {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
// src/router/resolveRoutePath.ts
|
|
63
|
-
var resolveRoutePath = (
|
|
64
|
-
const
|
|
65
|
-
if (routes.value[
|
|
66
|
-
return
|
|
67
|
-
const
|
|
68
|
-
if (routes.value[
|
|
69
|
-
return
|
|
70
|
-
|
|
63
|
+
var resolveRoutePath = (pathname, currentPath) => {
|
|
64
|
+
const normalizedRoutePath = normalizeRoutePath(pathname, currentPath);
|
|
65
|
+
if (routes.value[normalizedRoutePath])
|
|
66
|
+
return normalizedRoutePath;
|
|
67
|
+
const encodedRoutePath = encodeURI(normalizedRoutePath);
|
|
68
|
+
if (routes.value[encodedRoutePath]) {
|
|
69
|
+
return encodedRoutePath;
|
|
70
|
+
}
|
|
71
|
+
const redirectedRoutePath = redirects.value[normalizedRoutePath] || redirects.value[encodedRoutePath];
|
|
72
|
+
if (redirectedRoutePath) {
|
|
73
|
+
return redirectedRoutePath;
|
|
74
|
+
}
|
|
75
|
+
return normalizedRoutePath;
|
|
71
76
|
};
|
|
72
77
|
|
|
73
78
|
// src/router/resolveRoute.ts
|
|
79
|
+
import { splitPath } from "@vuepress/shared";
|
|
74
80
|
var resolveRoute = (path, currentPath) => {
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
const { pathname, hashAndQueries } = splitPath(path);
|
|
82
|
+
const routePath = resolveRoutePath(pathname, currentPath);
|
|
83
|
+
const routeFullPath = routePath + hashAndQueries;
|
|
84
|
+
if (!routes.value[routePath]) {
|
|
85
|
+
return {
|
|
86
|
+
...routes.value["/404.html"],
|
|
87
|
+
path: routeFullPath,
|
|
88
|
+
notFound: true
|
|
89
|
+
};
|
|
90
|
+
}
|
|
80
91
|
return {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
92
|
+
...routes.value[routePath],
|
|
93
|
+
path: routeFullPath,
|
|
94
|
+
notFound: false
|
|
84
95
|
};
|
|
85
96
|
};
|
|
86
97
|
|
|
98
|
+
// src/router/resolveRouteFullPath.ts
|
|
99
|
+
import { splitPath as splitPath2 } from "@vuepress/shared";
|
|
100
|
+
var resolveRouteFullPath = (path, currentPath) => {
|
|
101
|
+
const { pathname, hashAndQueries } = splitPath2(path);
|
|
102
|
+
return resolveRoutePath(pathname, currentPath) + hashAndQueries;
|
|
103
|
+
};
|
|
104
|
+
|
|
87
105
|
// src/router/index.ts
|
|
88
106
|
import { useRoute, useRouter } from "vue-router";
|
|
89
107
|
|
|
@@ -134,7 +152,7 @@ var RouteLink = defineComponent({
|
|
|
134
152
|
const router = useRouter2();
|
|
135
153
|
const route = useRoute2();
|
|
136
154
|
const path = computed(
|
|
137
|
-
() => props.to.startsWith("#") || props.to.startsWith("?") ? props.to : `${__VUEPRESS_BASE__}${
|
|
155
|
+
() => props.to.startsWith("#") || props.to.startsWith("?") ? props.to : `${__VUEPRESS_BASE__}${resolveRouteFullPath(props.to, route.path).substring(1)}`
|
|
138
156
|
);
|
|
139
157
|
return () => h(
|
|
140
158
|
"a",
|
|
@@ -154,105 +172,70 @@ var RouteLink = defineComponent({
|
|
|
154
172
|
|
|
155
173
|
// src/components/AutoLink.ts
|
|
156
174
|
import { isLinkWithProtocol } from "@vuepress/shared";
|
|
157
|
-
import { computed as computed2, defineComponent as defineComponent2, h as h2 } from "vue";
|
|
175
|
+
import { computed as computed2, defineComponent as defineComponent2, h as h2, toRef } from "vue";
|
|
158
176
|
import { useRoute as useRoute3 } from "vue-router";
|
|
159
177
|
var AutoLink = defineComponent2({
|
|
160
178
|
name: "AutoLink",
|
|
161
179
|
props: {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
*/
|
|
165
|
-
activeMatch: {
|
|
166
|
-
type: [String, RegExp],
|
|
167
|
-
default: ""
|
|
168
|
-
},
|
|
169
|
-
/**
|
|
170
|
-
* The `aria-label` attribute
|
|
171
|
-
*/
|
|
172
|
-
ariaLabel: {
|
|
173
|
-
type: String,
|
|
174
|
-
default: ""
|
|
175
|
-
},
|
|
176
|
-
/**
|
|
177
|
-
* Whether the link should be active only if the url is an exact match
|
|
178
|
-
*/
|
|
179
|
-
exact: Boolean,
|
|
180
|
-
/**
|
|
181
|
-
* URL of the auto link
|
|
182
|
-
*/
|
|
183
|
-
link: {
|
|
184
|
-
type: String,
|
|
185
|
-
required: true
|
|
186
|
-
},
|
|
187
|
-
/**
|
|
188
|
-
* The `rel` attribute
|
|
189
|
-
*/
|
|
190
|
-
rel: {
|
|
191
|
-
type: String,
|
|
192
|
-
default: ""
|
|
193
|
-
},
|
|
194
|
-
/**
|
|
195
|
-
* The `target` attribute
|
|
196
|
-
*/
|
|
197
|
-
target: {
|
|
198
|
-
type: String,
|
|
199
|
-
default: ""
|
|
200
|
-
},
|
|
201
|
-
/**
|
|
202
|
-
* Text of the auto link
|
|
203
|
-
*/
|
|
204
|
-
text: {
|
|
205
|
-
type: String,
|
|
180
|
+
config: {
|
|
181
|
+
type: Object,
|
|
206
182
|
required: true
|
|
207
183
|
}
|
|
208
184
|
},
|
|
209
185
|
slots: Object,
|
|
210
186
|
setup(props, { slots }) {
|
|
187
|
+
const config = toRef(props, "config");
|
|
211
188
|
const route = useRoute3();
|
|
212
189
|
const siteData = useSiteData();
|
|
213
|
-
const withProtocol = computed2(() => isLinkWithProtocol(
|
|
190
|
+
const withProtocol = computed2(() => isLinkWithProtocol(config.value.link));
|
|
214
191
|
const linkTarget = computed2(
|
|
215
|
-
() =>
|
|
192
|
+
() => config.value.target || (withProtocol.value ? "_blank" : void 0)
|
|
216
193
|
);
|
|
217
194
|
const isBlankTarget = computed2(() => linkTarget.value === "_blank");
|
|
218
195
|
const isInternal = computed2(
|
|
219
196
|
() => !withProtocol.value && !isBlankTarget.value
|
|
220
197
|
);
|
|
221
198
|
const linkRel = computed2(
|
|
222
|
-
() =>
|
|
199
|
+
() => config.value.rel || (isBlankTarget.value ? "noopener noreferrer" : null)
|
|
200
|
+
);
|
|
201
|
+
const linkAriaLabel = computed2(
|
|
202
|
+
() => config.value.ariaLabel ?? config.value.text
|
|
223
203
|
);
|
|
224
|
-
const linkAriaLabel = computed2(() => props.ariaLabel ?? props.text);
|
|
225
204
|
const shouldBeActiveInSubpath = computed2(() => {
|
|
226
|
-
if (
|
|
205
|
+
if (config.value.exact)
|
|
227
206
|
return false;
|
|
228
207
|
const localePaths = Object.keys(siteData.value.locales);
|
|
229
208
|
return localePaths.length ? (
|
|
230
209
|
// Check all the locales
|
|
231
|
-
localePaths.every((key) => key !==
|
|
210
|
+
localePaths.every((key) => key !== config.value.link)
|
|
232
211
|
) : (
|
|
233
212
|
// Check root
|
|
234
|
-
|
|
213
|
+
config.value.link !== "/"
|
|
235
214
|
);
|
|
236
215
|
});
|
|
237
216
|
const isActive = computed2(() => {
|
|
238
217
|
if (!isInternal.value)
|
|
239
218
|
return false;
|
|
240
|
-
if (
|
|
241
|
-
return (
|
|
219
|
+
if (config.value.activeMatch) {
|
|
220
|
+
return (config.value.activeMatch instanceof RegExp ? config.value.activeMatch : new RegExp(config.value.activeMatch, "u")).test(route.path);
|
|
242
221
|
}
|
|
243
222
|
if (shouldBeActiveInSubpath.value) {
|
|
244
|
-
return route.path.startsWith(
|
|
223
|
+
return route.path.startsWith(config.value.link);
|
|
245
224
|
}
|
|
246
|
-
return route.path ===
|
|
225
|
+
return route.path === config.value.link;
|
|
247
226
|
});
|
|
248
227
|
return () => {
|
|
249
228
|
const { before, after, default: defaultSlot } = slots;
|
|
250
|
-
const content = defaultSlot?.() || [
|
|
229
|
+
const content = defaultSlot?.(config.value) || [
|
|
230
|
+
before?.(config.value),
|
|
231
|
+
config.value.text,
|
|
232
|
+
after?.(config.value)
|
|
233
|
+
];
|
|
251
234
|
return isInternal.value ? h2(
|
|
252
235
|
RouteLink,
|
|
253
236
|
{
|
|
254
237
|
"class": "auto-link",
|
|
255
|
-
"to":
|
|
238
|
+
"to": config.value.link,
|
|
256
239
|
"active": isActive.value,
|
|
257
240
|
"aria-label": linkAriaLabel.value
|
|
258
241
|
},
|
|
@@ -261,7 +244,7 @@ var AutoLink = defineComponent2({
|
|
|
261
244
|
"a",
|
|
262
245
|
{
|
|
263
246
|
"class": "auto-link external-link",
|
|
264
|
-
"href":
|
|
247
|
+
"href": config.value.link,
|
|
265
248
|
"aria-label": linkAriaLabel.value,
|
|
266
249
|
"rel": linkRel.value,
|
|
267
250
|
"target": linkTarget.value
|
|
@@ -369,7 +352,7 @@ var resolvers = reactive({
|
|
|
369
352
|
/**
|
|
370
353
|
* Resolve locale path according to route path and locales config
|
|
371
354
|
*/
|
|
372
|
-
resolveRouteLocale: (locales, routePath) => resolveLocalePath(locales, routePath),
|
|
355
|
+
resolveRouteLocale: (locales, routePath) => resolveLocalePath(locales, decodeURI(routePath)),
|
|
373
356
|
/**
|
|
374
357
|
* Resolve site data for specific locale
|
|
375
358
|
*
|
|
@@ -420,6 +403,7 @@ export {
|
|
|
420
403
|
routes,
|
|
421
404
|
resolveRoutePath,
|
|
422
405
|
resolveRoute,
|
|
406
|
+
resolveRouteFullPath,
|
|
423
407
|
useRoute,
|
|
424
408
|
useRouter,
|
|
425
409
|
RouteLink,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
|
-
import { Component, ComputedRef, Ref, App, VNode, SlotsType, InjectionKey } from 'vue';
|
|
2
|
+
import { Component, ComputedRef, Ref, App, PropType, VNode, SlotsType, InjectionKey } from 'vue';
|
|
3
3
|
import { PageData, HeadConfig, PageFrontmatter, SiteData, SiteLocaleData } from '@vuepress/shared';
|
|
4
4
|
export { HeadConfig, PageData, PageFrontmatter, PageHeader, SiteData, SiteLocaleData } from '@vuepress/shared';
|
|
5
5
|
import { Router } from 'vue-router';
|
|
@@ -97,7 +97,7 @@ interface ClientConfig {
|
|
|
97
97
|
rootComponents?: Component[];
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
interface
|
|
100
|
+
interface AutoLinkConfig {
|
|
101
101
|
/**
|
|
102
102
|
* Pattern to determine if the link should be active, which has higher priority than `exact`
|
|
103
103
|
*/
|
|
@@ -134,111 +134,21 @@ interface AutoLinkProps {
|
|
|
134
134
|
* - If the link is external, it will be rendered as a normal `<a>` tag
|
|
135
135
|
*/
|
|
136
136
|
declare const AutoLink: vue.DefineComponent<{
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
*/
|
|
140
|
-
activeMatch: {
|
|
141
|
-
type: (StringConstructor | RegExpConstructor)[];
|
|
142
|
-
default: string;
|
|
143
|
-
};
|
|
144
|
-
/**
|
|
145
|
-
* The `aria-label` attribute
|
|
146
|
-
*/
|
|
147
|
-
ariaLabel: {
|
|
148
|
-
type: StringConstructor;
|
|
149
|
-
default: string;
|
|
150
|
-
};
|
|
151
|
-
/**
|
|
152
|
-
* Whether the link should be active only if the url is an exact match
|
|
153
|
-
*/
|
|
154
|
-
exact: BooleanConstructor;
|
|
155
|
-
/**
|
|
156
|
-
* URL of the auto link
|
|
157
|
-
*/
|
|
158
|
-
link: {
|
|
159
|
-
type: StringConstructor;
|
|
160
|
-
required: true;
|
|
161
|
-
};
|
|
162
|
-
/**
|
|
163
|
-
* The `rel` attribute
|
|
164
|
-
*/
|
|
165
|
-
rel: {
|
|
166
|
-
type: StringConstructor;
|
|
167
|
-
default: string;
|
|
168
|
-
};
|
|
169
|
-
/**
|
|
170
|
-
* The `target` attribute
|
|
171
|
-
*/
|
|
172
|
-
target: {
|
|
173
|
-
type: StringConstructor;
|
|
174
|
-
default: string;
|
|
175
|
-
};
|
|
176
|
-
/**
|
|
177
|
-
* Text of the auto link
|
|
178
|
-
*/
|
|
179
|
-
text: {
|
|
180
|
-
type: StringConstructor;
|
|
137
|
+
config: {
|
|
138
|
+
type: PropType<AutoLinkConfig>;
|
|
181
139
|
required: true;
|
|
182
140
|
};
|
|
183
141
|
}, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
184
142
|
[key: string]: any;
|
|
185
143
|
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
*/
|
|
189
|
-
activeMatch: {
|
|
190
|
-
type: (StringConstructor | RegExpConstructor)[];
|
|
191
|
-
default: string;
|
|
192
|
-
};
|
|
193
|
-
/**
|
|
194
|
-
* The `aria-label` attribute
|
|
195
|
-
*/
|
|
196
|
-
ariaLabel: {
|
|
197
|
-
type: StringConstructor;
|
|
198
|
-
default: string;
|
|
199
|
-
};
|
|
200
|
-
/**
|
|
201
|
-
* Whether the link should be active only if the url is an exact match
|
|
202
|
-
*/
|
|
203
|
-
exact: BooleanConstructor;
|
|
204
|
-
/**
|
|
205
|
-
* URL of the auto link
|
|
206
|
-
*/
|
|
207
|
-
link: {
|
|
208
|
-
type: StringConstructor;
|
|
209
|
-
required: true;
|
|
210
|
-
};
|
|
211
|
-
/**
|
|
212
|
-
* The `rel` attribute
|
|
213
|
-
*/
|
|
214
|
-
rel: {
|
|
215
|
-
type: StringConstructor;
|
|
216
|
-
default: string;
|
|
217
|
-
};
|
|
218
|
-
/**
|
|
219
|
-
* The `target` attribute
|
|
220
|
-
*/
|
|
221
|
-
target: {
|
|
222
|
-
type: StringConstructor;
|
|
223
|
-
default: string;
|
|
224
|
-
};
|
|
225
|
-
/**
|
|
226
|
-
* Text of the auto link
|
|
227
|
-
*/
|
|
228
|
-
text: {
|
|
229
|
-
type: StringConstructor;
|
|
144
|
+
config: {
|
|
145
|
+
type: PropType<AutoLinkConfig>;
|
|
230
146
|
required: true;
|
|
231
147
|
};
|
|
232
|
-
}>>, {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
exact: boolean;
|
|
237
|
-
rel: string;
|
|
238
|
-
}, SlotsType<{
|
|
239
|
-
default?: (() => VNode[] | VNode) | undefined;
|
|
240
|
-
before?: (() => VNode[] | VNode | null) | undefined;
|
|
241
|
-
after?: (() => VNode[] | VNode | null) | undefined;
|
|
148
|
+
}>>, {}, SlotsType<{
|
|
149
|
+
default?: ((config: AutoLinkConfig) => VNode[] | VNode) | undefined;
|
|
150
|
+
before?: ((config: AutoLinkConfig) => VNode[] | VNode | null) | undefined;
|
|
151
|
+
after?: ((config: AutoLinkConfig) => VNode[] | VNode | null) | undefined;
|
|
242
152
|
}>>;
|
|
243
153
|
|
|
244
154
|
/**
|
|
@@ -392,10 +302,15 @@ interface ResolvedRoute<T extends RouteMeta = RouteMeta> extends Route<T> {
|
|
|
392
302
|
*/
|
|
393
303
|
declare const resolveRoute: <T extends RouteMeta = RouteMeta>(path: string, currentPath?: string) => ResolvedRoute<T>;
|
|
394
304
|
|
|
305
|
+
/**
|
|
306
|
+
* Resolve route full path with given raw path
|
|
307
|
+
*/
|
|
308
|
+
declare const resolveRouteFullPath: (path: string, currentPath?: string) => string;
|
|
309
|
+
|
|
395
310
|
/**
|
|
396
311
|
* Resolve route path with given raw path
|
|
397
312
|
*/
|
|
398
|
-
declare const resolveRoutePath: (
|
|
313
|
+
declare const resolveRoutePath: (pathname: string, currentPath?: string) => string;
|
|
399
314
|
|
|
400
315
|
/**
|
|
401
316
|
* Resolver methods to get global computed
|
|
@@ -424,4 +339,4 @@ declare const defineClientConfig: (clientConfig?: ClientConfig) => ClientConfig;
|
|
|
424
339
|
*/
|
|
425
340
|
declare const withBase: (url: string) => string;
|
|
426
341
|
|
|
427
|
-
export { AutoLink, type
|
|
342
|
+
export { AutoLink, type AutoLinkConfig, type ClientConfig, type ClientData, ClientOnly, Content, type Layouts, type LayoutsRef, type PageChunk, type PageComponent, type PageComponentRef, type PageDataRef, type PageFrontmatterRef, type PageHead, type PageHeadRef, type PageHeadTitle, type PageHeadTitleRef, type PageLang, type PageLangRef, type PageLayout, type PageLayoutRef, type Redirects, type RedirectsRef, type ResolvedRoute, type Route, RouteLink, type RouteLinkProps, type RouteLocale, type RouteLocaleRef, type RouteMeta, type RoutePath, type RoutePathRef, type Routes, type RoutesRef, type SiteDataRef, type SiteLocaleDataRef, type UpdateHead, clientDataSymbol, defineClientConfig, resolveRoute, resolveRouteFullPath, resolveRoutePath, resolvers, updateHeadSymbol, useClientData, useLayouts, usePageComponent, usePageData, usePageFrontmatter, usePageHead, usePageLang, usePageLayout, useRedirects, useRouteLocale, useRoutePath, useRoutes, useSiteData, useSiteLocaleData, useUpdateHead, withBase };
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
clientDataSymbol,
|
|
7
7
|
defineClientConfig,
|
|
8
8
|
resolveRoute,
|
|
9
|
+
resolveRouteFullPath,
|
|
9
10
|
resolveRoutePath,
|
|
10
11
|
resolvers,
|
|
11
12
|
updateHeadSymbol,
|
|
@@ -27,7 +28,7 @@ import {
|
|
|
27
28
|
useSiteLocaleData,
|
|
28
29
|
useUpdateHead,
|
|
29
30
|
withBase
|
|
30
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-ZQJPP2LC.js";
|
|
31
32
|
export {
|
|
32
33
|
AutoLink,
|
|
33
34
|
ClientOnly,
|
|
@@ -36,6 +37,7 @@ export {
|
|
|
36
37
|
clientDataSymbol,
|
|
37
38
|
defineClientConfig,
|
|
38
39
|
resolveRoute,
|
|
40
|
+
resolveRouteFullPath,
|
|
39
41
|
resolveRoutePath,
|
|
40
42
|
resolvers,
|
|
41
43
|
updateHeadSymbol,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/client",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.12",
|
|
4
4
|
"description": "Client package of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@vue/devtools-api": "^6.6.1",
|
|
37
37
|
"vue": "^3.4.27",
|
|
38
38
|
"vue-router": "^4.3.2",
|
|
39
|
-
"@vuepress/shared": "2.0.0-rc.
|
|
39
|
+
"@vuepress/shared": "2.0.0-rc.12"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|