@vuepress/client 2.0.0-beta.63 → 2.0.0-beta.65
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 +34 -17
- package/dist/{chunk-X6BS2PXP.js → chunk-IKARB3UY.js} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/package.json +4 -3
package/dist/app.js
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
usePageLang,
|
|
18
18
|
usePageLayout,
|
|
19
19
|
withBase
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-IKARB3UY.js";
|
|
21
21
|
|
|
22
22
|
// src/app.ts
|
|
23
23
|
import { clientConfigs } from "@internal/clientConfigs";
|
|
@@ -57,8 +57,21 @@ var createRoutes = () => pagesRoutes.reduce(
|
|
|
57
57
|
component: Vuepress,
|
|
58
58
|
meta
|
|
59
59
|
},
|
|
60
|
+
{
|
|
61
|
+
path: path.endsWith("/") ? (
|
|
62
|
+
// redirect from `/index.html` to `/`
|
|
63
|
+
path + "index.html"
|
|
64
|
+
) : (
|
|
65
|
+
// redirect from `/foo` to `/foo.html`
|
|
66
|
+
path.substring(0, path.length - 5)
|
|
67
|
+
),
|
|
68
|
+
redirect: path
|
|
69
|
+
},
|
|
60
70
|
...redirects.map((item) => ({
|
|
61
|
-
path: item
|
|
71
|
+
path: item === ":md" ? (
|
|
72
|
+
// redirect from `/foo.md` to `/foo.html`
|
|
73
|
+
path.substring(0, path.length - 5) + ".md"
|
|
74
|
+
) : item,
|
|
62
75
|
redirect: path
|
|
63
76
|
}))
|
|
64
77
|
);
|
|
@@ -88,13 +101,21 @@ var createVueRouter = () => {
|
|
|
88
101
|
return { top: 0 };
|
|
89
102
|
}
|
|
90
103
|
});
|
|
104
|
+
let pendingPageData;
|
|
105
|
+
let pendingToPath;
|
|
91
106
|
router.beforeResolve(async (to, from) => {
|
|
92
107
|
if (to.path !== from.path || from === START_LOCATION) {
|
|
93
108
|
;
|
|
94
|
-
[
|
|
109
|
+
[pendingPageData] = await Promise.all([
|
|
95
110
|
resolvers.resolvePageData(to.name),
|
|
96
111
|
pagesComponents[to.name]?.__asyncLoader()
|
|
97
112
|
]);
|
|
113
|
+
pendingToPath = to.path;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
router.afterEach((to, from) => {
|
|
117
|
+
if (to.path !== from.path && to.path === pendingToPath) {
|
|
118
|
+
pageData.value = pendingPageData;
|
|
98
119
|
}
|
|
99
120
|
});
|
|
100
121
|
return router;
|
|
@@ -107,15 +128,12 @@ var setupGlobalComponents = (app) => {
|
|
|
107
128
|
};
|
|
108
129
|
|
|
109
130
|
// src/setupGlobalComputed.ts
|
|
110
|
-
import {
|
|
131
|
+
import { computedEager } from "@vueuse/core";
|
|
132
|
+
import { computed } from "vue";
|
|
111
133
|
var setupGlobalComputed = (app, router, clientConfigs2) => {
|
|
112
|
-
const routePath = ref(router.currentRoute.value.path);
|
|
113
|
-
watch(
|
|
114
|
-
() => router.currentRoute.value.path,
|
|
115
|
-
(value) => routePath.value = value
|
|
116
|
-
);
|
|
117
134
|
const layouts = computed(() => resolvers.resolveLayouts(clientConfigs2));
|
|
118
|
-
const
|
|
135
|
+
const routePath = computedEager(() => router.currentRoute.value.path);
|
|
136
|
+
const routeLocale = computedEager(
|
|
119
137
|
() => resolvers.resolveRouteLocale(siteData.value.locales, routePath.value)
|
|
120
138
|
);
|
|
121
139
|
const siteLocaleData = computed(
|
|
@@ -134,7 +152,9 @@ var setupGlobalComputed = (app, router, clientConfigs2) => {
|
|
|
134
152
|
siteLocaleData.value
|
|
135
153
|
)
|
|
136
154
|
);
|
|
137
|
-
const pageLang = computed(
|
|
155
|
+
const pageLang = computed(
|
|
156
|
+
() => resolvers.resolvePageLang(pageData.value, siteLocaleData.value)
|
|
157
|
+
);
|
|
138
158
|
const pageLayout = computed(
|
|
139
159
|
() => resolvers.resolvePageLayout(pageData.value, layouts.value)
|
|
140
160
|
);
|
|
@@ -173,7 +193,7 @@ var setupGlobalComputed = (app, router, clientConfigs2) => {
|
|
|
173
193
|
|
|
174
194
|
// src/setupUpdateHead.ts
|
|
175
195
|
import { isPlainObject, isString } from "@vuepress/shared";
|
|
176
|
-
import { onMounted, provide, ref
|
|
196
|
+
import { onMounted, provide, ref, useSSRContext, watch } from "vue";
|
|
177
197
|
var setupUpdateHead = () => {
|
|
178
198
|
const head = usePageHead();
|
|
179
199
|
const lang = usePageLang();
|
|
@@ -185,7 +205,7 @@ var setupUpdateHead = () => {
|
|
|
185
205
|
}
|
|
186
206
|
return;
|
|
187
207
|
}
|
|
188
|
-
const headTags =
|
|
208
|
+
const headTags = ref([]);
|
|
189
209
|
const loadHead = () => {
|
|
190
210
|
head.value.forEach((item) => {
|
|
191
211
|
const tag = queryHeadTag(item);
|
|
@@ -214,10 +234,7 @@ var setupUpdateHead = () => {
|
|
|
214
234
|
onMounted(() => {
|
|
215
235
|
loadHead();
|
|
216
236
|
updateHead();
|
|
217
|
-
|
|
218
|
-
() => head.value,
|
|
219
|
-
() => updateHead()
|
|
220
|
-
);
|
|
237
|
+
watch(() => head.value, updateHead);
|
|
221
238
|
});
|
|
222
239
|
};
|
|
223
240
|
var queryHeadTag = ([
|
|
@@ -218,7 +218,7 @@ var resolvers = reactive({
|
|
|
218
218
|
*
|
|
219
219
|
* It would be used as the `lang` attribute of `<html>` tag
|
|
220
220
|
*/
|
|
221
|
-
resolvePageLang: (page) => page.lang || "en",
|
|
221
|
+
resolvePageLang: (page, siteLocale) => page.lang || siteLocale.lang || "en-US",
|
|
222
222
|
/**
|
|
223
223
|
* Resolve layout component of current page
|
|
224
224
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -204,7 +204,7 @@ type RouteLocale = string;
|
|
|
204
204
|
/**
|
|
205
205
|
* Ref wrapper of `RouteLocale`
|
|
206
206
|
*/
|
|
207
|
-
type RouteLocaleRef =
|
|
207
|
+
type RouteLocaleRef = Readonly<Ref<RouteLocale>>;
|
|
208
208
|
/**
|
|
209
209
|
* Injection key for page route locale path
|
|
210
210
|
*/
|
|
@@ -278,7 +278,7 @@ declare const resolvers: {
|
|
|
278
278
|
resolvePageFrontmatter: (pageData: PageData) => PageFrontmatter;
|
|
279
279
|
resolvePageHead: (headTitle: PageHeadTitle, frontmatter: PageFrontmatter, siteLocale: SiteLocaleData) => PageHead;
|
|
280
280
|
resolvePageHeadTitle: (page: PageData, siteLocale: SiteLocaleData) => PageHeadTitle;
|
|
281
|
-
resolvePageLang: (page: PageData) => PageLang;
|
|
281
|
+
resolvePageLang: (page: PageData, siteLocale: SiteLocaleData) => PageLang;
|
|
282
282
|
resolvePageLayout: (page: PageData, layouts: Layouts) => Component;
|
|
283
283
|
resolveRouteLocale: (locales: SiteData['locales'], routePath: string) => RouteLocale;
|
|
284
284
|
resolveSiteLocaleData: (site: SiteData, routeLocale: RouteLocale) => SiteLocaleData;
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/client",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.65",
|
|
4
4
|
"description": "Client package of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress",
|
|
@@ -34,9 +34,10 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@vue/devtools-api": "^6.5.0",
|
|
37
|
+
"@vueuse/core": "^10.2.1",
|
|
37
38
|
"vue": "^3.3.4",
|
|
38
|
-
"vue-router": "^4.2.
|
|
39
|
-
"@vuepress/shared": "2.0.0-beta.
|
|
39
|
+
"vue-router": "^4.2.4",
|
|
40
|
+
"@vuepress/shared": "2.0.0-beta.65"
|
|
40
41
|
},
|
|
41
42
|
"publishConfig": {
|
|
42
43
|
"access": "public"
|