@vuepress/client 2.0.0-beta.9 → 2.0.0-rc.0

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.
Files changed (72) hide show
  1. package/dist/app.js +333 -0
  2. package/dist/chunk-DHNSDB55.js +338 -0
  3. package/dist/index.d.ts +287 -0
  4. package/dist/index.js +64 -0
  5. package/dist/setupDevtools-X4YFRK4B.js +89 -0
  6. package/package.json +47 -15
  7. package/templates/build.html +16 -0
  8. package/templates/{index.dev.html → dev.html} +2 -0
  9. package/types.d.ts +6 -3
  10. package/CHANGELOG.md +0 -229
  11. package/lib/app.d.ts +0 -18
  12. package/lib/app.js +0 -139
  13. package/lib/client.d.ts +0 -1
  14. package/lib/client.js +0 -14
  15. package/lib/components/Content.d.ts +0 -7
  16. package/lib/components/Content.js +0 -34
  17. package/lib/components/OutboundLink.css +0 -7
  18. package/lib/components/OutboundLink.d.ts +0 -3
  19. package/lib/components/OutboundLink.js +0 -24
  20. package/lib/components/Vuepress.d.ts +0 -5
  21. package/lib/components/Vuepress.js +0 -33
  22. package/lib/components/index.d.ts +0 -3
  23. package/lib/components/index.js +0 -3
  24. package/lib/index.d.ts +0 -7
  25. package/lib/index.js +0 -5
  26. package/lib/injections/index.d.ts +0 -10
  27. package/lib/injections/index.js +0 -10
  28. package/lib/injections/pageData.d.ts +0 -7
  29. package/lib/injections/pageData.js +0 -32
  30. package/lib/injections/pageFrontmatter.d.ts +0 -7
  31. package/lib/injections/pageFrontmatter.js +0 -10
  32. package/lib/injections/pageHead.d.ts +0 -15
  33. package/lib/injections/pageHead.js +0 -33
  34. package/lib/injections/pageHeadTitle.d.ts +0 -11
  35. package/lib/injections/pageHeadTitle.js +0 -13
  36. package/lib/injections/pageLang.d.ts +0 -13
  37. package/lib/injections/pageLang.js +0 -16
  38. package/lib/injections/pagesData.d.ts +0 -6
  39. package/lib/injections/pagesData.js +0 -6
  40. package/lib/injections/routeLocale.d.ts +0 -10
  41. package/lib/injections/routeLocale.js +0 -14
  42. package/lib/injections/siteData.d.ts +0 -6
  43. package/lib/injections/siteData.js +0 -10
  44. package/lib/injections/siteLocaleData.d.ts +0 -12
  45. package/lib/injections/siteLocaleData.js +0 -17
  46. package/lib/injections/updateHead.d.ts +0 -15
  47. package/lib/injections/updateHead.js +0 -100
  48. package/lib/server.d.ts +0 -8
  49. package/lib/server.js +0 -10
  50. package/lib/types/clientAppEnhance.d.ts +0 -8
  51. package/lib/types/clientAppEnhance.js +0 -1
  52. package/lib/types/clientAppSetup.d.ts +0 -1
  53. package/lib/types/clientAppSetup.js +0 -1
  54. package/lib/types/index.d.ts +0 -7
  55. package/lib/types/index.js +0 -2
  56. package/lib/types/internal/clientAppEnhances.d.ts +0 -5
  57. package/lib/types/internal/clientAppRootComponents.d.ts +0 -5
  58. package/lib/types/internal/clientAppSetups.d.ts +0 -5
  59. package/lib/types/internal/layoutComponents.d.ts +0 -5
  60. package/lib/types/internal/pagesComponent.d.ts +0 -5
  61. package/lib/types/internal/pagesData.d.ts +0 -5
  62. package/lib/types/internal/pagesRoutes.d.ts +0 -5
  63. package/lib/types/internal/siteData.d.ts +0 -5
  64. package/lib/utils/defineClientAppEnhance.d.ts +0 -2
  65. package/lib/utils/defineClientAppEnhance.js +0 -1
  66. package/lib/utils/defineClientAppSetup.d.ts +0 -2
  67. package/lib/utils/defineClientAppSetup.js +0 -1
  68. package/lib/utils/index.d.ts +0 -3
  69. package/lib/utils/index.js +0 -3
  70. package/lib/utils/withBase.d.ts +0 -4
  71. package/lib/utils/withBase.js +0 -11
  72. package/templates/index.ssr.html +0 -12
package/dist/app.js ADDED
@@ -0,0 +1,333 @@
1
+ import {
2
+ ClientOnly,
3
+ Content,
4
+ layoutsSymbol,
5
+ pageDataSymbol,
6
+ pageFrontmatterSymbol,
7
+ pageHeadSymbol,
8
+ pageHeadTitleSymbol,
9
+ pageLangSymbol,
10
+ pageLayoutSymbol,
11
+ pagesData,
12
+ resolvers,
13
+ routeLocaleSymbol,
14
+ siteData,
15
+ siteLocaleDataSymbol,
16
+ updateHeadSymbol,
17
+ usePageHead,
18
+ usePageLang,
19
+ usePageLayout,
20
+ withBase
21
+ } from "./chunk-DHNSDB55.js";
22
+
23
+ // src/app.ts
24
+ import { clientConfigs } from "@internal/clientConfigs";
25
+ import { createApp, createSSRApp, h as h2 } from "vue";
26
+ import { RouterView } from "vue-router";
27
+
28
+ // src/router.ts
29
+ import { pagesComponents } from "@internal/pagesComponents";
30
+ import { removeEndingSlash } from "@vuepress/shared";
31
+ import {
32
+ createMemoryHistory,
33
+ createRouter,
34
+ createWebHistory,
35
+ START_LOCATION
36
+ } from "vue-router";
37
+
38
+ // src/routes.ts
39
+ import { pagesRoutes } from "@internal/pagesRoutes";
40
+
41
+ // src/components/Vuepress.ts
42
+ import { defineComponent, h } from "vue";
43
+ var Vuepress = defineComponent({
44
+ name: "Vuepress",
45
+ setup() {
46
+ const layout = usePageLayout();
47
+ return () => h(layout.value);
48
+ }
49
+ });
50
+
51
+ // src/routes.ts
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
91
+ var historyCreator = __VUEPRESS_SSR__ ? createMemoryHistory : createWebHistory;
92
+ var createVueRouter = () => {
93
+ const router = createRouter({
94
+ // it might be an issue of vue-router that have to remove the ending slash
95
+ history: historyCreator(removeEndingSlash(__VUEPRESS_BASE__)),
96
+ routes: createRoutes(),
97
+ scrollBehavior: (to, from, savedPosition) => {
98
+ if (savedPosition)
99
+ return savedPosition;
100
+ if (to.hash)
101
+ return { el: to.hash };
102
+ return { top: 0 };
103
+ }
104
+ });
105
+ router.beforeResolve(async (to, from) => {
106
+ if (to.path !== from.path || from === START_LOCATION) {
107
+ ;
108
+ [to.meta._data] = await Promise.all([
109
+ resolvers.resolvePageData(to.name),
110
+ pagesComponents[to.name]?.__asyncLoader()
111
+ ]);
112
+ }
113
+ });
114
+ return router;
115
+ };
116
+
117
+ // src/setupGlobalComponents.ts
118
+ var setupGlobalComponents = (app) => {
119
+ app.component("ClientOnly", ClientOnly);
120
+ app.component("Content", Content);
121
+ };
122
+
123
+ // src/setupGlobalComputed.ts
124
+ import { computedEager, computedWithControl } from "@vueuse/core";
125
+ import { computed } from "vue";
126
+ var setupGlobalComputed = (app, router, clientConfigs2) => {
127
+ const routePath = computedEager(() => router.currentRoute.value.path);
128
+ const routeLocale = computedEager(
129
+ () => resolvers.resolveRouteLocale(siteData.value.locales, routePath.value)
130
+ );
131
+ const pageData = computedWithControl(
132
+ routePath,
133
+ () => router.currentRoute.value.meta._data
134
+ );
135
+ if (__VUEPRESS_DEV__ && (import.meta.webpackHot || import.meta.hot)) {
136
+ __VUE_HMR_RUNTIME__.updatePageData = (data) => {
137
+ pagesData.value[data.key] = () => Promise.resolve(data);
138
+ if (data.key === router.currentRoute.value.meta._data?.key) {
139
+ router.currentRoute.value.meta._data = data;
140
+ pageData.trigger();
141
+ }
142
+ };
143
+ }
144
+ const layouts = computed(() => resolvers.resolveLayouts(clientConfigs2));
145
+ const siteLocaleData = computed(
146
+ () => resolvers.resolveSiteLocaleData(siteData.value, routeLocale.value)
147
+ );
148
+ const pageFrontmatter = computed(
149
+ () => resolvers.resolvePageFrontmatter(pageData.value)
150
+ );
151
+ const pageHeadTitle = computed(
152
+ () => resolvers.resolvePageHeadTitle(pageData.value, siteLocaleData.value)
153
+ );
154
+ const pageHead = computed(
155
+ () => resolvers.resolvePageHead(
156
+ pageHeadTitle.value,
157
+ pageFrontmatter.value,
158
+ siteLocaleData.value
159
+ )
160
+ );
161
+ const pageLang = computed(
162
+ () => resolvers.resolvePageLang(pageData.value, siteLocaleData.value)
163
+ );
164
+ const pageLayout = computed(
165
+ () => resolvers.resolvePageLayout(pageData.value, layouts.value)
166
+ );
167
+ app.provide(layoutsSymbol, layouts);
168
+ app.provide(pageDataSymbol, pageData);
169
+ app.provide(pageFrontmatterSymbol, pageFrontmatter);
170
+ app.provide(pageHeadTitleSymbol, pageHeadTitle);
171
+ app.provide(pageHeadSymbol, pageHead);
172
+ app.provide(pageLangSymbol, pageLang);
173
+ app.provide(pageLayoutSymbol, pageLayout);
174
+ app.provide(routeLocaleSymbol, routeLocale);
175
+ app.provide(siteLocaleDataSymbol, siteLocaleData);
176
+ Object.defineProperties(app.config.globalProperties, {
177
+ $frontmatter: { get: () => pageFrontmatter.value },
178
+ $head: { get: () => pageHead.value },
179
+ $headTitle: { get: () => pageHeadTitle.value },
180
+ $lang: { get: () => pageLang.value },
181
+ $page: { get: () => pageData.value },
182
+ $routeLocale: { get: () => routeLocale.value },
183
+ $site: { get: () => siteData.value },
184
+ $siteLocale: { get: () => siteLocaleData.value },
185
+ $withBase: { get: () => withBase }
186
+ });
187
+ return {
188
+ layouts,
189
+ pageData,
190
+ pageFrontmatter,
191
+ pageHead,
192
+ pageHeadTitle,
193
+ pageLang,
194
+ pageLayout,
195
+ routeLocale,
196
+ siteData,
197
+ siteLocaleData
198
+ };
199
+ };
200
+
201
+ // src/setupUpdateHead.ts
202
+ import { isPlainObject, isString } from "@vuepress/shared";
203
+ import { onMounted, provide, ref, useSSRContext, watch } from "vue";
204
+ var setupUpdateHead = () => {
205
+ const head = usePageHead();
206
+ const lang = usePageLang();
207
+ if (__VUEPRESS_SSR__) {
208
+ const ssrContext = useSSRContext();
209
+ if (ssrContext) {
210
+ ssrContext.head = head.value;
211
+ ssrContext.lang = lang.value;
212
+ }
213
+ return;
214
+ }
215
+ const headTags = ref([]);
216
+ const loadHead = () => {
217
+ head.value.forEach((item) => {
218
+ const tag = queryHeadTag(item);
219
+ if (tag) {
220
+ headTags.value.push(tag);
221
+ }
222
+ });
223
+ };
224
+ const updateHead = () => {
225
+ document.documentElement.lang = lang.value;
226
+ headTags.value.forEach((item) => {
227
+ if (item.parentNode === document.head) {
228
+ document.head.removeChild(item);
229
+ }
230
+ });
231
+ headTags.value.splice(0, headTags.value.length);
232
+ head.value.forEach((item) => {
233
+ const tag = createHeadTag(item);
234
+ if (tag !== null) {
235
+ document.head.appendChild(tag);
236
+ headTags.value.push(tag);
237
+ }
238
+ });
239
+ };
240
+ provide(updateHeadSymbol, updateHead);
241
+ onMounted(() => {
242
+ loadHead();
243
+ updateHead();
244
+ watch(() => head.value, updateHead);
245
+ });
246
+ };
247
+ var queryHeadTag = ([
248
+ tagName,
249
+ attrs,
250
+ content = ""
251
+ ]) => {
252
+ const attrsSelector = Object.entries(attrs).map(([key, value]) => {
253
+ if (isString(value)) {
254
+ return `[${key}=${JSON.stringify(value)}]`;
255
+ }
256
+ if (value === true) {
257
+ return `[${key}]`;
258
+ }
259
+ return "";
260
+ }).join("");
261
+ const selector = `head > ${tagName}${attrsSelector}`;
262
+ const tags = Array.from(document.querySelectorAll(selector));
263
+ const matchedTag = tags.find((item) => item.innerText === content);
264
+ return matchedTag || null;
265
+ };
266
+ var createHeadTag = ([
267
+ tagName,
268
+ attrs,
269
+ content
270
+ ]) => {
271
+ if (!isString(tagName)) {
272
+ return null;
273
+ }
274
+ const tag = document.createElement(tagName);
275
+ if (isPlainObject(attrs)) {
276
+ Object.entries(attrs).forEach(([key, value]) => {
277
+ if (isString(value)) {
278
+ tag.setAttribute(key, value);
279
+ } else if (value === true) {
280
+ tag.setAttribute(key, "");
281
+ }
282
+ });
283
+ }
284
+ if (isString(content)) {
285
+ tag.appendChild(document.createTextNode(content));
286
+ }
287
+ return tag;
288
+ };
289
+
290
+ // src/app.ts
291
+ var appCreator = __VUEPRESS_DEV__ ? createApp : createSSRApp;
292
+ var createVueApp = async () => {
293
+ const app = appCreator({
294
+ name: "VuepressApp",
295
+ setup() {
296
+ setupUpdateHead();
297
+ for (const clientConfig of clientConfigs) {
298
+ clientConfig.setup?.();
299
+ }
300
+ return () => [
301
+ h2(RouterView),
302
+ ...clientConfigs.flatMap(
303
+ ({ rootComponents = [] }) => rootComponents.map((component) => h2(component))
304
+ )
305
+ ];
306
+ }
307
+ });
308
+ const router = createVueRouter();
309
+ setupGlobalComponents(app);
310
+ const globalComputed = setupGlobalComputed(app, router, clientConfigs);
311
+ if (__VUEPRESS_DEV__ || __VUE_PROD_DEVTOOLS__) {
312
+ const { setupDevtools } = await import("./setupDevtools-X4YFRK4B.js");
313
+ setupDevtools(app, globalComputed);
314
+ }
315
+ for (const clientConfig of clientConfigs) {
316
+ await clientConfig.enhance?.({ app, router, siteData });
317
+ }
318
+ app.use(router);
319
+ return {
320
+ app,
321
+ router
322
+ };
323
+ };
324
+ if (!__VUEPRESS_SSR__) {
325
+ createVueApp().then(({ app, router }) => {
326
+ router.isReady().then(() => {
327
+ app.mount("#app");
328
+ });
329
+ });
330
+ }
331
+ export {
332
+ createVueApp
333
+ };
@@ -0,0 +1,338 @@
1
+ // src/composables/layouts.ts
2
+ import { inject } from "vue";
3
+ var layoutsSymbol = Symbol(
4
+ __VUEPRESS_DEV__ ? "layouts" : ""
5
+ );
6
+ var useLayouts = () => {
7
+ const layouts = inject(layoutsSymbol);
8
+ if (!layouts) {
9
+ throw new Error("useLayouts() is called without provider.");
10
+ }
11
+ return layouts;
12
+ };
13
+
14
+ // src/composables/pageData.ts
15
+ import { inject as inject2, readonly } from "vue";
16
+ var pageDataSymbol = Symbol(
17
+ __VUEPRESS_DEV__ ? "pageData" : ""
18
+ );
19
+ var pageDataEmpty = readonly({
20
+ key: "",
21
+ path: "",
22
+ title: "",
23
+ lang: "",
24
+ frontmatter: {},
25
+ headers: []
26
+ });
27
+ var usePageData = () => {
28
+ const pageData = inject2(pageDataSymbol);
29
+ if (!pageData) {
30
+ throw new Error("pageData() is called without provider.");
31
+ }
32
+ return pageData;
33
+ };
34
+
35
+ // src/composables/pageFrontmatter.ts
36
+ import { inject as inject3 } from "vue";
37
+ var pageFrontmatterSymbol = Symbol(
38
+ __VUEPRESS_DEV__ ? "pageFrontmatter" : ""
39
+ );
40
+ var usePageFrontmatter = () => {
41
+ const pageFrontmatter = inject3(pageFrontmatterSymbol);
42
+ if (!pageFrontmatter) {
43
+ throw new Error("usePageFrontmatter() is called without provider.");
44
+ }
45
+ return pageFrontmatter;
46
+ };
47
+
48
+ // src/composables/pageHead.ts
49
+ import { inject as inject4 } from "vue";
50
+ var pageHeadSymbol = Symbol(
51
+ __VUEPRESS_DEV__ ? "pageHead" : ""
52
+ );
53
+ var usePageHead = () => {
54
+ const pageHead = inject4(pageHeadSymbol);
55
+ if (!pageHead) {
56
+ throw new Error("usePageHead() is called without provider.");
57
+ }
58
+ return pageHead;
59
+ };
60
+
61
+ // src/composables/pageHeadTitle.ts
62
+ import { inject as inject5 } from "vue";
63
+ var pageHeadTitleSymbol = Symbol(
64
+ __VUEPRESS_DEV__ ? "pageHeadTitle" : ""
65
+ );
66
+ var usePageHeadTitle = () => {
67
+ const pageHeadTitle = inject5(pageHeadTitleSymbol);
68
+ if (!pageHeadTitle) {
69
+ throw new Error("usePageHeadTitle() is called without provider.");
70
+ }
71
+ return pageHeadTitle;
72
+ };
73
+
74
+ // src/composables/pageLang.ts
75
+ import { inject as inject6 } from "vue";
76
+ var pageLangSymbol = Symbol(
77
+ __VUEPRESS_DEV__ ? "pageLang" : ""
78
+ );
79
+ var usePageLang = () => {
80
+ const pageLang = inject6(pageLangSymbol);
81
+ if (!pageLang) {
82
+ throw new Error("usePageLang() is called without provider.");
83
+ }
84
+ return pageLang;
85
+ };
86
+
87
+ // src/composables/pageLayout.ts
88
+ import { inject as inject7 } from "vue";
89
+ var pageLayoutSymbol = Symbol(
90
+ __VUEPRESS_DEV__ ? "pageLayout" : ""
91
+ );
92
+ var usePageLayout = () => {
93
+ const pageLayout = inject7(pageLayoutSymbol);
94
+ if (!pageLayout) {
95
+ throw new Error("usePageLayout() is called without provider.");
96
+ }
97
+ return pageLayout;
98
+ };
99
+
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
+ // src/composables/routeLocale.ts
107
+ import { inject as inject8 } from "vue";
108
+ var routeLocaleSymbol = Symbol(
109
+ __VUEPRESS_DEV__ ? "routeLocale" : ""
110
+ );
111
+ var useRouteLocale = () => {
112
+ const routeLocale = inject8(routeLocaleSymbol);
113
+ if (!routeLocale) {
114
+ throw new Error("useRouteLocale() is called without provider.");
115
+ }
116
+ return routeLocale;
117
+ };
118
+
119
+ // src/composables/siteData.ts
120
+ import { siteData as siteDataRaw } from "@internal/siteData";
121
+ import { ref as ref2 } from "vue";
122
+ var siteData = ref2(siteDataRaw);
123
+ var useSiteData = () => siteData;
124
+ if (__VUEPRESS_DEV__ && (import.meta.webpackHot || import.meta.hot)) {
125
+ __VUE_HMR_RUNTIME__.updateSiteData = (data) => {
126
+ siteData.value = data;
127
+ };
128
+ }
129
+
130
+ // src/composables/siteLocaleData.ts
131
+ import { inject as inject9 } from "vue";
132
+ var siteLocaleDataSymbol = Symbol(
133
+ __VUEPRESS_DEV__ ? "siteLocaleData" : ""
134
+ );
135
+ var useSiteLocaleData = () => {
136
+ const siteLocaleData = inject9(siteLocaleDataSymbol);
137
+ if (!siteLocaleData) {
138
+ throw new Error("useSiteLocaleData() is called without provider.");
139
+ }
140
+ return siteLocaleData;
141
+ };
142
+
143
+ // src/composables/updateHead.ts
144
+ import { inject as inject10 } from "vue";
145
+ var updateHeadSymbol = Symbol(
146
+ __VUEPRESS_DEV__ ? "updateHead" : ""
147
+ );
148
+ var useUpdateHead = () => {
149
+ const updateHead = inject10(updateHeadSymbol);
150
+ if (!updateHead) {
151
+ throw new Error("useUpdateHead() is called without provider.");
152
+ }
153
+ return updateHead;
154
+ };
155
+
156
+ // src/resolvers.ts
157
+ import {
158
+ dedupeHead,
159
+ isArray,
160
+ isString,
161
+ resolveLocalePath
162
+ } from "@vuepress/shared";
163
+ import { reactive } from "vue";
164
+
165
+ // src/constants.ts
166
+ var LAYOUT_NAME_DEFAULT = "Layout";
167
+ var LAYOUT_NAME_NOT_FOUND = "NotFound";
168
+
169
+ // src/resolvers.ts
170
+ var resolvers = reactive({
171
+ /**
172
+ * Resolve layouts component map
173
+ */
174
+ resolveLayouts: (clientConfigs) => clientConfigs.reduce(
175
+ (prev, item) => ({
176
+ ...prev,
177
+ ...item.layouts
178
+ }),
179
+ {}
180
+ ),
181
+ /**
182
+ * Resolve page data according to page key
183
+ */
184
+ resolvePageData: async (pageKey) => {
185
+ const pageDataResolver = pagesData.value[pageKey];
186
+ const pageData = await pageDataResolver?.();
187
+ return pageData ?? pageDataEmpty;
188
+ },
189
+ /**
190
+ * Resolve page frontmatter from page data
191
+ */
192
+ resolvePageFrontmatter: (pageData) => pageData.frontmatter,
193
+ /**
194
+ * Merge the head config in frontmatter and site locale
195
+ *
196
+ * Frontmatter should take priority over site locale
197
+ */
198
+ resolvePageHead: (headTitle, frontmatter, siteLocale) => {
199
+ const description = isString(frontmatter.description) ? frontmatter.description : siteLocale.description;
200
+ const head = [
201
+ ...isArray(frontmatter.head) ? frontmatter.head : [],
202
+ ...siteLocale.head,
203
+ ["title", {}, headTitle],
204
+ ["meta", { name: "description", content: description }]
205
+ ];
206
+ return dedupeHead(head);
207
+ },
208
+ /**
209
+ * Resolve the content of page head title
210
+ *
211
+ * It would be used as the content of the `<title>` tag
212
+ */
213
+ resolvePageHeadTitle: (page, siteLocale) => [page.title, siteLocale.title].filter((item) => !!item).join(" | "),
214
+ /**
215
+ * Resolve page language from page data
216
+ *
217
+ * It would be used as the `lang` attribute of `<html>` tag
218
+ */
219
+ resolvePageLang: (page, siteLocale) => page.lang || siteLocale.lang || "en-US",
220
+ /**
221
+ * Resolve layout component of current page
222
+ */
223
+ resolvePageLayout: (page, layouts) => {
224
+ let layoutName;
225
+ if (page.path) {
226
+ const frontmatterLayout = page.frontmatter.layout;
227
+ if (isString(frontmatterLayout)) {
228
+ layoutName = frontmatterLayout;
229
+ } else {
230
+ layoutName = LAYOUT_NAME_DEFAULT;
231
+ }
232
+ } else {
233
+ layoutName = LAYOUT_NAME_NOT_FOUND;
234
+ }
235
+ return layouts[layoutName];
236
+ },
237
+ /**
238
+ * Resolve locale path according to route path and locales config
239
+ */
240
+ resolveRouteLocale: (locales, routePath) => resolveLocalePath(locales, routePath),
241
+ /**
242
+ * Resolve site data for specific locale
243
+ *
244
+ * It would merge the locales fields to the root fields
245
+ */
246
+ resolveSiteLocaleData: (site, routeLocale) => ({
247
+ ...site,
248
+ ...site.locales[routeLocale]
249
+ })
250
+ });
251
+
252
+ // src/components/ClientOnly.ts
253
+ import { defineComponent, onMounted, ref as ref3 } from "vue";
254
+ var ClientOnly = defineComponent({
255
+ name: "ClientOnly",
256
+ setup(_, ctx) {
257
+ const isMounted = ref3(false);
258
+ onMounted(() => {
259
+ isMounted.value = true;
260
+ });
261
+ return () => isMounted.value ? ctx.slots.default?.() : null;
262
+ }
263
+ });
264
+
265
+ // src/components/Content.ts
266
+ import { pagesComponents } from "@internal/pagesComponents";
267
+ import { computed, defineComponent as defineComponent2, h } from "vue";
268
+ var Content = defineComponent2({
269
+ // eslint-disable-next-line vue/no-reserved-component-names
270
+ name: "Content",
271
+ props: {
272
+ pageKey: {
273
+ type: String,
274
+ required: false,
275
+ default: ""
276
+ }
277
+ },
278
+ setup(props) {
279
+ const page = usePageData();
280
+ const pageComponent = computed(
281
+ () => pagesComponents[props.pageKey || page.value.key]
282
+ );
283
+ return () => pageComponent.value ? (
284
+ // use page component
285
+ h(pageComponent.value)
286
+ ) : (
287
+ // fallback content
288
+ h(
289
+ "div",
290
+ __VUEPRESS_DEV__ ? "Page does not exist. This is a fallback content." : "404 Not Found"
291
+ )
292
+ );
293
+ }
294
+ });
295
+
296
+ // src/helpers/defineClientConfig.ts
297
+ var defineClientConfig = (clientConfig = {}) => clientConfig;
298
+
299
+ // src/helpers/withBase.ts
300
+ import { isLinkHttp, removeLeadingSlash } from "@vuepress/shared";
301
+ var withBase = (url) => {
302
+ if (isLinkHttp(url))
303
+ return url;
304
+ return `${__VUEPRESS_BASE__}${removeLeadingSlash(url)}`;
305
+ };
306
+
307
+ export {
308
+ layoutsSymbol,
309
+ useLayouts,
310
+ pageDataSymbol,
311
+ pageDataEmpty,
312
+ usePageData,
313
+ pageFrontmatterSymbol,
314
+ usePageFrontmatter,
315
+ pageHeadSymbol,
316
+ usePageHead,
317
+ pageHeadTitleSymbol,
318
+ usePageHeadTitle,
319
+ pageLangSymbol,
320
+ usePageLang,
321
+ pageLayoutSymbol,
322
+ usePageLayout,
323
+ pagesData,
324
+ usePagesData,
325
+ routeLocaleSymbol,
326
+ useRouteLocale,
327
+ siteData,
328
+ useSiteData,
329
+ siteLocaleDataSymbol,
330
+ useSiteLocaleData,
331
+ updateHeadSymbol,
332
+ useUpdateHead,
333
+ resolvers,
334
+ ClientOnly,
335
+ Content,
336
+ defineClientConfig,
337
+ withBase
338
+ };