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