@vuepress/client 2.0.0-beta.6 → 2.0.0-beta.60
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 +308 -0
- package/dist/chunk-E44UNXTX.js +298 -0
- package/dist/index.d.ts +287 -0
- package/dist/index.js +64 -0
- package/dist/setupDevtools-EXVHPMXB.js +88 -0
- package/package.json +48 -16
- package/templates/{index.ssr.html → build.html} +4 -1
- package/templates/{index.dev.html → dev.html} +2 -0
- package/types.d.ts +7 -0
- package/CHANGELOG.md +0 -198
- package/lib/app.d.ts +0 -18
- package/lib/app.js +0 -134
- package/lib/client.d.ts +0 -1
- package/lib/client.js +0 -14
- package/lib/components/Content.d.ts +0 -7
- package/lib/components/Content.js +0 -34
- package/lib/components/OutboundLink.css +0 -7
- package/lib/components/OutboundLink.d.ts +0 -3
- package/lib/components/OutboundLink.js +0 -24
- package/lib/components/Vuepress.d.ts +0 -5
- package/lib/components/Vuepress.js +0 -33
- package/lib/components/index.d.ts +0 -3
- package/lib/components/index.js +0 -3
- package/lib/constants.d.ts +0 -4
- package/lib/index.d.ts +0 -7
- package/lib/index.js +0 -5
- package/lib/injections/index.d.ts +0 -10
- package/lib/injections/index.js +0 -10
- package/lib/injections/pageData.d.ts +0 -7
- package/lib/injections/pageData.js +0 -31
- package/lib/injections/pageFrontmatter.d.ts +0 -7
- package/lib/injections/pageFrontmatter.js +0 -10
- package/lib/injections/pageHead.d.ts +0 -15
- package/lib/injections/pageHead.js +0 -33
- package/lib/injections/pageHeadTitle.d.ts +0 -11
- package/lib/injections/pageHeadTitle.js +0 -13
- package/lib/injections/pageLang.d.ts +0 -13
- package/lib/injections/pageLang.js +0 -16
- package/lib/injections/pagesData.d.ts +0 -6
- package/lib/injections/pagesData.js +0 -6
- package/lib/injections/routeLocale.d.ts +0 -10
- package/lib/injections/routeLocale.js +0 -14
- package/lib/injections/siteData.d.ts +0 -6
- package/lib/injections/siteData.js +0 -10
- package/lib/injections/siteLocaleData.d.ts +0 -12
- package/lib/injections/siteLocaleData.js +0 -17
- package/lib/injections/updateHead.d.ts +0 -15
- package/lib/injections/updateHead.js +0 -100
- package/lib/server.d.ts +0 -8
- package/lib/server.js +0 -10
- package/lib/types/clientAppEnhance.d.ts +0 -8
- package/lib/types/clientAppEnhance.js +0 -1
- package/lib/types/clientAppSetup.d.ts +0 -1
- package/lib/types/clientAppSetup.js +0 -1
- package/lib/types/index.d.ts +0 -7
- package/lib/types/index.js +0 -2
- package/lib/types/internal/clientAppEnhances.d.ts +0 -5
- package/lib/types/internal/clientAppRootComponents.d.ts +0 -5
- package/lib/types/internal/clientAppSetups.d.ts +0 -5
- package/lib/types/internal/layoutComponents.d.ts +0 -5
- package/lib/types/internal/pagesComponent.d.ts +0 -5
- package/lib/types/internal/pagesData.d.ts +0 -5
- package/lib/types/internal/pagesRoutes.d.ts +0 -5
- package/lib/types/internal/siteData.d.ts +0 -5
- package/lib/utils/defineClientAppEnhance.d.ts +0 -2
- package/lib/utils/defineClientAppEnhance.js +0 -1
- package/lib/utils/defineClientAppSetup.d.ts +0 -2
- package/lib/utils/defineClientAppSetup.js +0 -1
- package/lib/utils/index.d.ts +0 -3
- package/lib/utils/index.js +0 -3
- package/lib/utils/withBase.d.ts +0 -4
- package/lib/utils/withBase.js +0 -11
package/dist/app.js
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
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-E44UNXTX.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
|
+
history: historyCreator(removeEndingSlash(__VUEPRESS_BASE__)),
|
|
81
|
+
routes: createRoutes(),
|
|
82
|
+
scrollBehavior: (to, from, savedPosition) => {
|
|
83
|
+
if (savedPosition)
|
|
84
|
+
return savedPosition;
|
|
85
|
+
if (to.hash)
|
|
86
|
+
return { el: to.hash };
|
|
87
|
+
return { top: 0 };
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
router.beforeResolve(async (to, from) => {
|
|
91
|
+
if (to.path !== from.path || from === START_LOCATION) {
|
|
92
|
+
;
|
|
93
|
+
[pageData.value] = await Promise.all([
|
|
94
|
+
resolvers.resolvePageData(to.name),
|
|
95
|
+
pagesComponents[to.name]?.__asyncLoader()
|
|
96
|
+
]);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
return router;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// src/setupGlobalComponents.ts
|
|
103
|
+
var setupGlobalComponents = (app) => {
|
|
104
|
+
app.component("ClientOnly", ClientOnly);
|
|
105
|
+
app.component("Content", Content);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// src/setupGlobalComputed.ts
|
|
109
|
+
import { computed } from "vue";
|
|
110
|
+
var setupGlobalComputed = (app, router, clientConfigs2) => {
|
|
111
|
+
const layouts = computed(() => resolvers.resolveLayouts(clientConfigs2));
|
|
112
|
+
const routeLocale = computed(
|
|
113
|
+
() => resolvers.resolveRouteLocale(
|
|
114
|
+
siteData.value.locales,
|
|
115
|
+
router.currentRoute.value.path
|
|
116
|
+
)
|
|
117
|
+
);
|
|
118
|
+
const siteLocaleData = computed(
|
|
119
|
+
() => resolvers.resolveSiteLocaleData(siteData.value, routeLocale.value)
|
|
120
|
+
);
|
|
121
|
+
const pageFrontmatter = computed(
|
|
122
|
+
() => resolvers.resolvePageFrontmatter(pageData.value)
|
|
123
|
+
);
|
|
124
|
+
const pageHeadTitle = computed(
|
|
125
|
+
() => resolvers.resolvePageHeadTitle(pageData.value, siteLocaleData.value)
|
|
126
|
+
);
|
|
127
|
+
const pageHead = computed(
|
|
128
|
+
() => resolvers.resolvePageHead(
|
|
129
|
+
pageHeadTitle.value,
|
|
130
|
+
pageFrontmatter.value,
|
|
131
|
+
siteLocaleData.value
|
|
132
|
+
)
|
|
133
|
+
);
|
|
134
|
+
const pageLang = computed(() => resolvers.resolvePageLang(pageData.value));
|
|
135
|
+
const pageLayout = computed(
|
|
136
|
+
() => resolvers.resolvePageLayout(pageData.value, layouts.value)
|
|
137
|
+
);
|
|
138
|
+
app.provide(layoutsSymbol, layouts);
|
|
139
|
+
app.provide(pageFrontmatterSymbol, pageFrontmatter);
|
|
140
|
+
app.provide(pageHeadTitleSymbol, pageHeadTitle);
|
|
141
|
+
app.provide(pageHeadSymbol, pageHead);
|
|
142
|
+
app.provide(pageLangSymbol, pageLang);
|
|
143
|
+
app.provide(pageLayoutSymbol, pageLayout);
|
|
144
|
+
app.provide(routeLocaleSymbol, routeLocale);
|
|
145
|
+
app.provide(siteLocaleDataSymbol, siteLocaleData);
|
|
146
|
+
Object.defineProperties(app.config.globalProperties, {
|
|
147
|
+
$frontmatter: { get: () => pageFrontmatter.value },
|
|
148
|
+
$head: { get: () => pageHead.value },
|
|
149
|
+
$headTitle: { get: () => pageHeadTitle.value },
|
|
150
|
+
$lang: { get: () => pageLang.value },
|
|
151
|
+
$page: { get: () => pageData.value },
|
|
152
|
+
$routeLocale: { get: () => routeLocale.value },
|
|
153
|
+
$site: { get: () => siteData.value },
|
|
154
|
+
$siteLocale: { get: () => siteLocaleData.value },
|
|
155
|
+
$withBase: { get: () => withBase }
|
|
156
|
+
});
|
|
157
|
+
return {
|
|
158
|
+
layouts,
|
|
159
|
+
pageData,
|
|
160
|
+
pageFrontmatter,
|
|
161
|
+
pageHead,
|
|
162
|
+
pageHeadTitle,
|
|
163
|
+
pageLang,
|
|
164
|
+
pageLayout,
|
|
165
|
+
routeLocale,
|
|
166
|
+
siteData,
|
|
167
|
+
siteLocaleData
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
// src/setupUpdateHead.ts
|
|
172
|
+
import { isPlainObject, isString } from "@vuepress/shared";
|
|
173
|
+
import { onMounted, provide, ref, useSSRContext, watch } from "vue";
|
|
174
|
+
import { useRoute } from "vue-router";
|
|
175
|
+
var setupUpdateHead = () => {
|
|
176
|
+
const route = useRoute();
|
|
177
|
+
const head = usePageHead();
|
|
178
|
+
const lang = usePageLang();
|
|
179
|
+
if (__VUEPRESS_SSR__) {
|
|
180
|
+
const ssrContext = useSSRContext();
|
|
181
|
+
if (ssrContext) {
|
|
182
|
+
ssrContext.head = head.value;
|
|
183
|
+
ssrContext.lang = lang.value;
|
|
184
|
+
}
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const headTags = ref([]);
|
|
188
|
+
const loadHead = () => {
|
|
189
|
+
head.value.forEach((item) => {
|
|
190
|
+
const tag = queryHeadTag(item);
|
|
191
|
+
if (tag) {
|
|
192
|
+
headTags.value.push(tag);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
const updateHead = () => {
|
|
197
|
+
document.documentElement.lang = lang.value;
|
|
198
|
+
headTags.value.forEach((item) => {
|
|
199
|
+
if (item.parentNode === document.head) {
|
|
200
|
+
document.head.removeChild(item);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
headTags.value.splice(0, headTags.value.length);
|
|
204
|
+
head.value.forEach((item) => {
|
|
205
|
+
const tag = createHeadTag(item);
|
|
206
|
+
if (tag !== null) {
|
|
207
|
+
document.head.appendChild(tag);
|
|
208
|
+
headTags.value.push(tag);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
provide(updateHeadSymbol, updateHead);
|
|
213
|
+
onMounted(() => {
|
|
214
|
+
loadHead();
|
|
215
|
+
updateHead();
|
|
216
|
+
watch(
|
|
217
|
+
() => __VUEPRESS_DEV__ ? head.value : route.path,
|
|
218
|
+
() => updateHead()
|
|
219
|
+
);
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
var queryHeadTag = ([
|
|
223
|
+
tagName,
|
|
224
|
+
attrs,
|
|
225
|
+
content = ""
|
|
226
|
+
]) => {
|
|
227
|
+
const attrsSelector = Object.entries(attrs).map(([key, value]) => {
|
|
228
|
+
if (isString(value)) {
|
|
229
|
+
return `[${key}=${JSON.stringify(value)}]`;
|
|
230
|
+
}
|
|
231
|
+
if (value === true) {
|
|
232
|
+
return `[${key}]`;
|
|
233
|
+
}
|
|
234
|
+
return "";
|
|
235
|
+
}).join("");
|
|
236
|
+
const selector = `head > ${tagName}${attrsSelector}`;
|
|
237
|
+
const tags = Array.from(document.querySelectorAll(selector));
|
|
238
|
+
const matchedTag = tags.find((item) => item.innerText === content);
|
|
239
|
+
return matchedTag || null;
|
|
240
|
+
};
|
|
241
|
+
var createHeadTag = ([
|
|
242
|
+
tagName,
|
|
243
|
+
attrs,
|
|
244
|
+
content
|
|
245
|
+
]) => {
|
|
246
|
+
if (!isString(tagName)) {
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
const tag = document.createElement(tagName);
|
|
250
|
+
if (isPlainObject(attrs)) {
|
|
251
|
+
Object.entries(attrs).forEach(([key, value]) => {
|
|
252
|
+
if (isString(value)) {
|
|
253
|
+
tag.setAttribute(key, value);
|
|
254
|
+
} else if (value === true) {
|
|
255
|
+
tag.setAttribute(key, "");
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
if (isString(content)) {
|
|
260
|
+
tag.appendChild(document.createTextNode(content));
|
|
261
|
+
}
|
|
262
|
+
return tag;
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
// src/app.ts
|
|
266
|
+
var appCreator = __VUEPRESS_DEV__ ? createApp : createSSRApp;
|
|
267
|
+
var createVueApp = async () => {
|
|
268
|
+
const app = appCreator({
|
|
269
|
+
name: "VuepressApp",
|
|
270
|
+
setup() {
|
|
271
|
+
setupUpdateHead();
|
|
272
|
+
for (const clientConfig of clientConfigs) {
|
|
273
|
+
clientConfig.setup?.();
|
|
274
|
+
}
|
|
275
|
+
return () => [
|
|
276
|
+
h2(RouterView),
|
|
277
|
+
...clientConfigs.flatMap(
|
|
278
|
+
({ rootComponents = [] }) => rootComponents.map((component) => h2(component))
|
|
279
|
+
)
|
|
280
|
+
];
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
const router = createVueRouter();
|
|
284
|
+
setupGlobalComponents(app);
|
|
285
|
+
const globalComputed = setupGlobalComputed(app, router, clientConfigs);
|
|
286
|
+
if (__VUEPRESS_DEV__ || __VUE_PROD_DEVTOOLS__) {
|
|
287
|
+
const { setupDevtools } = await import("./setupDevtools-EXVHPMXB.js");
|
|
288
|
+
setupDevtools(app, globalComputed);
|
|
289
|
+
}
|
|
290
|
+
for (const clientConfig of clientConfigs) {
|
|
291
|
+
await clientConfig.enhance?.({ app, router, siteData });
|
|
292
|
+
}
|
|
293
|
+
app.use(router);
|
|
294
|
+
return {
|
|
295
|
+
app,
|
|
296
|
+
router
|
|
297
|
+
};
|
|
298
|
+
};
|
|
299
|
+
if (!__VUEPRESS_SSR__) {
|
|
300
|
+
createVueApp().then(({ app, router }) => {
|
|
301
|
+
router.isReady().then(() => {
|
|
302
|
+
app.mount("#app");
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
export {
|
|
307
|
+
createVueApp
|
|
308
|
+
};
|
|
@@ -0,0 +1,298 @@
|
|
|
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
|
+
resolveLayouts: (clientConfigs) => clientConfigs.reduce(
|
|
174
|
+
(prev, item) => ({
|
|
175
|
+
...prev,
|
|
176
|
+
...item.layouts
|
|
177
|
+
}),
|
|
178
|
+
{}
|
|
179
|
+
),
|
|
180
|
+
resolvePageData: async (pageKey) => {
|
|
181
|
+
const pageDataResolver = pagesData.value[pageKey];
|
|
182
|
+
const pageData2 = await pageDataResolver?.();
|
|
183
|
+
return pageData2 ?? pageDataEmpty;
|
|
184
|
+
},
|
|
185
|
+
resolvePageFrontmatter: (pageData2) => pageData2.frontmatter,
|
|
186
|
+
resolvePageHead: (headTitle, frontmatter, siteLocale) => {
|
|
187
|
+
const description = isString(frontmatter.description) ? frontmatter.description : siteLocale.description;
|
|
188
|
+
const head = [
|
|
189
|
+
...isArray(frontmatter.head) ? frontmatter.head : [],
|
|
190
|
+
...siteLocale.head,
|
|
191
|
+
["title", {}, headTitle],
|
|
192
|
+
["meta", { name: "description", content: description }]
|
|
193
|
+
];
|
|
194
|
+
return dedupeHead(head);
|
|
195
|
+
},
|
|
196
|
+
resolvePageHeadTitle: (page, siteLocale) => [page.title, siteLocale.title].filter((item) => !!item).join(" | "),
|
|
197
|
+
resolvePageLang: (page) => page.lang || "en",
|
|
198
|
+
resolvePageLayout: (page, layouts) => {
|
|
199
|
+
let layoutName;
|
|
200
|
+
if (page.path) {
|
|
201
|
+
const frontmatterLayout = page.frontmatter.layout;
|
|
202
|
+
if (isString(frontmatterLayout)) {
|
|
203
|
+
layoutName = frontmatterLayout;
|
|
204
|
+
} else {
|
|
205
|
+
layoutName = LAYOUT_NAME_DEFAULT;
|
|
206
|
+
}
|
|
207
|
+
} else {
|
|
208
|
+
layoutName = LAYOUT_NAME_NOT_FOUND;
|
|
209
|
+
}
|
|
210
|
+
return layouts[layoutName];
|
|
211
|
+
},
|
|
212
|
+
resolveRouteLocale: (locales, routePath) => resolveLocalePath(locales, routePath),
|
|
213
|
+
resolveSiteLocaleData: (site, routeLocale) => ({
|
|
214
|
+
...site,
|
|
215
|
+
...site.locales[routeLocale]
|
|
216
|
+
})
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// src/components/ClientOnly.ts
|
|
220
|
+
import { defineComponent, onMounted, ref as ref4 } from "vue";
|
|
221
|
+
var ClientOnly = defineComponent({
|
|
222
|
+
name: "ClientOnly",
|
|
223
|
+
setup(_, ctx) {
|
|
224
|
+
const isMounted = ref4(false);
|
|
225
|
+
onMounted(() => {
|
|
226
|
+
isMounted.value = true;
|
|
227
|
+
});
|
|
228
|
+
return () => isMounted.value ? ctx.slots.default?.() : null;
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
// src/components/Content.ts
|
|
233
|
+
import { pagesComponents } from "@internal/pagesComponents";
|
|
234
|
+
import { computed, defineComponent as defineComponent2, h } from "vue";
|
|
235
|
+
var Content = defineComponent2({
|
|
236
|
+
name: "Content",
|
|
237
|
+
props: {
|
|
238
|
+
pageKey: {
|
|
239
|
+
type: String,
|
|
240
|
+
required: false,
|
|
241
|
+
default: ""
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
setup(props) {
|
|
245
|
+
const page = usePageData();
|
|
246
|
+
const pageComponent = computed(
|
|
247
|
+
() => pagesComponents[props.pageKey || page.value.key]
|
|
248
|
+
);
|
|
249
|
+
return () => pageComponent.value ? h(pageComponent.value) : h(
|
|
250
|
+
"div",
|
|
251
|
+
__VUEPRESS_DEV__ ? "Page does not exist. This is a fallback content." : "404 Not Found"
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
// src/helpers/defineClientConfig.ts
|
|
257
|
+
var defineClientConfig = (clientConfig = {}) => clientConfig;
|
|
258
|
+
|
|
259
|
+
// src/helpers/withBase.ts
|
|
260
|
+
import { isLinkHttp, removeLeadingSlash } from "@vuepress/shared";
|
|
261
|
+
var withBase = (url) => {
|
|
262
|
+
if (isLinkHttp(url))
|
|
263
|
+
return url;
|
|
264
|
+
return `${__VUEPRESS_BASE__}${removeLeadingSlash(url)}`;
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
export {
|
|
268
|
+
layoutsSymbol,
|
|
269
|
+
useLayouts,
|
|
270
|
+
pagesData,
|
|
271
|
+
usePagesData,
|
|
272
|
+
pageDataEmpty,
|
|
273
|
+
pageData,
|
|
274
|
+
usePageData,
|
|
275
|
+
pageFrontmatterSymbol,
|
|
276
|
+
usePageFrontmatter,
|
|
277
|
+
pageHeadSymbol,
|
|
278
|
+
usePageHead,
|
|
279
|
+
pageHeadTitleSymbol,
|
|
280
|
+
usePageHeadTitle,
|
|
281
|
+
pageLangSymbol,
|
|
282
|
+
usePageLang,
|
|
283
|
+
pageLayoutSymbol,
|
|
284
|
+
usePageLayout,
|
|
285
|
+
routeLocaleSymbol,
|
|
286
|
+
useRouteLocale,
|
|
287
|
+
siteData,
|
|
288
|
+
useSiteData,
|
|
289
|
+
siteLocaleDataSymbol,
|
|
290
|
+
useSiteLocaleData,
|
|
291
|
+
updateHeadSymbol,
|
|
292
|
+
useUpdateHead,
|
|
293
|
+
resolvers,
|
|
294
|
+
ClientOnly,
|
|
295
|
+
Content,
|
|
296
|
+
defineClientConfig,
|
|
297
|
+
withBase
|
|
298
|
+
};
|