@vuepress/client 2.0.0-beta.60 → 2.0.0-beta.61
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
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
usePageLang,
|
|
18
18
|
usePageLayout,
|
|
19
19
|
withBase
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-X6BS2PXP.js";
|
|
21
21
|
|
|
22
22
|
// src/app.ts
|
|
23
23
|
import { clientConfigs } from "@internal/clientConfigs";
|
|
@@ -77,6 +77,7 @@ var createRoutes = () => pagesRoutes.reduce(
|
|
|
77
77
|
var historyCreator = __VUEPRESS_SSR__ ? createMemoryHistory : createWebHistory;
|
|
78
78
|
var createVueRouter = () => {
|
|
79
79
|
const router = createRouter({
|
|
80
|
+
// it might be an issue of vue-router that have to remove the ending slash
|
|
80
81
|
history: historyCreator(removeEndingSlash(__VUEPRESS_BASE__)),
|
|
81
82
|
routes: createRoutes(),
|
|
82
83
|
scrollBehavior: (to, from, savedPosition) => {
|
|
@@ -106,14 +107,16 @@ var setupGlobalComponents = (app) => {
|
|
|
106
107
|
};
|
|
107
108
|
|
|
108
109
|
// src/setupGlobalComputed.ts
|
|
109
|
-
import { computed } from "vue";
|
|
110
|
+
import { computed, ref, watch } from "vue";
|
|
110
111
|
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
|
+
);
|
|
111
117
|
const layouts = computed(() => resolvers.resolveLayouts(clientConfigs2));
|
|
112
118
|
const routeLocale = computed(
|
|
113
|
-
() => resolvers.resolveRouteLocale(
|
|
114
|
-
siteData.value.locales,
|
|
115
|
-
router.currentRoute.value.path
|
|
116
|
-
)
|
|
119
|
+
() => resolvers.resolveRouteLocale(siteData.value.locales, routePath.value)
|
|
117
120
|
);
|
|
118
121
|
const siteLocaleData = computed(
|
|
119
122
|
() => resolvers.resolveSiteLocaleData(siteData.value, routeLocale.value)
|
|
@@ -170,10 +173,8 @@ var setupGlobalComputed = (app, router, clientConfigs2) => {
|
|
|
170
173
|
|
|
171
174
|
// src/setupUpdateHead.ts
|
|
172
175
|
import { isPlainObject, isString } from "@vuepress/shared";
|
|
173
|
-
import { onMounted, provide, ref, useSSRContext, watch } from "vue";
|
|
174
|
-
import { useRoute } from "vue-router";
|
|
176
|
+
import { onMounted, provide, ref as ref2, useSSRContext, watch as watch2 } from "vue";
|
|
175
177
|
var setupUpdateHead = () => {
|
|
176
|
-
const route = useRoute();
|
|
177
178
|
const head = usePageHead();
|
|
178
179
|
const lang = usePageLang();
|
|
179
180
|
if (__VUEPRESS_SSR__) {
|
|
@@ -184,7 +185,7 @@ var setupUpdateHead = () => {
|
|
|
184
185
|
}
|
|
185
186
|
return;
|
|
186
187
|
}
|
|
187
|
-
const headTags =
|
|
188
|
+
const headTags = ref2([]);
|
|
188
189
|
const loadHead = () => {
|
|
189
190
|
head.value.forEach((item) => {
|
|
190
191
|
const tag = queryHeadTag(item);
|
|
@@ -213,8 +214,8 @@ var setupUpdateHead = () => {
|
|
|
213
214
|
onMounted(() => {
|
|
214
215
|
loadHead();
|
|
215
216
|
updateHead();
|
|
216
|
-
|
|
217
|
-
() =>
|
|
217
|
+
watch2(
|
|
218
|
+
() => head.value,
|
|
218
219
|
() => updateHead()
|
|
219
220
|
);
|
|
220
221
|
});
|
|
@@ -284,7 +285,7 @@ var createVueApp = async () => {
|
|
|
284
285
|
setupGlobalComponents(app);
|
|
285
286
|
const globalComputed = setupGlobalComputed(app, router, clientConfigs);
|
|
286
287
|
if (__VUEPRESS_DEV__ || __VUE_PROD_DEVTOOLS__) {
|
|
287
|
-
const { setupDevtools } = await import("./setupDevtools-
|
|
288
|
+
const { setupDevtools } = await import("./setupDevtools-X4YFRK4B.js");
|
|
288
289
|
setupDevtools(app, globalComputed);
|
|
289
290
|
}
|
|
290
291
|
for (const clientConfig of clientConfigs) {
|
|
@@ -170,6 +170,9 @@ var LAYOUT_NAME_NOT_FOUND = "NotFound";
|
|
|
170
170
|
|
|
171
171
|
// src/resolvers.ts
|
|
172
172
|
var resolvers = reactive({
|
|
173
|
+
/**
|
|
174
|
+
* Resolve layouts component map
|
|
175
|
+
*/
|
|
173
176
|
resolveLayouts: (clientConfigs) => clientConfigs.reduce(
|
|
174
177
|
(prev, item) => ({
|
|
175
178
|
...prev,
|
|
@@ -177,12 +180,23 @@ var resolvers = reactive({
|
|
|
177
180
|
}),
|
|
178
181
|
{}
|
|
179
182
|
),
|
|
183
|
+
/**
|
|
184
|
+
* Resolve page data according to page key
|
|
185
|
+
*/
|
|
180
186
|
resolvePageData: async (pageKey) => {
|
|
181
187
|
const pageDataResolver = pagesData.value[pageKey];
|
|
182
188
|
const pageData2 = await pageDataResolver?.();
|
|
183
189
|
return pageData2 ?? pageDataEmpty;
|
|
184
190
|
},
|
|
191
|
+
/**
|
|
192
|
+
* Resolve page frontmatter from page data
|
|
193
|
+
*/
|
|
185
194
|
resolvePageFrontmatter: (pageData2) => pageData2.frontmatter,
|
|
195
|
+
/**
|
|
196
|
+
* Merge the head config in frontmatter and site locale
|
|
197
|
+
*
|
|
198
|
+
* Frontmatter should take priority over site locale
|
|
199
|
+
*/
|
|
186
200
|
resolvePageHead: (headTitle, frontmatter, siteLocale) => {
|
|
187
201
|
const description = isString(frontmatter.description) ? frontmatter.description : siteLocale.description;
|
|
188
202
|
const head = [
|
|
@@ -193,8 +207,21 @@ var resolvers = reactive({
|
|
|
193
207
|
];
|
|
194
208
|
return dedupeHead(head);
|
|
195
209
|
},
|
|
210
|
+
/**
|
|
211
|
+
* Resolve the content of page head title
|
|
212
|
+
*
|
|
213
|
+
* It would be used as the content of the `<title>` tag
|
|
214
|
+
*/
|
|
196
215
|
resolvePageHeadTitle: (page, siteLocale) => [page.title, siteLocale.title].filter((item) => !!item).join(" | "),
|
|
216
|
+
/**
|
|
217
|
+
* Resolve page language from page data
|
|
218
|
+
*
|
|
219
|
+
* It would be used as the `lang` attribute of `<html>` tag
|
|
220
|
+
*/
|
|
197
221
|
resolvePageLang: (page) => page.lang || "en",
|
|
222
|
+
/**
|
|
223
|
+
* Resolve layout component of current page
|
|
224
|
+
*/
|
|
198
225
|
resolvePageLayout: (page, layouts) => {
|
|
199
226
|
let layoutName;
|
|
200
227
|
if (page.path) {
|
|
@@ -209,7 +236,15 @@ var resolvers = reactive({
|
|
|
209
236
|
}
|
|
210
237
|
return layouts[layoutName];
|
|
211
238
|
},
|
|
239
|
+
/**
|
|
240
|
+
* Resolve locale path according to route path and locales config
|
|
241
|
+
*/
|
|
212
242
|
resolveRouteLocale: (locales, routePath) => resolveLocalePath(locales, routePath),
|
|
243
|
+
/**
|
|
244
|
+
* Resolve site data for specific locale
|
|
245
|
+
*
|
|
246
|
+
* It would merge the locales fields to the root fields
|
|
247
|
+
*/
|
|
213
248
|
resolveSiteLocaleData: (site, routeLocale) => ({
|
|
214
249
|
...site,
|
|
215
250
|
...site.locales[routeLocale]
|
|
@@ -233,6 +268,7 @@ var ClientOnly = defineComponent({
|
|
|
233
268
|
import { pagesComponents } from "@internal/pagesComponents";
|
|
234
269
|
import { computed, defineComponent as defineComponent2, h } from "vue";
|
|
235
270
|
var Content = defineComponent2({
|
|
271
|
+
// eslint-disable-next-line vue/no-reserved-component-names
|
|
236
272
|
name: "Content",
|
|
237
273
|
props: {
|
|
238
274
|
pageKey: {
|
|
@@ -246,9 +282,15 @@ var Content = defineComponent2({
|
|
|
246
282
|
const pageComponent = computed(
|
|
247
283
|
() => pagesComponents[props.pageKey || page.value.key]
|
|
248
284
|
);
|
|
249
|
-
return () => pageComponent.value ?
|
|
250
|
-
|
|
251
|
-
|
|
285
|
+
return () => pageComponent.value ? (
|
|
286
|
+
// use page component
|
|
287
|
+
h(pageComponent.value)
|
|
288
|
+
) : (
|
|
289
|
+
// fallback content
|
|
290
|
+
h(
|
|
291
|
+
"div",
|
|
292
|
+
__VUEPRESS_DEV__ ? "Page does not exist. This is a fallback content." : "404 Not Found"
|
|
293
|
+
)
|
|
252
294
|
);
|
|
253
295
|
}
|
|
254
296
|
});
|
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.61",
|
|
4
4
|
"description": "Client package of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"types.d.ts"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@vue/devtools-api": "^6.
|
|
37
|
-
"vue": "^3.2.
|
|
36
|
+
"@vue/devtools-api": "^6.5.0",
|
|
37
|
+
"vue": "^3.2.47",
|
|
38
38
|
"vue-router": "^4.1.6",
|
|
39
|
-
"@vuepress/shared": "2.0.0-beta.
|
|
39
|
+
"@vuepress/shared": "2.0.0-beta.61"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|