@vuepress/client 2.0.0-beta.4 → 2.0.0-beta.42
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.d.ts +7 -0
- package/dist/app.js +259 -0
- package/dist/chunk-RTLFYRTT.js +250 -0
- package/dist/createVueAppFunction-c8e67ca1.d.ts +9 -0
- package/dist/index.d.ts +220 -0
- package/dist/index.js +70 -0
- package/package.json +53 -16
- package/templates/{index.ssr.html → build.html} +3 -0
- package/templates/{index.dev.html → dev.html} +2 -0
- package/types.d.ts +6 -0
- package/CHANGELOG.md +0 -171
- package/lib/app.d.ts +0 -18
- package/lib/app.js +0 -133
- 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 -16
- 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 -14
- 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.d.ts
ADDED
package/dist/app.js
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ClientOnly,
|
|
3
|
+
Content,
|
|
4
|
+
pageData,
|
|
5
|
+
pageFrontmatterSymbol,
|
|
6
|
+
pageHeadSymbol,
|
|
7
|
+
pageHeadTitleSymbol,
|
|
8
|
+
pageLangSymbol,
|
|
9
|
+
resolvers,
|
|
10
|
+
routeLocaleSymbol,
|
|
11
|
+
siteData,
|
|
12
|
+
siteLocaleDataSymbol,
|
|
13
|
+
updateHeadSymbol,
|
|
14
|
+
usePageHead,
|
|
15
|
+
usePageLang,
|
|
16
|
+
withBase
|
|
17
|
+
} from "./chunk-RTLFYRTT.js";
|
|
18
|
+
|
|
19
|
+
// src/app.ts
|
|
20
|
+
import { clientAppEnhances } from "@internal/clientAppEnhances";
|
|
21
|
+
import { clientAppRootComponents } from "@internal/clientAppRootComponents";
|
|
22
|
+
import { clientAppSetups } from "@internal/clientAppSetups";
|
|
23
|
+
import { createApp, createSSRApp, h } from "vue";
|
|
24
|
+
import { RouterView } from "vue-router";
|
|
25
|
+
|
|
26
|
+
// src/router.ts
|
|
27
|
+
import { pagesComponents } from "@internal/pagesComponents";
|
|
28
|
+
import { pagesRoutes } from "@internal/pagesRoutes";
|
|
29
|
+
import { removeEndingSlash } from "@vuepress/shared";
|
|
30
|
+
import {
|
|
31
|
+
createMemoryHistory,
|
|
32
|
+
createRouter,
|
|
33
|
+
createWebHistory,
|
|
34
|
+
START_LOCATION
|
|
35
|
+
} from "vue-router";
|
|
36
|
+
var historyCreator = __VUEPRESS_SSR__ ? createMemoryHistory : createWebHistory;
|
|
37
|
+
var createVueRouter = () => {
|
|
38
|
+
const router = createRouter({
|
|
39
|
+
history: historyCreator(removeEndingSlash(siteData.value.base)),
|
|
40
|
+
routes: pagesRoutes,
|
|
41
|
+
scrollBehavior: (to, from, savedPosition) => {
|
|
42
|
+
if (savedPosition)
|
|
43
|
+
return savedPosition;
|
|
44
|
+
if (to.hash)
|
|
45
|
+
return { el: to.hash };
|
|
46
|
+
return { top: 0 };
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
router.beforeResolve(async (to, from) => {
|
|
50
|
+
if (to.path !== from.path || from === START_LOCATION) {
|
|
51
|
+
;
|
|
52
|
+
[pageData.value] = await Promise.all([
|
|
53
|
+
resolvers.resolvePageData(to.name),
|
|
54
|
+
pagesComponents[to.name]?.__asyncLoader()
|
|
55
|
+
]);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return router;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// src/setupDevtools.ts
|
|
62
|
+
import { setupDevtoolsPlugin } from "@vue/devtools-api";
|
|
63
|
+
var setupDevtools = (app, globalComputed) => {
|
|
64
|
+
setupDevtoolsPlugin({
|
|
65
|
+
app,
|
|
66
|
+
id: "org.vuejs.vuepress",
|
|
67
|
+
label: "VuePress",
|
|
68
|
+
packageName: "@vuepress/client",
|
|
69
|
+
homepage: "https://v2.vuepress.vuejs.org",
|
|
70
|
+
logo: "https://v2.vuepress.vuejs.org/images/hero.png",
|
|
71
|
+
componentStateTypes: ["VuePress"]
|
|
72
|
+
}, (api) => {
|
|
73
|
+
api.on.inspectComponent((payload) => {
|
|
74
|
+
payload.instanceData.state.push(...Object.entries(globalComputed).map(([name, item]) => ({
|
|
75
|
+
type: "VuePress",
|
|
76
|
+
key: name,
|
|
77
|
+
editable: false,
|
|
78
|
+
value: item.value
|
|
79
|
+
})));
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// src/setupGlobalComponents.ts
|
|
85
|
+
var setupGlobalComponents = (app) => {
|
|
86
|
+
app.component("ClientOnly", ClientOnly);
|
|
87
|
+
app.component("Content", Content);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// src/setupGlobalComputed.ts
|
|
91
|
+
import { computed } from "vue";
|
|
92
|
+
var setupGlobalComputed = (app, router) => {
|
|
93
|
+
const routeLocale = computed(() => resolvers.resolveRouteLocale(siteData.value.locales, router.currentRoute.value.path));
|
|
94
|
+
const siteLocaleData = computed(() => resolvers.resolveSiteLocaleData(siteData.value, routeLocale.value));
|
|
95
|
+
const pageFrontmatter = computed(() => resolvers.resolvePageFrontmatter(pageData.value));
|
|
96
|
+
const pageHeadTitle = computed(() => resolvers.resolvePageHeadTitle(pageData.value, siteLocaleData.value));
|
|
97
|
+
const pageHead = computed(() => resolvers.resolvePageHead(pageHeadTitle.value, pageFrontmatter.value, siteLocaleData.value));
|
|
98
|
+
const pageLang = computed(() => resolvers.resolvePageLang(pageData.value));
|
|
99
|
+
app.provide(routeLocaleSymbol, routeLocale);
|
|
100
|
+
app.provide(siteLocaleDataSymbol, siteLocaleData);
|
|
101
|
+
app.provide(pageFrontmatterSymbol, pageFrontmatter);
|
|
102
|
+
app.provide(pageHeadTitleSymbol, pageHeadTitle);
|
|
103
|
+
app.provide(pageHeadSymbol, pageHead);
|
|
104
|
+
app.provide(pageLangSymbol, pageLang);
|
|
105
|
+
Object.defineProperties(app.config.globalProperties, {
|
|
106
|
+
$frontmatter: { get: () => pageFrontmatter.value },
|
|
107
|
+
$head: { get: () => pageHead.value },
|
|
108
|
+
$headTitle: { get: () => pageHeadTitle.value },
|
|
109
|
+
$lang: { get: () => pageLang.value },
|
|
110
|
+
$page: { get: () => pageData.value },
|
|
111
|
+
$routeLocale: { get: () => routeLocale.value },
|
|
112
|
+
$site: { get: () => siteData.value },
|
|
113
|
+
$siteLocale: { get: () => siteLocaleData.value },
|
|
114
|
+
$withBase: { get: () => withBase }
|
|
115
|
+
});
|
|
116
|
+
return {
|
|
117
|
+
pageData,
|
|
118
|
+
pageFrontmatter,
|
|
119
|
+
pageHead,
|
|
120
|
+
pageHeadTitle,
|
|
121
|
+
pageLang,
|
|
122
|
+
routeLocale,
|
|
123
|
+
siteData,
|
|
124
|
+
siteLocaleData
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// src/setupUpdateHead.ts
|
|
129
|
+
import { isPlainObject, isString } from "@vuepress/shared";
|
|
130
|
+
import { onMounted, provide, ref, useSSRContext, watch } from "vue";
|
|
131
|
+
import { useRoute } from "vue-router";
|
|
132
|
+
var setupUpdateHead = () => {
|
|
133
|
+
const route = useRoute();
|
|
134
|
+
const head = usePageHead();
|
|
135
|
+
const lang = usePageLang();
|
|
136
|
+
if (__VUEPRESS_SSR__) {
|
|
137
|
+
const ssrContext = useSSRContext();
|
|
138
|
+
if (ssrContext) {
|
|
139
|
+
ssrContext.head = head.value;
|
|
140
|
+
ssrContext.lang = lang.value;
|
|
141
|
+
}
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const headTags = ref([]);
|
|
145
|
+
const loadHead = () => {
|
|
146
|
+
head.value.forEach((item) => {
|
|
147
|
+
const tag = queryHeadTag(item);
|
|
148
|
+
if (tag) {
|
|
149
|
+
headTags.value.push(tag);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
const updateHead = () => {
|
|
154
|
+
document.documentElement.lang = lang.value;
|
|
155
|
+
headTags.value.forEach((item) => {
|
|
156
|
+
if (item.parentNode === document.head) {
|
|
157
|
+
document.head.removeChild(item);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
headTags.value.splice(0, headTags.value.length);
|
|
161
|
+
head.value.forEach((item) => {
|
|
162
|
+
const tag = createHeadTag(item);
|
|
163
|
+
if (tag !== null) {
|
|
164
|
+
document.head.appendChild(tag);
|
|
165
|
+
headTags.value.push(tag);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
provide(updateHeadSymbol, updateHead);
|
|
170
|
+
onMounted(() => {
|
|
171
|
+
loadHead();
|
|
172
|
+
updateHead();
|
|
173
|
+
watch(() => __VUEPRESS_DEV__ ? head.value : route.path, () => updateHead());
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
var queryHeadTag = ([
|
|
177
|
+
tagName,
|
|
178
|
+
attrs,
|
|
179
|
+
content = ""
|
|
180
|
+
]) => {
|
|
181
|
+
const attrsSelector = Object.entries(attrs).map(([key, value]) => {
|
|
182
|
+
if (isString(value)) {
|
|
183
|
+
return `[${key}="${value}"]`;
|
|
184
|
+
}
|
|
185
|
+
if (value === true) {
|
|
186
|
+
return `[${key}]`;
|
|
187
|
+
}
|
|
188
|
+
return "";
|
|
189
|
+
}).join("");
|
|
190
|
+
const selector = `head > ${tagName}${attrsSelector}`;
|
|
191
|
+
const tags = Array.from(document.querySelectorAll(selector));
|
|
192
|
+
const matchedTag = tags.find((item) => item.innerText === content);
|
|
193
|
+
return matchedTag || null;
|
|
194
|
+
};
|
|
195
|
+
var createHeadTag = ([
|
|
196
|
+
tagName,
|
|
197
|
+
attrs,
|
|
198
|
+
content
|
|
199
|
+
]) => {
|
|
200
|
+
if (!isString(tagName)) {
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
const tag = document.createElement(tagName);
|
|
204
|
+
if (isPlainObject(attrs)) {
|
|
205
|
+
Object.entries(attrs).forEach(([key, value]) => {
|
|
206
|
+
if (isString(value)) {
|
|
207
|
+
tag.setAttribute(key, value);
|
|
208
|
+
} else if (value === true) {
|
|
209
|
+
tag.setAttribute(key, "");
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
if (isString(content)) {
|
|
214
|
+
tag.appendChild(document.createTextNode(content));
|
|
215
|
+
}
|
|
216
|
+
return tag;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// src/app.ts
|
|
220
|
+
var appCreator = __VUEPRESS_DEV__ ? createApp : createSSRApp;
|
|
221
|
+
var createVueApp = async () => {
|
|
222
|
+
const app = appCreator({
|
|
223
|
+
name: "VuepressApp",
|
|
224
|
+
setup() {
|
|
225
|
+
setupUpdateHead();
|
|
226
|
+
for (const clientAppSetup of clientAppSetups) {
|
|
227
|
+
clientAppSetup();
|
|
228
|
+
}
|
|
229
|
+
return () => [
|
|
230
|
+
h(RouterView),
|
|
231
|
+
...clientAppRootComponents.map((comp) => h(comp))
|
|
232
|
+
];
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
const router = createVueRouter();
|
|
236
|
+
setupGlobalComponents(app);
|
|
237
|
+
const globalComputed = setupGlobalComputed(app, router);
|
|
238
|
+
if (__VUEPRESS_DEV__ || __VUE_PROD_DEVTOOLS__) {
|
|
239
|
+
setupDevtools(app, globalComputed);
|
|
240
|
+
}
|
|
241
|
+
for (const clientAppEnhance of clientAppEnhances) {
|
|
242
|
+
await clientAppEnhance({ app, router, siteData });
|
|
243
|
+
}
|
|
244
|
+
app.use(router);
|
|
245
|
+
return {
|
|
246
|
+
app,
|
|
247
|
+
router
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
if (!__VUEPRESS_SSR__) {
|
|
251
|
+
createVueApp().then(({ app, router }) => {
|
|
252
|
+
router.isReady().then(() => {
|
|
253
|
+
app.mount("#app");
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
export {
|
|
258
|
+
createVueApp
|
|
259
|
+
};
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
// src/composables/pagesData.ts
|
|
2
|
+
import { pagesData as pagesDataRaw } from "@internal/pagesData";
|
|
3
|
+
import { ref } from "vue";
|
|
4
|
+
var pagesData = ref(pagesDataRaw);
|
|
5
|
+
var usePagesData = () => pagesData;
|
|
6
|
+
|
|
7
|
+
// src/composables/pageData.ts
|
|
8
|
+
import { readonly, ref as ref2 } from "vue";
|
|
9
|
+
var pageDataEmpty = readonly({
|
|
10
|
+
key: "",
|
|
11
|
+
path: "",
|
|
12
|
+
title: "",
|
|
13
|
+
lang: "",
|
|
14
|
+
frontmatter: {},
|
|
15
|
+
excerpt: "",
|
|
16
|
+
headers: []
|
|
17
|
+
});
|
|
18
|
+
var pageData = ref2(pageDataEmpty);
|
|
19
|
+
var usePageData = () => pageData;
|
|
20
|
+
if (import.meta.webpackHot || import.meta.hot) {
|
|
21
|
+
__VUE_HMR_RUNTIME__.updatePageData = (data) => {
|
|
22
|
+
pagesData.value[data.key] = () => Promise.resolve(data);
|
|
23
|
+
if (data.key === pageData.value.key) {
|
|
24
|
+
pageData.value = data;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// src/composables/pageFrontmatter.ts
|
|
30
|
+
import { inject } from "vue";
|
|
31
|
+
var pageFrontmatterSymbol = Symbol(__VUEPRESS_DEV__ ? "pageFrontmatter" : "");
|
|
32
|
+
var usePageFrontmatter = () => {
|
|
33
|
+
const pageFrontmatter = inject(pageFrontmatterSymbol);
|
|
34
|
+
if (!pageFrontmatter) {
|
|
35
|
+
throw new Error("usePageFrontmatter() is called without provider.");
|
|
36
|
+
}
|
|
37
|
+
return pageFrontmatter;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// src/composables/pageHead.ts
|
|
41
|
+
import { inject as inject2 } from "vue";
|
|
42
|
+
var pageHeadSymbol = Symbol(__VUEPRESS_DEV__ ? "pageHead" : "");
|
|
43
|
+
var usePageHead = () => {
|
|
44
|
+
const pageHead = inject2(pageHeadSymbol);
|
|
45
|
+
if (!pageHead) {
|
|
46
|
+
throw new Error("usePageHead() is called without provider.");
|
|
47
|
+
}
|
|
48
|
+
return pageHead;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// src/composables/pageHeadTitle.ts
|
|
52
|
+
import { inject as inject3 } from "vue";
|
|
53
|
+
var pageHeadTitleSymbol = Symbol(__VUEPRESS_DEV__ ? "pageHeadTitle" : "");
|
|
54
|
+
var usePageHeadTitle = () => {
|
|
55
|
+
const pageHeadTitle = inject3(pageHeadTitleSymbol);
|
|
56
|
+
if (!pageHeadTitle) {
|
|
57
|
+
throw new Error("usePageHeadTitle() is called without provider.");
|
|
58
|
+
}
|
|
59
|
+
return pageHeadTitle;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// src/composables/pageLang.ts
|
|
63
|
+
import { inject as inject4 } from "vue";
|
|
64
|
+
var pageLangSymbol = Symbol(__VUEPRESS_DEV__ ? "pageLang" : "");
|
|
65
|
+
var usePageLang = () => {
|
|
66
|
+
const pageLang = inject4(pageLangSymbol);
|
|
67
|
+
if (!pageLang) {
|
|
68
|
+
throw new Error("usePageLang() is called without provider.");
|
|
69
|
+
}
|
|
70
|
+
return pageLang;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// src/composables/routeLocale.ts
|
|
74
|
+
import { inject as inject5 } from "vue";
|
|
75
|
+
var routeLocaleSymbol = Symbol(__VUEPRESS_DEV__ ? "routeLocale" : "");
|
|
76
|
+
var useRouteLocale = () => {
|
|
77
|
+
const routeLocale = inject5(routeLocaleSymbol);
|
|
78
|
+
if (!routeLocale) {
|
|
79
|
+
throw new Error("useRouteLocale() is called without provider.");
|
|
80
|
+
}
|
|
81
|
+
return routeLocale;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// src/composables/siteData.ts
|
|
85
|
+
import { siteData as siteDataRaw } from "@internal/siteData";
|
|
86
|
+
import { ref as ref3 } from "vue";
|
|
87
|
+
var siteData = ref3(siteDataRaw);
|
|
88
|
+
var useSiteData = () => siteData;
|
|
89
|
+
if (import.meta.webpackHot || import.meta.hot) {
|
|
90
|
+
__VUE_HMR_RUNTIME__.updateSiteData = (data) => {
|
|
91
|
+
siteData.value = data;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// src/composables/siteLocaleData.ts
|
|
96
|
+
import { inject as inject6 } from "vue";
|
|
97
|
+
var siteLocaleDataSymbol = Symbol(__VUEPRESS_DEV__ ? "siteLocaleData" : "");
|
|
98
|
+
var useSiteLocaleData = () => {
|
|
99
|
+
const siteLocaleData = inject6(siteLocaleDataSymbol);
|
|
100
|
+
if (!siteLocaleData) {
|
|
101
|
+
throw new Error("useSiteLocaleData() is called without provider.");
|
|
102
|
+
}
|
|
103
|
+
return siteLocaleData;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// src/composables/updateHead.ts
|
|
107
|
+
import { inject as inject7 } from "vue";
|
|
108
|
+
var updateHeadSymbol = Symbol(__VUEPRESS_DEV__ ? "updateHead" : "");
|
|
109
|
+
var useUpdateHead = () => {
|
|
110
|
+
const updateHead = inject7(updateHeadSymbol);
|
|
111
|
+
if (!updateHead) {
|
|
112
|
+
throw new Error("useUpdateHead() is called without provider.");
|
|
113
|
+
}
|
|
114
|
+
return updateHead;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// src/resolvers.ts
|
|
118
|
+
import {
|
|
119
|
+
dedupeHead,
|
|
120
|
+
isArray,
|
|
121
|
+
isString,
|
|
122
|
+
resolveLocalePath
|
|
123
|
+
} from "@vuepress/shared";
|
|
124
|
+
import { reactive } from "vue";
|
|
125
|
+
var resolvers = reactive({
|
|
126
|
+
resolvePageData: async (pageKey) => {
|
|
127
|
+
const pageDataResolver = pagesData.value[pageKey];
|
|
128
|
+
const pageData2 = await pageDataResolver?.();
|
|
129
|
+
return pageData2 ?? pageDataEmpty;
|
|
130
|
+
},
|
|
131
|
+
resolvePageFrontmatter: (pageData2) => pageData2.frontmatter,
|
|
132
|
+
resolvePageHead: (headTitle, frontmatter, siteLocale) => {
|
|
133
|
+
const description = isString(frontmatter.description) ? frontmatter.description : siteLocale.description;
|
|
134
|
+
const head = [
|
|
135
|
+
...isArray(frontmatter.head) ? frontmatter.head : [],
|
|
136
|
+
...siteLocale.head,
|
|
137
|
+
["title", {}, headTitle],
|
|
138
|
+
["meta", { name: "description", content: description }]
|
|
139
|
+
];
|
|
140
|
+
return dedupeHead(head);
|
|
141
|
+
},
|
|
142
|
+
resolvePageHeadTitle: (page, siteLocale) => `${page.title ? `${page.title} | ` : ``}${siteLocale.title}`,
|
|
143
|
+
resolvePageLang: (pageData2) => pageData2.lang || "en",
|
|
144
|
+
resolveRouteLocale: (locales, routePath) => resolveLocalePath(locales, routePath),
|
|
145
|
+
resolveSiteLocaleData: (site, routeLocale) => ({
|
|
146
|
+
...site,
|
|
147
|
+
...site.locales[routeLocale]
|
|
148
|
+
})
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// src/components/ClientOnly.ts
|
|
152
|
+
import { defineComponent, onMounted, ref as ref4 } from "vue";
|
|
153
|
+
var ClientOnly = defineComponent({
|
|
154
|
+
setup(_, ctx) {
|
|
155
|
+
const isMounted = ref4(false);
|
|
156
|
+
onMounted(() => {
|
|
157
|
+
isMounted.value = true;
|
|
158
|
+
});
|
|
159
|
+
return () => isMounted.value ? ctx.slots.default?.() : null;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
// src/components/Content.ts
|
|
164
|
+
import { pagesComponents } from "@internal/pagesComponents";
|
|
165
|
+
import { h } from "vue";
|
|
166
|
+
var Content = (props) => {
|
|
167
|
+
let key;
|
|
168
|
+
if (props.pageKey) {
|
|
169
|
+
key = props.pageKey;
|
|
170
|
+
} else {
|
|
171
|
+
const page = usePageData();
|
|
172
|
+
key = page.value.key;
|
|
173
|
+
}
|
|
174
|
+
const component = pagesComponents[key];
|
|
175
|
+
if (component) {
|
|
176
|
+
return h(component);
|
|
177
|
+
}
|
|
178
|
+
return h("div", __VUEPRESS_DEV__ ? "Page does not exist. This is a fallback content." : "404 Not Found");
|
|
179
|
+
};
|
|
180
|
+
Content.displayName = "Content";
|
|
181
|
+
Content.props = {
|
|
182
|
+
pageKey: {
|
|
183
|
+
type: String,
|
|
184
|
+
required: false
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// src/components/Vuepress.ts
|
|
189
|
+
import { layoutComponents } from "@internal/layoutComponents";
|
|
190
|
+
import { isString as isString2 } from "@vuepress/shared";
|
|
191
|
+
import { computed, defineComponent as defineComponent2, h as h2, resolveComponent } from "vue";
|
|
192
|
+
var Vuepress = defineComponent2({
|
|
193
|
+
name: "Vuepress",
|
|
194
|
+
setup() {
|
|
195
|
+
const page = usePageData();
|
|
196
|
+
const layoutComponent = computed(() => {
|
|
197
|
+
let layoutName;
|
|
198
|
+
if (page.value.path) {
|
|
199
|
+
const frontmatterLayout = page.value.frontmatter.layout;
|
|
200
|
+
if (isString2(frontmatterLayout)) {
|
|
201
|
+
layoutName = frontmatterLayout;
|
|
202
|
+
} else {
|
|
203
|
+
layoutName = "Layout";
|
|
204
|
+
}
|
|
205
|
+
} else {
|
|
206
|
+
layoutName = "404";
|
|
207
|
+
}
|
|
208
|
+
return layoutComponents[layoutName] || resolveComponent(layoutName, false);
|
|
209
|
+
});
|
|
210
|
+
return () => h2(layoutComponent.value);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// src/withBase.ts
|
|
215
|
+
import { isLinkHttp, removeLeadingSlash } from "@vuepress/shared";
|
|
216
|
+
var withBase = (url) => {
|
|
217
|
+
if (isLinkHttp(url))
|
|
218
|
+
return url;
|
|
219
|
+
const base = useSiteData().value.base;
|
|
220
|
+
return `${base}${removeLeadingSlash(url)}`;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
export {
|
|
224
|
+
pagesData,
|
|
225
|
+
usePagesData,
|
|
226
|
+
pageDataEmpty,
|
|
227
|
+
pageData,
|
|
228
|
+
usePageData,
|
|
229
|
+
pageFrontmatterSymbol,
|
|
230
|
+
usePageFrontmatter,
|
|
231
|
+
pageHeadSymbol,
|
|
232
|
+
usePageHead,
|
|
233
|
+
pageHeadTitleSymbol,
|
|
234
|
+
usePageHeadTitle,
|
|
235
|
+
pageLangSymbol,
|
|
236
|
+
usePageLang,
|
|
237
|
+
routeLocaleSymbol,
|
|
238
|
+
useRouteLocale,
|
|
239
|
+
siteData,
|
|
240
|
+
useSiteData,
|
|
241
|
+
siteLocaleDataSymbol,
|
|
242
|
+
useSiteLocaleData,
|
|
243
|
+
updateHeadSymbol,
|
|
244
|
+
useUpdateHead,
|
|
245
|
+
resolvers,
|
|
246
|
+
ClientOnly,
|
|
247
|
+
Content,
|
|
248
|
+
Vuepress,
|
|
249
|
+
withBase
|
|
250
|
+
};
|