@vuepress/client 2.0.0-beta.9 → 2.0.0-rc.1
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/LICENSE +1 -1
- package/README.md +12 -0
- package/dist/app.d.ts +7 -0
- package/dist/app.js +353 -0
- package/dist/chunk-PEQEPZ75.js +339 -0
- package/dist/createVueAppFunction-YNGNKfE3.d.ts +9 -0
- package/dist/index.d.ts +283 -0
- package/dist/index.js +64 -0
- package/dist/setupDevtools-X4YFRK4B.js +89 -0
- package/package.json +52 -17
- package/templates/build.html +16 -0
- package/templates/{index.dev.html → dev.html} +2 -0
- package/types.d.ts +6 -3
- package/CHANGELOG.md +0 -229
- package/lib/app.d.ts +0 -18
- package/lib/app.js +0 -139
- 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/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 -32
- 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/templates/index.ssr.html +0 -12
|
@@ -0,0 +1,339 @@
|
|
|
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 { dedupeHead, isString, resolveLocalePath } from "@vuepress/shared";
|
|
158
|
+
import { reactive } from "vue";
|
|
159
|
+
|
|
160
|
+
// src/constants.ts
|
|
161
|
+
var LAYOUT_NAME_DEFAULT = "Layout";
|
|
162
|
+
var LAYOUT_NAME_NOT_FOUND = "NotFound";
|
|
163
|
+
|
|
164
|
+
// src/resolvers.ts
|
|
165
|
+
var resolvers = reactive({
|
|
166
|
+
/**
|
|
167
|
+
* Resolve layouts component map
|
|
168
|
+
*/
|
|
169
|
+
resolveLayouts: (clientConfigs) => clientConfigs.reduce(
|
|
170
|
+
(prev, item) => ({
|
|
171
|
+
...prev,
|
|
172
|
+
...item.layouts
|
|
173
|
+
}),
|
|
174
|
+
{}
|
|
175
|
+
),
|
|
176
|
+
/**
|
|
177
|
+
* Resolve page data according to page key
|
|
178
|
+
*/
|
|
179
|
+
resolvePageData: async (pageKey) => {
|
|
180
|
+
const pageDataResolver = pagesData.value[pageKey];
|
|
181
|
+
const pageData = await pageDataResolver?.();
|
|
182
|
+
return pageData ?? pageDataEmpty;
|
|
183
|
+
},
|
|
184
|
+
/**
|
|
185
|
+
* Resolve page frontmatter from page data
|
|
186
|
+
*/
|
|
187
|
+
resolvePageFrontmatter: (pageData) => pageData.frontmatter,
|
|
188
|
+
/**
|
|
189
|
+
* Merge the head config in frontmatter and site locale
|
|
190
|
+
*
|
|
191
|
+
* Frontmatter should take priority over site locale
|
|
192
|
+
*/
|
|
193
|
+
resolvePageHead: (headTitle, frontmatter, siteLocale) => {
|
|
194
|
+
const description = isString(frontmatter.description) ? frontmatter.description : siteLocale.description;
|
|
195
|
+
const head = [
|
|
196
|
+
...Array.isArray(frontmatter.head) ? frontmatter.head : [],
|
|
197
|
+
...siteLocale.head,
|
|
198
|
+
["title", {}, headTitle],
|
|
199
|
+
["meta", { name: "description", content: description }]
|
|
200
|
+
];
|
|
201
|
+
return dedupeHead(head);
|
|
202
|
+
},
|
|
203
|
+
/**
|
|
204
|
+
* Resolve the content of page head title
|
|
205
|
+
*
|
|
206
|
+
* It would be used as the content of the `<title>` tag
|
|
207
|
+
*/
|
|
208
|
+
resolvePageHeadTitle: (page, siteLocale) => [page.title, siteLocale.title].filter((item) => !!item).join(" | "),
|
|
209
|
+
/**
|
|
210
|
+
* Resolve page language from page data
|
|
211
|
+
*
|
|
212
|
+
* It would be used as the `lang` attribute of `<html>` tag
|
|
213
|
+
*/
|
|
214
|
+
resolvePageLang: (page, siteLocale) => page.lang || siteLocale.lang || "en-US",
|
|
215
|
+
/**
|
|
216
|
+
* Resolve layout component of current page
|
|
217
|
+
*/
|
|
218
|
+
resolvePageLayout: (page, layouts) => {
|
|
219
|
+
let layoutName;
|
|
220
|
+
if (page.path) {
|
|
221
|
+
const frontmatterLayout = page.frontmatter.layout;
|
|
222
|
+
if (isString(frontmatterLayout)) {
|
|
223
|
+
layoutName = frontmatterLayout;
|
|
224
|
+
} else {
|
|
225
|
+
layoutName = LAYOUT_NAME_DEFAULT;
|
|
226
|
+
}
|
|
227
|
+
} else {
|
|
228
|
+
layoutName = LAYOUT_NAME_NOT_FOUND;
|
|
229
|
+
}
|
|
230
|
+
return layouts[layoutName];
|
|
231
|
+
},
|
|
232
|
+
/**
|
|
233
|
+
* Resolve locale path according to route path and locales config
|
|
234
|
+
*/
|
|
235
|
+
resolveRouteLocale: (locales, routePath) => resolveLocalePath(locales, routePath),
|
|
236
|
+
/**
|
|
237
|
+
* Resolve site data for specific locale
|
|
238
|
+
*
|
|
239
|
+
* It would merge the locales fields to the root fields
|
|
240
|
+
*/
|
|
241
|
+
resolveSiteLocaleData: (site, routeLocale) => ({
|
|
242
|
+
...site,
|
|
243
|
+
...site.locales[routeLocale],
|
|
244
|
+
head: [
|
|
245
|
+
// when merging head, the locales head should be placed before root head
|
|
246
|
+
// to get higher priority
|
|
247
|
+
...site.locales[routeLocale]?.head ?? [],
|
|
248
|
+
...site.head ?? []
|
|
249
|
+
]
|
|
250
|
+
})
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
// src/components/ClientOnly.ts
|
|
254
|
+
import { defineComponent, onMounted, ref as ref3 } from "vue";
|
|
255
|
+
var ClientOnly = defineComponent({
|
|
256
|
+
name: "ClientOnly",
|
|
257
|
+
setup(_, ctx) {
|
|
258
|
+
const isMounted = ref3(false);
|
|
259
|
+
onMounted(() => {
|
|
260
|
+
isMounted.value = true;
|
|
261
|
+
});
|
|
262
|
+
return () => isMounted.value ? ctx.slots.default?.() : null;
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
// src/components/Content.ts
|
|
267
|
+
import { pagesComponents } from "@internal/pagesComponents";
|
|
268
|
+
import { computed, defineComponent as defineComponent2, h } from "vue";
|
|
269
|
+
var Content = defineComponent2({
|
|
270
|
+
// eslint-disable-next-line vue/no-reserved-component-names
|
|
271
|
+
name: "Content",
|
|
272
|
+
props: {
|
|
273
|
+
pageKey: {
|
|
274
|
+
type: String,
|
|
275
|
+
required: false,
|
|
276
|
+
default: ""
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
setup(props) {
|
|
280
|
+
const page = usePageData();
|
|
281
|
+
const pageComponent = computed(
|
|
282
|
+
() => pagesComponents[props.pageKey || page.value.key]
|
|
283
|
+
);
|
|
284
|
+
return () => pageComponent.value ? (
|
|
285
|
+
// use page component
|
|
286
|
+
h(pageComponent.value)
|
|
287
|
+
) : (
|
|
288
|
+
// fallback content
|
|
289
|
+
h(
|
|
290
|
+
"div",
|
|
291
|
+
__VUEPRESS_DEV__ ? "Page does not exist. This is a fallback content." : "404 Not Found"
|
|
292
|
+
)
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
// src/helpers/defineClientConfig.ts
|
|
298
|
+
var defineClientConfig = (clientConfig = {}) => clientConfig;
|
|
299
|
+
|
|
300
|
+
// src/helpers/withBase.ts
|
|
301
|
+
import { isLinkHttp, removeLeadingSlash } from "@vuepress/shared";
|
|
302
|
+
var withBase = (url) => {
|
|
303
|
+
if (isLinkHttp(url))
|
|
304
|
+
return url;
|
|
305
|
+
return `${__VUEPRESS_BASE__}${removeLeadingSlash(url)}`;
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
export {
|
|
309
|
+
layoutsSymbol,
|
|
310
|
+
useLayouts,
|
|
311
|
+
pageDataSymbol,
|
|
312
|
+
pageDataEmpty,
|
|
313
|
+
usePageData,
|
|
314
|
+
pageFrontmatterSymbol,
|
|
315
|
+
usePageFrontmatter,
|
|
316
|
+
pageHeadSymbol,
|
|
317
|
+
usePageHead,
|
|
318
|
+
pageHeadTitleSymbol,
|
|
319
|
+
usePageHeadTitle,
|
|
320
|
+
pageLangSymbol,
|
|
321
|
+
usePageLang,
|
|
322
|
+
pageLayoutSymbol,
|
|
323
|
+
usePageLayout,
|
|
324
|
+
pagesData,
|
|
325
|
+
usePagesData,
|
|
326
|
+
routeLocaleSymbol,
|
|
327
|
+
useRouteLocale,
|
|
328
|
+
siteData,
|
|
329
|
+
useSiteData,
|
|
330
|
+
siteLocaleDataSymbol,
|
|
331
|
+
useSiteLocaleData,
|
|
332
|
+
updateHeadSymbol,
|
|
333
|
+
useUpdateHead,
|
|
334
|
+
resolvers,
|
|
335
|
+
ClientOnly,
|
|
336
|
+
Content,
|
|
337
|
+
defineClientConfig,
|
|
338
|
+
withBase
|
|
339
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { PageData, PageFrontmatter, HeadConfig, SiteData } from '@vuepress/shared';
|
|
2
|
+
export { PageData, PageFrontmatter, PageHeader, SiteData } from '@vuepress/shared';
|
|
3
|
+
import * as vue from 'vue';
|
|
4
|
+
import { ComputedRef, InjectionKey, Ref, Component, App } from 'vue';
|
|
5
|
+
import { Router, RouteMeta } from 'vue-router';
|
|
6
|
+
export { C as CreateVueAppFunction } from './createVueAppFunction-YNGNKfE3.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Ref wrapper of `Layouts`
|
|
10
|
+
*/
|
|
11
|
+
type LayoutsRef = ComputedRef<Layouts>;
|
|
12
|
+
/**
|
|
13
|
+
* Injection key for layouts
|
|
14
|
+
*/
|
|
15
|
+
declare const layoutsSymbol: InjectionKey<LayoutsRef>;
|
|
16
|
+
/**
|
|
17
|
+
* Returns layouts component map
|
|
18
|
+
*/
|
|
19
|
+
declare const useLayouts: () => LayoutsRef;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Ref wrapper of `PageData`
|
|
23
|
+
*/
|
|
24
|
+
type PageDataRef<T extends Record<any, any> = Record<never, never>> = Ref<PageData<T>>;
|
|
25
|
+
/**
|
|
26
|
+
* Injection key for page data
|
|
27
|
+
*/
|
|
28
|
+
declare const pageDataSymbol: InjectionKey<PageDataRef>;
|
|
29
|
+
/**
|
|
30
|
+
* Empty page data to be used as the fallback value
|
|
31
|
+
*/
|
|
32
|
+
declare const pageDataEmpty: PageData;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the ref of the data of current page
|
|
35
|
+
*/
|
|
36
|
+
declare const usePageData: <T extends Record<any, any> = Record<never, never>>() => PageDataRef<T>;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Ref wrapper of `PageFrontmatter`
|
|
40
|
+
*/
|
|
41
|
+
type PageFrontmatterRef<T extends Record<any, any> = Record<string, unknown>> = ComputedRef<PageFrontmatter<T>>;
|
|
42
|
+
/**
|
|
43
|
+
* Injection key for page frontmatter
|
|
44
|
+
*/
|
|
45
|
+
declare const pageFrontmatterSymbol: InjectionKey<PageFrontmatterRef>;
|
|
46
|
+
/**
|
|
47
|
+
* Returns the ref of the frontmatter of current page
|
|
48
|
+
*/
|
|
49
|
+
declare const usePageFrontmatter: <T extends Record<any, any> = Record<string, unknown>>() => PageFrontmatterRef<T>;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Page head config, which would be used for generate html tags in `<head>`
|
|
53
|
+
*/
|
|
54
|
+
type PageHead = HeadConfig[];
|
|
55
|
+
/**
|
|
56
|
+
* Ref wrapper of `PageHead`
|
|
57
|
+
*/
|
|
58
|
+
type PageHeadRef = ComputedRef<PageHead>;
|
|
59
|
+
/**
|
|
60
|
+
* Injection key for page head
|
|
61
|
+
*/
|
|
62
|
+
declare const pageHeadSymbol: InjectionKey<PageHeadRef>;
|
|
63
|
+
/**
|
|
64
|
+
* Returns the ref of the head config of current page
|
|
65
|
+
*/
|
|
66
|
+
declare const usePageHead: () => PageHeadRef;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Page head title, which would be used as the content of `head > title` tag
|
|
70
|
+
*/
|
|
71
|
+
type PageHeadTitle = string;
|
|
72
|
+
/**
|
|
73
|
+
* Ref wrapper of `PageHeadTitle`
|
|
74
|
+
*/
|
|
75
|
+
type PageHeadTitleRef = ComputedRef<PageHeadTitle>;
|
|
76
|
+
/**
|
|
77
|
+
* Injection key for page head title
|
|
78
|
+
*/
|
|
79
|
+
declare const pageHeadTitleSymbol: InjectionKey<PageHeadTitleRef>;
|
|
80
|
+
/**
|
|
81
|
+
* Returns the ref of the head title of current page
|
|
82
|
+
*/
|
|
83
|
+
declare const usePageHeadTitle: () => PageHeadTitleRef;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Page language
|
|
87
|
+
*/
|
|
88
|
+
type PageLang = string;
|
|
89
|
+
/**
|
|
90
|
+
* Ref wrapper of `PageLang`
|
|
91
|
+
*/
|
|
92
|
+
type PageLangRef = ComputedRef<PageLang>;
|
|
93
|
+
/**
|
|
94
|
+
* Injection key for page language
|
|
95
|
+
*/
|
|
96
|
+
declare const pageLangSymbol: InjectionKey<PageLangRef>;
|
|
97
|
+
/**
|
|
98
|
+
* Returns the ref of the language of current page
|
|
99
|
+
*/
|
|
100
|
+
declare const usePageLang: () => PageLangRef;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Ref wrapper of `PageLayout`
|
|
104
|
+
*/
|
|
105
|
+
type PageLayoutRef = ComputedRef<Component>;
|
|
106
|
+
/**
|
|
107
|
+
* Injection key for page layout
|
|
108
|
+
*/
|
|
109
|
+
declare const pageLayoutSymbol: InjectionKey<PageLayoutRef>;
|
|
110
|
+
/**
|
|
111
|
+
* Returns layout component of current page
|
|
112
|
+
*/
|
|
113
|
+
declare const usePageLayout: () => ComputedRef<Component>;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Data resolvers of all pages
|
|
117
|
+
*
|
|
118
|
+
* The key is page key, and the value is an async function that
|
|
119
|
+
* returns the page data
|
|
120
|
+
*/
|
|
121
|
+
type PagesData = Record<string, (() => Promise<PageData>) | undefined>;
|
|
122
|
+
/**
|
|
123
|
+
* Ref wrapper of `PagesData`
|
|
124
|
+
*/
|
|
125
|
+
type PagesDataRef = Ref<PagesData>;
|
|
126
|
+
/**
|
|
127
|
+
* Global pages data ref
|
|
128
|
+
*/
|
|
129
|
+
declare const pagesData: PagesDataRef;
|
|
130
|
+
/**
|
|
131
|
+
* Returns the ref of data resolvers of all pages
|
|
132
|
+
*/
|
|
133
|
+
declare const usePagesData: () => PagesDataRef;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Route locale path
|
|
137
|
+
*/
|
|
138
|
+
type RouteLocale = string;
|
|
139
|
+
/**
|
|
140
|
+
* Ref wrapper of `RouteLocale`
|
|
141
|
+
*/
|
|
142
|
+
type RouteLocaleRef = Readonly<Ref<RouteLocale>>;
|
|
143
|
+
/**
|
|
144
|
+
* Injection key for page route locale path
|
|
145
|
+
*/
|
|
146
|
+
declare const routeLocaleSymbol: InjectionKey<RouteLocaleRef>;
|
|
147
|
+
/**
|
|
148
|
+
* Returns the ref of the route locale path of current page
|
|
149
|
+
*/
|
|
150
|
+
declare const useRouteLocale: () => RouteLocaleRef;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Ref wrapper of `SiteData`
|
|
154
|
+
*/
|
|
155
|
+
type SiteDataRef = Ref<SiteData>;
|
|
156
|
+
/**
|
|
157
|
+
* Global site data ref
|
|
158
|
+
*/
|
|
159
|
+
declare const siteData: SiteDataRef;
|
|
160
|
+
/**
|
|
161
|
+
* Returns the ref of the site data
|
|
162
|
+
*/
|
|
163
|
+
declare const useSiteData: () => SiteDataRef;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Site data of current locale
|
|
167
|
+
*/
|
|
168
|
+
type SiteLocaleData = SiteData;
|
|
169
|
+
/**
|
|
170
|
+
* Ref wrapper of `SiteLocaleData`
|
|
171
|
+
*/
|
|
172
|
+
type SiteLocaleDataRef = ComputedRef<SiteLocaleData>;
|
|
173
|
+
/**
|
|
174
|
+
* Injection key for site locale data
|
|
175
|
+
*/
|
|
176
|
+
declare const siteLocaleDataSymbol: InjectionKey<SiteLocaleDataRef>;
|
|
177
|
+
/**
|
|
178
|
+
* Returns the ref of the site data of current locale
|
|
179
|
+
*/
|
|
180
|
+
declare const useSiteLocaleData: () => SiteLocaleDataRef;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* A util function to force update `<head>` of current page
|
|
184
|
+
*/
|
|
185
|
+
type UpdateHead = () => void;
|
|
186
|
+
/**
|
|
187
|
+
* Injection key for `updateHead` util
|
|
188
|
+
*/
|
|
189
|
+
declare const updateHeadSymbol: InjectionKey<UpdateHead>;
|
|
190
|
+
/**
|
|
191
|
+
* Returns the `updateHead` util
|
|
192
|
+
*/
|
|
193
|
+
declare const useUpdateHead: () => UpdateHead;
|
|
194
|
+
|
|
195
|
+
type Layouts = Record<string, Component>;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Configure vuepress client
|
|
199
|
+
*/
|
|
200
|
+
interface ClientConfig {
|
|
201
|
+
/**
|
|
202
|
+
* An enhance function to be called after vue app instance and
|
|
203
|
+
* vue-router instance has been created
|
|
204
|
+
*/
|
|
205
|
+
enhance?: (context: {
|
|
206
|
+
app: App;
|
|
207
|
+
router: Router;
|
|
208
|
+
siteData: SiteDataRef;
|
|
209
|
+
}) => void | Promise<void>;
|
|
210
|
+
/**
|
|
211
|
+
* A function to be called inside the setup function of vue app
|
|
212
|
+
*/
|
|
213
|
+
setup?: () => void;
|
|
214
|
+
/**
|
|
215
|
+
* Layout components
|
|
216
|
+
*/
|
|
217
|
+
layouts?: Layouts;
|
|
218
|
+
/**
|
|
219
|
+
* Components to be placed directly into the root node of vue app
|
|
220
|
+
*/
|
|
221
|
+
rootComponents?: Component[];
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
type PageRouteItem = [
|
|
225
|
+
name: string,
|
|
226
|
+
path: string,
|
|
227
|
+
meta: RouteMeta,
|
|
228
|
+
redirects: string[]
|
|
229
|
+
];
|
|
230
|
+
|
|
231
|
+
declare const ClientOnly: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
232
|
+
[key: string]: any;
|
|
233
|
+
}>[] | null | undefined, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{}>>, {}, {}>;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Markdown rendered content
|
|
237
|
+
*/
|
|
238
|
+
declare const Content: vue.DefineComponent<{
|
|
239
|
+
pageKey: {
|
|
240
|
+
type: StringConstructor;
|
|
241
|
+
required: false;
|
|
242
|
+
default: string;
|
|
243
|
+
};
|
|
244
|
+
}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
245
|
+
[key: string]: any;
|
|
246
|
+
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
247
|
+
pageKey: {
|
|
248
|
+
type: StringConstructor;
|
|
249
|
+
required: false;
|
|
250
|
+
default: string;
|
|
251
|
+
};
|
|
252
|
+
}>>, {
|
|
253
|
+
pageKey: string;
|
|
254
|
+
}, {}>;
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* A helper function to help you define vuepress client config file
|
|
258
|
+
*/
|
|
259
|
+
declare const defineClientConfig: (clientConfig?: ClientConfig) => ClientConfig;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Prefix url with site base
|
|
263
|
+
*/
|
|
264
|
+
declare const withBase: (url: string) => string;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Resolver methods to get global computed
|
|
268
|
+
*
|
|
269
|
+
* Users can override corresponding method for advanced customization
|
|
270
|
+
*/
|
|
271
|
+
declare const resolvers: {
|
|
272
|
+
resolveLayouts: (clientConfigs: ClientConfig[]) => Layouts;
|
|
273
|
+
resolvePageData: (pageKey: string) => Promise<PageData>;
|
|
274
|
+
resolvePageFrontmatter: (pageData: PageData) => PageFrontmatter;
|
|
275
|
+
resolvePageHead: (headTitle: PageHeadTitle, frontmatter: PageFrontmatter, siteLocale: SiteLocaleData) => PageHead;
|
|
276
|
+
resolvePageHeadTitle: (page: PageData, siteLocale: SiteLocaleData) => PageHeadTitle;
|
|
277
|
+
resolvePageLang: (page: PageData, siteLocale: SiteLocaleData) => PageLang;
|
|
278
|
+
resolvePageLayout: (page: PageData, layouts: Layouts) => Component;
|
|
279
|
+
resolveRouteLocale: (locales: SiteData['locales'], routePath: string) => RouteLocale;
|
|
280
|
+
resolveSiteLocaleData: (site: SiteData, routeLocale: RouteLocale) => SiteLocaleData;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
export { type ClientConfig, ClientOnly, Content, type Layouts, type LayoutsRef, type PageDataRef, type PageFrontmatterRef, type PageHead, type PageHeadRef, type PageHeadTitle, type PageHeadTitleRef, type PageLang, type PageLangRef, type PageLayoutRef, type PageRouteItem, type PagesData, type PagesDataRef, type RouteLocale, type RouteLocaleRef, type SiteDataRef, type SiteLocaleData, type SiteLocaleDataRef, type UpdateHead, defineClientConfig, layoutsSymbol, pageDataEmpty, pageDataSymbol, pageFrontmatterSymbol, pageHeadSymbol, pageHeadTitleSymbol, pageLangSymbol, pageLayoutSymbol, pagesData, resolvers, routeLocaleSymbol, siteData, siteLocaleDataSymbol, updateHeadSymbol, useLayouts, usePageData, usePageFrontmatter, usePageHead, usePageHeadTitle, usePageLang, usePageLayout, usePagesData, useRouteLocale, useSiteData, useSiteLocaleData, useUpdateHead, withBase };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ClientOnly,
|
|
3
|
+
Content,
|
|
4
|
+
defineClientConfig,
|
|
5
|
+
layoutsSymbol,
|
|
6
|
+
pageDataEmpty,
|
|
7
|
+
pageDataSymbol,
|
|
8
|
+
pageFrontmatterSymbol,
|
|
9
|
+
pageHeadSymbol,
|
|
10
|
+
pageHeadTitleSymbol,
|
|
11
|
+
pageLangSymbol,
|
|
12
|
+
pageLayoutSymbol,
|
|
13
|
+
pagesData,
|
|
14
|
+
resolvers,
|
|
15
|
+
routeLocaleSymbol,
|
|
16
|
+
siteData,
|
|
17
|
+
siteLocaleDataSymbol,
|
|
18
|
+
updateHeadSymbol,
|
|
19
|
+
useLayouts,
|
|
20
|
+
usePageData,
|
|
21
|
+
usePageFrontmatter,
|
|
22
|
+
usePageHead,
|
|
23
|
+
usePageHeadTitle,
|
|
24
|
+
usePageLang,
|
|
25
|
+
usePageLayout,
|
|
26
|
+
usePagesData,
|
|
27
|
+
useRouteLocale,
|
|
28
|
+
useSiteData,
|
|
29
|
+
useSiteLocaleData,
|
|
30
|
+
useUpdateHead,
|
|
31
|
+
withBase
|
|
32
|
+
} from "./chunk-PEQEPZ75.js";
|
|
33
|
+
export {
|
|
34
|
+
ClientOnly,
|
|
35
|
+
Content,
|
|
36
|
+
defineClientConfig,
|
|
37
|
+
layoutsSymbol,
|
|
38
|
+
pageDataEmpty,
|
|
39
|
+
pageDataSymbol,
|
|
40
|
+
pageFrontmatterSymbol,
|
|
41
|
+
pageHeadSymbol,
|
|
42
|
+
pageHeadTitleSymbol,
|
|
43
|
+
pageLangSymbol,
|
|
44
|
+
pageLayoutSymbol,
|
|
45
|
+
pagesData,
|
|
46
|
+
resolvers,
|
|
47
|
+
routeLocaleSymbol,
|
|
48
|
+
siteData,
|
|
49
|
+
siteLocaleDataSymbol,
|
|
50
|
+
updateHeadSymbol,
|
|
51
|
+
useLayouts,
|
|
52
|
+
usePageData,
|
|
53
|
+
usePageFrontmatter,
|
|
54
|
+
usePageHead,
|
|
55
|
+
usePageHeadTitle,
|
|
56
|
+
usePageLang,
|
|
57
|
+
usePageLayout,
|
|
58
|
+
usePagesData,
|
|
59
|
+
useRouteLocale,
|
|
60
|
+
useSiteData,
|
|
61
|
+
useSiteLocaleData,
|
|
62
|
+
useUpdateHead,
|
|
63
|
+
withBase
|
|
64
|
+
};
|