@vuepress/client 2.0.0-rc.2 → 2.0.0-rc.3
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 +30 -57
- package/dist/{chunk-PEQEPZ75.js → chunk-2SMBJWK6.js} +140 -85
- package/dist/index.d.ts +48 -37
- package/dist/index.js +15 -7
- package/package.json +3 -5
package/dist/app.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ClientOnly,
|
|
3
3
|
Content,
|
|
4
|
+
VPLink,
|
|
4
5
|
layoutsSymbol,
|
|
5
6
|
pageDataSymbol,
|
|
6
7
|
pageFrontmatterSymbol,
|
|
@@ -8,9 +9,10 @@ import {
|
|
|
8
9
|
pageHeadTitleSymbol,
|
|
9
10
|
pageLangSymbol,
|
|
10
11
|
pageLayoutSymbol,
|
|
11
|
-
|
|
12
|
+
resolveRoute,
|
|
12
13
|
resolvers,
|
|
13
14
|
routeLocaleSymbol,
|
|
15
|
+
routes,
|
|
14
16
|
siteData,
|
|
15
17
|
siteLocaleDataSymbol,
|
|
16
18
|
updateHeadSymbol,
|
|
@@ -18,15 +20,14 @@ import {
|
|
|
18
20
|
usePageLang,
|
|
19
21
|
usePageLayout,
|
|
20
22
|
withBase
|
|
21
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-2SMBJWK6.js";
|
|
22
24
|
|
|
23
25
|
// src/app.ts
|
|
24
26
|
import { clientConfigs } from "@internal/clientConfigs";
|
|
25
27
|
import { createApp, createSSRApp, h as h2 } from "vue";
|
|
26
28
|
import { RouterView } from "vue-router";
|
|
27
29
|
|
|
28
|
-
// src/
|
|
29
|
-
import { pagesComponents } from "@internal/pagesComponents";
|
|
30
|
+
// src/createVueRouter.ts
|
|
30
31
|
import { removeEndingSlash } from "@vuepress/shared";
|
|
31
32
|
import {
|
|
32
33
|
createMemoryHistory,
|
|
@@ -35,9 +36,6 @@ import {
|
|
|
35
36
|
START_LOCATION
|
|
36
37
|
} from "vue-router";
|
|
37
38
|
|
|
38
|
-
// src/routes.ts
|
|
39
|
-
import { pagesRoutes } from "@internal/pagesRoutes";
|
|
40
|
-
|
|
41
39
|
// src/components/Vuepress.ts
|
|
42
40
|
import { defineComponent, h } from "vue";
|
|
43
41
|
var Vuepress = defineComponent({
|
|
@@ -48,53 +46,20 @@ var Vuepress = defineComponent({
|
|
|
48
46
|
}
|
|
49
47
|
});
|
|
50
48
|
|
|
51
|
-
// src/
|
|
52
|
-
var createRoutes = () => pagesRoutes.reduce(
|
|
53
|
-
(result, [name, path, meta, redirects]) => {
|
|
54
|
-
result.push(
|
|
55
|
-
{
|
|
56
|
-
name,
|
|
57
|
-
path,
|
|
58
|
-
component: Vuepress,
|
|
59
|
-
meta
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
path: path.endsWith("/") ? (
|
|
63
|
-
// redirect from `/index.html` to `/`
|
|
64
|
-
path + "index.html"
|
|
65
|
-
) : (
|
|
66
|
-
// redirect from `/foo` to `/foo.html`
|
|
67
|
-
path.substring(0, path.length - 5)
|
|
68
|
-
),
|
|
69
|
-
redirect: path
|
|
70
|
-
},
|
|
71
|
-
...redirects.map((item) => ({
|
|
72
|
-
path: item === ":md" ? (
|
|
73
|
-
// redirect from `/foo.md` to `/foo.html`
|
|
74
|
-
path.substring(0, path.length - 5) + ".md"
|
|
75
|
-
) : item,
|
|
76
|
-
redirect: path
|
|
77
|
-
}))
|
|
78
|
-
);
|
|
79
|
-
return result;
|
|
80
|
-
},
|
|
81
|
-
[
|
|
82
|
-
{
|
|
83
|
-
name: "404",
|
|
84
|
-
path: "/:catchAll(.*)",
|
|
85
|
-
component: Vuepress
|
|
86
|
-
}
|
|
87
|
-
]
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
// src/router.ts
|
|
49
|
+
// src/createVueRouter.ts
|
|
91
50
|
var historyCreator = __VUEPRESS_SSR__ ? createMemoryHistory : createWebHistory;
|
|
92
51
|
var createVueRouter = () => {
|
|
93
52
|
const router = createRouter({
|
|
94
53
|
// it might be an issue of vue-router that have to remove the ending slash
|
|
95
54
|
history: historyCreator(removeEndingSlash(__VUEPRESS_BASE__)),
|
|
96
|
-
routes:
|
|
97
|
-
|
|
55
|
+
routes: [
|
|
56
|
+
{
|
|
57
|
+
name: "vuepress-route",
|
|
58
|
+
path: "/:catchAll(.*)",
|
|
59
|
+
component: Vuepress
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
scrollBehavior: (to, _from, savedPosition) => {
|
|
98
63
|
if (savedPosition)
|
|
99
64
|
return savedPosition;
|
|
100
65
|
if (to.hash)
|
|
@@ -104,11 +69,17 @@ var createVueRouter = () => {
|
|
|
104
69
|
});
|
|
105
70
|
router.beforeResolve(async (to, from) => {
|
|
106
71
|
if (to.path !== from.path || from === START_LOCATION) {
|
|
107
|
-
;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
72
|
+
const route = resolveRoute(to.path);
|
|
73
|
+
if (route.path !== to.path) {
|
|
74
|
+
return route.path;
|
|
75
|
+
}
|
|
76
|
+
const pageChunk = await route.loader();
|
|
77
|
+
to.meta = {
|
|
78
|
+
// attach route meta
|
|
79
|
+
...route.meta,
|
|
80
|
+
// attach page data to route meta to trigger page data computed when route changes
|
|
81
|
+
_data: pageChunk.data
|
|
82
|
+
};
|
|
112
83
|
}
|
|
113
84
|
});
|
|
114
85
|
return router;
|
|
@@ -118,6 +89,7 @@ var createVueRouter = () => {
|
|
|
118
89
|
var setupGlobalComponents = (app) => {
|
|
119
90
|
app.component("ClientOnly", ClientOnly);
|
|
120
91
|
app.component("Content", Content);
|
|
92
|
+
app.component("VPLink", VPLink);
|
|
121
93
|
};
|
|
122
94
|
|
|
123
95
|
// src/setupGlobalComputed.ts
|
|
@@ -130,9 +102,10 @@ var setupGlobalComputed = (app, router, clientConfigs2) => {
|
|
|
130
102
|
() => router.currentRoute.value.meta._data
|
|
131
103
|
);
|
|
132
104
|
if (__VUEPRESS_DEV__ && (import.meta.webpackHot || import.meta.hot)) {
|
|
133
|
-
__VUE_HMR_RUNTIME__.updatePageData = (data) => {
|
|
134
|
-
|
|
135
|
-
|
|
105
|
+
__VUE_HMR_RUNTIME__.updatePageData = async (data) => {
|
|
106
|
+
const pageChunk = await routes.value[data.path].loader();
|
|
107
|
+
routes.value[data.path].loader = () => Promise.resolve({ comp: pageChunk.comp, data });
|
|
108
|
+
if (data.path === router.currentRoute.value.meta._data?.path) {
|
|
136
109
|
router.currentRoute.value.meta._data = data;
|
|
137
110
|
pageData.trigger();
|
|
138
111
|
}
|
|
@@ -12,18 +12,10 @@ var useLayouts = () => {
|
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
// src/composables/pageData.ts
|
|
15
|
-
import { inject as inject2
|
|
15
|
+
import { inject as inject2 } from "vue";
|
|
16
16
|
var pageDataSymbol = Symbol(
|
|
17
17
|
__VUEPRESS_DEV__ ? "pageData" : ""
|
|
18
18
|
);
|
|
19
|
-
var pageDataEmpty = readonly({
|
|
20
|
-
key: "",
|
|
21
|
-
path: "",
|
|
22
|
-
title: "",
|
|
23
|
-
lang: "",
|
|
24
|
-
frontmatter: {},
|
|
25
|
-
headers: []
|
|
26
|
-
});
|
|
27
19
|
var usePageData = () => {
|
|
28
20
|
const pageData = inject2(pageDataSymbol);
|
|
29
21
|
if (!pageData) {
|
|
@@ -97,12 +89,6 @@ var usePageLayout = () => {
|
|
|
97
89
|
return pageLayout;
|
|
98
90
|
};
|
|
99
91
|
|
|
100
|
-
// src/composables/pagesData.ts
|
|
101
|
-
import { pagesData as pagesDataRaw } from "@internal/pagesData";
|
|
102
|
-
import { ref } from "vue";
|
|
103
|
-
var pagesData = ref(pagesDataRaw);
|
|
104
|
-
var usePagesData = () => pagesData;
|
|
105
|
-
|
|
106
92
|
// src/composables/routeLocale.ts
|
|
107
93
|
import { inject as inject8 } from "vue";
|
|
108
94
|
var routeLocaleSymbol = Symbol(
|
|
@@ -116,10 +102,57 @@ var useRouteLocale = () => {
|
|
|
116
102
|
return routeLocale;
|
|
117
103
|
};
|
|
118
104
|
|
|
105
|
+
// src/router/routes.ts
|
|
106
|
+
import {
|
|
107
|
+
redirects as redirectsRaw,
|
|
108
|
+
routes as routesRaw
|
|
109
|
+
} from "@internal/routes";
|
|
110
|
+
import { shallowRef } from "vue";
|
|
111
|
+
var redirects = shallowRef(redirectsRaw);
|
|
112
|
+
var routes = shallowRef(routesRaw);
|
|
113
|
+
if (__VUEPRESS_DEV__ && (import.meta.webpackHot || import.meta.hot)) {
|
|
114
|
+
__VUE_HMR_RUNTIME__.updateRoutes = (data) => {
|
|
115
|
+
routes.value = data;
|
|
116
|
+
};
|
|
117
|
+
__VUE_HMR_RUNTIME__.updateRedirects = (data) => {
|
|
118
|
+
redirects.value = data;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// src/router/resolveRoutePath.ts
|
|
123
|
+
import { normalizeRoutePath } from "@vuepress/shared";
|
|
124
|
+
var resolveRoutePath = (path) => {
|
|
125
|
+
const normalizedPath = normalizeRoutePath(path);
|
|
126
|
+
if (routes.value[normalizedPath])
|
|
127
|
+
return normalizedPath;
|
|
128
|
+
const encodedPath = encodeURI(normalizedPath);
|
|
129
|
+
if (routes.value[encodedPath])
|
|
130
|
+
return encodedPath;
|
|
131
|
+
return redirects.value[normalizedPath] || normalizedPath;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// src/router/resolveRoute.ts
|
|
135
|
+
var resolveRoute = (path) => {
|
|
136
|
+
const routePath = resolveRoutePath(path);
|
|
137
|
+
const route = routes.value[routePath] ?? {
|
|
138
|
+
...routes.value["/404.html"],
|
|
139
|
+
notFound: true
|
|
140
|
+
};
|
|
141
|
+
return {
|
|
142
|
+
path: routePath,
|
|
143
|
+
notFound: false,
|
|
144
|
+
...route
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// src/composables/routes.ts
|
|
149
|
+
var useRedirects = () => redirects;
|
|
150
|
+
var useRoutes = () => routes;
|
|
151
|
+
|
|
119
152
|
// src/composables/siteData.ts
|
|
120
153
|
import { siteData as siteDataRaw } from "@internal/siteData";
|
|
121
|
-
import {
|
|
122
|
-
var siteData =
|
|
154
|
+
import { shallowRef as shallowRef2 } from "vue";
|
|
155
|
+
var siteData = shallowRef2(siteDataRaw);
|
|
123
156
|
var useSiteData = () => siteData;
|
|
124
157
|
if (__VUEPRESS_DEV__ && (import.meta.webpackHot || import.meta.hot)) {
|
|
125
158
|
__VUE_HMR_RUNTIME__.updateSiteData = (data) => {
|
|
@@ -153,6 +186,87 @@ var useUpdateHead = () => {
|
|
|
153
186
|
return updateHead;
|
|
154
187
|
};
|
|
155
188
|
|
|
189
|
+
// src/components/ClientOnly.ts
|
|
190
|
+
import { defineComponent, onMounted, ref } from "vue";
|
|
191
|
+
var ClientOnly = defineComponent({
|
|
192
|
+
name: "ClientOnly",
|
|
193
|
+
setup(_, ctx) {
|
|
194
|
+
const isMounted = ref(false);
|
|
195
|
+
onMounted(() => {
|
|
196
|
+
isMounted.value = true;
|
|
197
|
+
});
|
|
198
|
+
return () => isMounted.value ? ctx.slots.default?.() : null;
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
// src/components/Content.ts
|
|
203
|
+
import { computed, defineAsyncComponent, defineComponent as defineComponent2, h } from "vue";
|
|
204
|
+
var Content = defineComponent2({
|
|
205
|
+
// eslint-disable-next-line vue/no-reserved-component-names
|
|
206
|
+
name: "Content",
|
|
207
|
+
props: {
|
|
208
|
+
path: {
|
|
209
|
+
type: String,
|
|
210
|
+
required: false,
|
|
211
|
+
default: ""
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
setup(props) {
|
|
215
|
+
const pageData = usePageData();
|
|
216
|
+
const pageComponent = computed(() => {
|
|
217
|
+
const route = resolveRoute(props.path || pageData.value.path);
|
|
218
|
+
return defineAsyncComponent(() => route.loader().then(({ comp }) => comp));
|
|
219
|
+
});
|
|
220
|
+
return () => h(pageComponent.value);
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
// src/helpers/defineClientConfig.ts
|
|
225
|
+
var defineClientConfig = (clientConfig = {}) => clientConfig;
|
|
226
|
+
|
|
227
|
+
// src/helpers/withBase.ts
|
|
228
|
+
import { isLinkHttp, removeLeadingSlash } from "@vuepress/shared";
|
|
229
|
+
var withBase = (url) => {
|
|
230
|
+
if (isLinkHttp(url))
|
|
231
|
+
return url;
|
|
232
|
+
return `${__VUEPRESS_BASE__}${removeLeadingSlash(url)}`;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// src/components/VPLink.ts
|
|
236
|
+
import { h as h2 } from "vue";
|
|
237
|
+
import { useRouter } from "vue-router";
|
|
238
|
+
var guardEvent = (event) => {
|
|
239
|
+
if (event.metaKey || event.altKey || event.ctrlKey || event.shiftKey)
|
|
240
|
+
return;
|
|
241
|
+
if (event.defaultPrevented)
|
|
242
|
+
return;
|
|
243
|
+
if (event.button !== void 0 && event.button !== 0)
|
|
244
|
+
return;
|
|
245
|
+
if (event.currentTarget) {
|
|
246
|
+
const target = event.currentTarget.getAttribute("target");
|
|
247
|
+
if (target?.match(/\b_blank\b/i))
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
event.preventDefault();
|
|
251
|
+
return true;
|
|
252
|
+
};
|
|
253
|
+
var VPLink = ({ to = "" }, { slots }) => {
|
|
254
|
+
const router = useRouter();
|
|
255
|
+
const path = withBase(resolveRoutePath(to));
|
|
256
|
+
return h2(
|
|
257
|
+
"a",
|
|
258
|
+
{
|
|
259
|
+
class: "vp-link",
|
|
260
|
+
href: path,
|
|
261
|
+
onClick: (event = {}) => {
|
|
262
|
+
guardEvent(event) ? router.push(to).catch() : Promise.resolve();
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
slots.default?.()
|
|
266
|
+
);
|
|
267
|
+
};
|
|
268
|
+
VPLink.displayName = "VPLink";
|
|
269
|
+
|
|
156
270
|
// src/resolvers.ts
|
|
157
271
|
import { dedupeHead, isString, resolveLocalePath } from "@vuepress/shared";
|
|
158
272
|
import { reactive } from "vue";
|
|
@@ -173,14 +287,6 @@ var resolvers = reactive({
|
|
|
173
287
|
}),
|
|
174
288
|
{}
|
|
175
289
|
),
|
|
176
|
-
/**
|
|
177
|
-
* Resolve page data according to page key
|
|
178
|
-
*/
|
|
179
|
-
resolvePageData: async (pageKey) => {
|
|
180
|
-
const pageDataResolver = pagesData.value[pageKey];
|
|
181
|
-
const pageData = await pageDataResolver?.();
|
|
182
|
-
return pageData ?? pageDataEmpty;
|
|
183
|
-
},
|
|
184
290
|
/**
|
|
185
291
|
* Resolve page frontmatter from page data
|
|
186
292
|
*/
|
|
@@ -250,66 +356,10 @@ var resolvers = reactive({
|
|
|
250
356
|
})
|
|
251
357
|
});
|
|
252
358
|
|
|
253
|
-
// src/components/ClientOnly.ts
|
|
254
|
-
import { defineComponent, onMounted, ref as ref3 } from "vue";
|
|
255
|
-
var ClientOnly = defineComponent({
|
|
256
|
-
name: "ClientOnly",
|
|
257
|
-
setup(_, ctx) {
|
|
258
|
-
const isMounted = ref3(false);
|
|
259
|
-
onMounted(() => {
|
|
260
|
-
isMounted.value = true;
|
|
261
|
-
});
|
|
262
|
-
return () => isMounted.value ? ctx.slots.default?.() : null;
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
// src/components/Content.ts
|
|
267
|
-
import { pagesComponents } from "@internal/pagesComponents";
|
|
268
|
-
import { computed, defineComponent as defineComponent2, h } from "vue";
|
|
269
|
-
var Content = defineComponent2({
|
|
270
|
-
// eslint-disable-next-line vue/no-reserved-component-names
|
|
271
|
-
name: "Content",
|
|
272
|
-
props: {
|
|
273
|
-
pageKey: {
|
|
274
|
-
type: String,
|
|
275
|
-
required: false,
|
|
276
|
-
default: ""
|
|
277
|
-
}
|
|
278
|
-
},
|
|
279
|
-
setup(props) {
|
|
280
|
-
const page = usePageData();
|
|
281
|
-
const pageComponent = computed(
|
|
282
|
-
() => pagesComponents[props.pageKey || page.value.key]
|
|
283
|
-
);
|
|
284
|
-
return () => pageComponent.value ? (
|
|
285
|
-
// use page component
|
|
286
|
-
h(pageComponent.value)
|
|
287
|
-
) : (
|
|
288
|
-
// fallback content
|
|
289
|
-
h(
|
|
290
|
-
"div",
|
|
291
|
-
__VUEPRESS_DEV__ ? "Page does not exist. This is a fallback content." : "404 Not Found"
|
|
292
|
-
)
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
// src/helpers/defineClientConfig.ts
|
|
298
|
-
var defineClientConfig = (clientConfig = {}) => clientConfig;
|
|
299
|
-
|
|
300
|
-
// src/helpers/withBase.ts
|
|
301
|
-
import { isLinkHttp, removeLeadingSlash } from "@vuepress/shared";
|
|
302
|
-
var withBase = (url) => {
|
|
303
|
-
if (isLinkHttp(url))
|
|
304
|
-
return url;
|
|
305
|
-
return `${__VUEPRESS_BASE__}${removeLeadingSlash(url)}`;
|
|
306
|
-
};
|
|
307
|
-
|
|
308
359
|
export {
|
|
309
360
|
layoutsSymbol,
|
|
310
361
|
useLayouts,
|
|
311
362
|
pageDataSymbol,
|
|
312
|
-
pageDataEmpty,
|
|
313
363
|
usePageData,
|
|
314
364
|
pageFrontmatterSymbol,
|
|
315
365
|
usePageFrontmatter,
|
|
@@ -321,19 +371,24 @@ export {
|
|
|
321
371
|
usePageLang,
|
|
322
372
|
pageLayoutSymbol,
|
|
323
373
|
usePageLayout,
|
|
324
|
-
pagesData,
|
|
325
|
-
usePagesData,
|
|
326
374
|
routeLocaleSymbol,
|
|
327
375
|
useRouteLocale,
|
|
376
|
+
redirects,
|
|
377
|
+
routes,
|
|
378
|
+
resolveRoutePath,
|
|
379
|
+
resolveRoute,
|
|
380
|
+
useRedirects,
|
|
381
|
+
useRoutes,
|
|
328
382
|
siteData,
|
|
329
383
|
useSiteData,
|
|
330
384
|
siteLocaleDataSymbol,
|
|
331
385
|
useSiteLocaleData,
|
|
332
386
|
updateHeadSymbol,
|
|
333
387
|
useUpdateHead,
|
|
334
|
-
resolvers,
|
|
335
388
|
ClientOnly,
|
|
336
389
|
Content,
|
|
337
390
|
defineClientConfig,
|
|
338
|
-
withBase
|
|
391
|
+
withBase,
|
|
392
|
+
VPLink,
|
|
393
|
+
resolvers
|
|
339
394
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { PageData, PageFrontmatter, HeadConfig, SiteData } from '@vuepress/shared';
|
|
2
2
|
export { PageData, PageFrontmatter, PageHeader, SiteData } from '@vuepress/shared';
|
|
3
3
|
import * as vue from 'vue';
|
|
4
|
-
import { ComputedRef, InjectionKey, Ref, Component, App } from 'vue';
|
|
5
|
-
import {
|
|
4
|
+
import { ComputedRef, InjectionKey, Ref, Component, App, FunctionalComponent, VNode } from 'vue';
|
|
5
|
+
import { Redirects, Routes, PageMetaDefault, Route } from '@internal/routes';
|
|
6
|
+
export { PageChunk, PageMetaDefault, Redirects, Route, Routes } from '@internal/routes';
|
|
7
|
+
import { Router } from 'vue-router';
|
|
6
8
|
export { C as CreateVueAppFunction } from './createVueAppFunction-YNGNKfE3.js';
|
|
7
9
|
|
|
8
10
|
/**
|
|
@@ -26,10 +28,6 @@ type PageDataRef<T extends Record<any, any> = Record<never, never>> = Ref<PageDa
|
|
|
26
28
|
* Injection key for page data
|
|
27
29
|
*/
|
|
28
30
|
declare const pageDataSymbol: InjectionKey<PageDataRef>;
|
|
29
|
-
/**
|
|
30
|
-
* Empty page data to be used as the fallback value
|
|
31
|
-
*/
|
|
32
|
-
declare const pageDataEmpty: PageData;
|
|
33
31
|
/**
|
|
34
32
|
* Returns the ref of the data of current page
|
|
35
33
|
*/
|
|
@@ -113,41 +111,53 @@ declare const pageLayoutSymbol: InjectionKey<PageLayoutRef>;
|
|
|
113
111
|
declare const usePageLayout: () => ComputedRef<Component>;
|
|
114
112
|
|
|
115
113
|
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
* The key is page key, and the value is an async function that
|
|
119
|
-
* returns the page data
|
|
114
|
+
* Route locale path
|
|
120
115
|
*/
|
|
121
|
-
type
|
|
116
|
+
type RouteLocale = string;
|
|
122
117
|
/**
|
|
123
|
-
* Ref wrapper of `
|
|
118
|
+
* Ref wrapper of `RouteLocale`
|
|
124
119
|
*/
|
|
125
|
-
type
|
|
120
|
+
type RouteLocaleRef = Readonly<Ref<RouteLocale>>;
|
|
126
121
|
/**
|
|
127
|
-
*
|
|
122
|
+
* Injection key for page route locale path
|
|
128
123
|
*/
|
|
129
|
-
declare const
|
|
124
|
+
declare const routeLocaleSymbol: InjectionKey<RouteLocaleRef>;
|
|
130
125
|
/**
|
|
131
|
-
* Returns the ref of
|
|
126
|
+
* Returns the ref of the route locale path of current page
|
|
132
127
|
*/
|
|
133
|
-
declare const
|
|
128
|
+
declare const useRouteLocale: () => RouteLocaleRef;
|
|
134
129
|
|
|
135
130
|
/**
|
|
136
|
-
*
|
|
131
|
+
* Global redirects ref
|
|
137
132
|
*/
|
|
138
|
-
|
|
133
|
+
declare const redirects: Ref<Redirects>;
|
|
139
134
|
/**
|
|
140
|
-
*
|
|
135
|
+
* Global routes ref
|
|
141
136
|
*/
|
|
142
|
-
|
|
137
|
+
declare const routes: Ref<Routes>;
|
|
138
|
+
|
|
139
|
+
interface ResolvedRoute<PageMeta extends PageMetaDefault = PageMetaDefault> extends Route<PageMeta> {
|
|
140
|
+
path: string;
|
|
141
|
+
notFound: boolean;
|
|
142
|
+
}
|
|
143
143
|
/**
|
|
144
|
-
*
|
|
144
|
+
* Resolve route with given path
|
|
145
145
|
*/
|
|
146
|
-
declare const
|
|
146
|
+
declare const resolveRoute: <PageMeta extends PageMetaDefault = PageMetaDefault>(path: string) => ResolvedRoute<PageMeta>;
|
|
147
|
+
|
|
147
148
|
/**
|
|
148
|
-
*
|
|
149
|
+
* Resolve route path with given raw path
|
|
149
150
|
*/
|
|
150
|
-
declare const
|
|
151
|
+
declare const resolveRoutePath: (path: string) => string;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Returns the ref of pages map
|
|
155
|
+
*/
|
|
156
|
+
declare const useRedirects: () => typeof redirects;
|
|
157
|
+
/**
|
|
158
|
+
* Returns the ref of routes map
|
|
159
|
+
*/
|
|
160
|
+
declare const useRoutes: () => typeof routes;
|
|
151
161
|
|
|
152
162
|
/**
|
|
153
163
|
* Ref wrapper of `SiteData`
|
|
@@ -221,13 +231,6 @@ interface ClientConfig {
|
|
|
221
231
|
rootComponents?: Component[];
|
|
222
232
|
}
|
|
223
233
|
|
|
224
|
-
type PageRouteItem = [
|
|
225
|
-
name: string,
|
|
226
|
-
path: string,
|
|
227
|
-
meta: RouteMeta,
|
|
228
|
-
redirects: string[]
|
|
229
|
-
];
|
|
230
|
-
|
|
231
234
|
declare const ClientOnly: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
232
235
|
[key: string]: any;
|
|
233
236
|
}>[] | null | undefined, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{}>>, {}, {}>;
|
|
@@ -236,7 +239,7 @@ declare const ClientOnly: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNo
|
|
|
236
239
|
* Markdown rendered content
|
|
237
240
|
*/
|
|
238
241
|
declare const Content: vue.DefineComponent<{
|
|
239
|
-
|
|
242
|
+
path: {
|
|
240
243
|
type: StringConstructor;
|
|
241
244
|
required: false;
|
|
242
245
|
default: string;
|
|
@@ -244,15 +247,22 @@ declare const Content: vue.DefineComponent<{
|
|
|
244
247
|
}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
245
248
|
[key: string]: any;
|
|
246
249
|
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
247
|
-
|
|
250
|
+
path: {
|
|
248
251
|
type: StringConstructor;
|
|
249
252
|
required: false;
|
|
250
253
|
default: string;
|
|
251
254
|
};
|
|
252
255
|
}>>, {
|
|
253
|
-
|
|
256
|
+
path: string;
|
|
254
257
|
}, {}>;
|
|
255
258
|
|
|
259
|
+
interface VPLinkProps {
|
|
260
|
+
to: string;
|
|
261
|
+
}
|
|
262
|
+
declare const VPLink: FunctionalComponent<VPLinkProps, Record<never, never>, {
|
|
263
|
+
default: () => string | VNode | (string | VNode)[];
|
|
264
|
+
}>;
|
|
265
|
+
|
|
256
266
|
/**
|
|
257
267
|
* A helper function to help you define vuepress client config file
|
|
258
268
|
*/
|
|
@@ -267,10 +277,11 @@ declare const withBase: (url: string) => string;
|
|
|
267
277
|
* Resolver methods to get global computed
|
|
268
278
|
*
|
|
269
279
|
* Users can override corresponding method for advanced customization
|
|
280
|
+
*
|
|
281
|
+
* @experimental - This is an experimental API and may be changed in minor versions
|
|
270
282
|
*/
|
|
271
283
|
declare const resolvers: {
|
|
272
284
|
resolveLayouts: (clientConfigs: ClientConfig[]) => Layouts;
|
|
273
|
-
resolvePageData: (pageKey: string) => Promise<PageData>;
|
|
274
285
|
resolvePageFrontmatter: (pageData: PageData) => PageFrontmatter;
|
|
275
286
|
resolvePageHead: (headTitle: PageHeadTitle, frontmatter: PageFrontmatter, siteLocale: SiteLocaleData) => PageHead;
|
|
276
287
|
resolvePageHeadTitle: (page: PageData, siteLocale: SiteLocaleData) => PageHeadTitle;
|
|
@@ -280,4 +291,4 @@ declare const resolvers: {
|
|
|
280
291
|
resolveSiteLocaleData: (site: SiteData, routeLocale: RouteLocale) => SiteLocaleData;
|
|
281
292
|
};
|
|
282
293
|
|
|
283
|
-
export { type ClientConfig, ClientOnly, Content, type Layouts, type LayoutsRef, type PageDataRef, type PageFrontmatterRef, type PageHead, type PageHeadRef, type PageHeadTitle, type PageHeadTitleRef, type PageLang, type PageLangRef, type PageLayoutRef, type
|
|
294
|
+
export { type ClientConfig, ClientOnly, Content, type Layouts, type LayoutsRef, type PageDataRef, type PageFrontmatterRef, type PageHead, type PageHeadRef, type PageHeadTitle, type PageHeadTitleRef, type PageLang, type PageLangRef, type PageLayoutRef, type RouteLocale, type RouteLocaleRef, type SiteDataRef, type SiteLocaleData, type SiteLocaleDataRef, type UpdateHead, VPLink, type VPLinkProps, defineClientConfig, layoutsSymbol, pageDataSymbol, pageFrontmatterSymbol, pageHeadSymbol, pageHeadTitleSymbol, pageLangSymbol, pageLayoutSymbol, redirects, resolveRoute, resolveRoutePath, resolvers, routeLocaleSymbol, routes, siteData, siteLocaleDataSymbol, updateHeadSymbol, useLayouts, usePageData, usePageFrontmatter, usePageHead, usePageHeadTitle, usePageLang, usePageLayout, useRedirects, useRouteLocale, useRoutes, useSiteData, useSiteLocaleData, useUpdateHead, withBase };
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ClientOnly,
|
|
3
3
|
Content,
|
|
4
|
+
VPLink,
|
|
4
5
|
defineClientConfig,
|
|
5
6
|
layoutsSymbol,
|
|
6
|
-
pageDataEmpty,
|
|
7
7
|
pageDataSymbol,
|
|
8
8
|
pageFrontmatterSymbol,
|
|
9
9
|
pageHeadSymbol,
|
|
10
10
|
pageHeadTitleSymbol,
|
|
11
11
|
pageLangSymbol,
|
|
12
12
|
pageLayoutSymbol,
|
|
13
|
-
|
|
13
|
+
redirects,
|
|
14
|
+
resolveRoute,
|
|
15
|
+
resolveRoutePath,
|
|
14
16
|
resolvers,
|
|
15
17
|
routeLocaleSymbol,
|
|
18
|
+
routes,
|
|
16
19
|
siteData,
|
|
17
20
|
siteLocaleDataSymbol,
|
|
18
21
|
updateHeadSymbol,
|
|
@@ -23,28 +26,32 @@ import {
|
|
|
23
26
|
usePageHeadTitle,
|
|
24
27
|
usePageLang,
|
|
25
28
|
usePageLayout,
|
|
26
|
-
|
|
29
|
+
useRedirects,
|
|
27
30
|
useRouteLocale,
|
|
31
|
+
useRoutes,
|
|
28
32
|
useSiteData,
|
|
29
33
|
useSiteLocaleData,
|
|
30
34
|
useUpdateHead,
|
|
31
35
|
withBase
|
|
32
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-2SMBJWK6.js";
|
|
33
37
|
export {
|
|
34
38
|
ClientOnly,
|
|
35
39
|
Content,
|
|
40
|
+
VPLink,
|
|
36
41
|
defineClientConfig,
|
|
37
42
|
layoutsSymbol,
|
|
38
|
-
pageDataEmpty,
|
|
39
43
|
pageDataSymbol,
|
|
40
44
|
pageFrontmatterSymbol,
|
|
41
45
|
pageHeadSymbol,
|
|
42
46
|
pageHeadTitleSymbol,
|
|
43
47
|
pageLangSymbol,
|
|
44
48
|
pageLayoutSymbol,
|
|
45
|
-
|
|
49
|
+
redirects,
|
|
50
|
+
resolveRoute,
|
|
51
|
+
resolveRoutePath,
|
|
46
52
|
resolvers,
|
|
47
53
|
routeLocaleSymbol,
|
|
54
|
+
routes,
|
|
48
55
|
siteData,
|
|
49
56
|
siteLocaleDataSymbol,
|
|
50
57
|
updateHeadSymbol,
|
|
@@ -55,8 +62,9 @@ export {
|
|
|
55
62
|
usePageHeadTitle,
|
|
56
63
|
usePageLang,
|
|
57
64
|
usePageLayout,
|
|
58
|
-
|
|
65
|
+
useRedirects,
|
|
59
66
|
useRouteLocale,
|
|
67
|
+
useRoutes,
|
|
60
68
|
useSiteData,
|
|
61
69
|
useSiteLocaleData,
|
|
62
70
|
useUpdateHead,
|
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.3",
|
|
4
4
|
"description": "Client package of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@vueuse/core": "^10.7.2",
|
|
38
38
|
"vue": "^3.4.15",
|
|
39
39
|
"vue-router": "^4.2.5",
|
|
40
|
-
"@vuepress/shared": "2.0.0-rc.
|
|
40
|
+
"@vuepress/shared": "2.0.0-rc.3"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
@@ -55,9 +55,7 @@
|
|
|
55
55
|
"external": [
|
|
56
56
|
"@internal/clientConfigs",
|
|
57
57
|
"@internal/layoutComponents",
|
|
58
|
-
"@internal/
|
|
59
|
-
"@internal/pagesData",
|
|
60
|
-
"@internal/pagesRoutes",
|
|
58
|
+
"@internal/routes",
|
|
61
59
|
"@internal/siteData"
|
|
62
60
|
],
|
|
63
61
|
"format": [
|