@vuepress/client 2.0.0-beta.56 → 2.0.0-beta.58

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 CHANGED
@@ -1,23 +1,26 @@
1
1
  import {
2
2
  ClientOnly,
3
3
  Content,
4
+ layoutsSymbol,
4
5
  pageData,
5
6
  pageFrontmatterSymbol,
6
7
  pageHeadSymbol,
7
8
  pageHeadTitleSymbol,
8
9
  pageLangSymbol,
10
+ pageLayoutSymbol,
9
11
  resolvers,
10
12
  routeLocaleSymbol,
11
13
  siteData,
12
14
  siteLocaleDataSymbol,
13
15
  updateHeadSymbol,
14
- usePageData,
15
16
  usePageHead,
16
17
  usePageLang,
18
+ usePageLayout,
17
19
  withBase
18
- } from "./chunk-YRWD2ESJ.js";
20
+ } from "./chunk-2OYZ7FSR.js";
19
21
 
20
22
  // src/app.ts
23
+ import { clientConfigs } from "@internal/clientConfigs";
21
24
  import { createApp, createSSRApp, h as h2 } from "vue";
22
25
  import { RouterView } from "vue-router";
23
26
 
@@ -35,78 +38,47 @@ import {
35
38
  import { pagesRoutes } from "@internal/pagesRoutes";
36
39
 
37
40
  // src/components/Vuepress.ts
38
- import { isString } from "@vuepress/shared";
39
- import { computed, defineComponent, h } from "vue";
40
- var LAYOUT_NAME_DEFAULT = "Layout";
41
- var LAYOUT_NAME_NOT_FOUND = "NotFound";
42
- var createVuepressComponent = async () => {
43
- const { clientConfigs } = await import("@internal/clientConfigs");
44
- const layouts = clientConfigs.reduce(
45
- (prev, item) => ({
46
- ...prev,
47
- ...item.layouts
48
- }),
49
- {}
50
- );
51
- const Vuepress = defineComponent({
52
- name: "Vuepress",
53
- setup() {
54
- const page = usePageData();
55
- const layoutComponent = computed(() => {
56
- let layoutName;
57
- if (page.value.path) {
58
- const frontmatterLayout = page.value.frontmatter.layout;
59
- if (isString(frontmatterLayout)) {
60
- layoutName = frontmatterLayout;
61
- } else {
62
- layoutName = LAYOUT_NAME_DEFAULT;
63
- }
64
- } else {
65
- layoutName = LAYOUT_NAME_NOT_FOUND;
66
- }
67
- return layouts[layoutName];
68
- });
69
- return () => h(layoutComponent.value);
70
- }
71
- });
72
- return Vuepress;
73
- };
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
+ });
74
49
 
75
50
  // src/routes.ts
76
- var createRoutes = async () => {
77
- const Vuepress = await createVuepressComponent();
78
- return pagesRoutes.reduce(
79
- (result, [name, path, meta, redirects]) => {
80
- result.push(
81
- {
82
- name,
83
- path,
84
- component: Vuepress,
85
- meta
86
- },
87
- ...redirects.map((item) => ({
88
- path: item,
89
- redirect: path
90
- }))
91
- );
92
- return result;
93
- },
94
- [
51
+ var createRoutes = () => pagesRoutes.reduce(
52
+ (result, [name, path, meta, redirects]) => {
53
+ result.push(
95
54
  {
96
- name: "404",
97
- path: "/:catchAll(.*)",
98
- component: Vuepress
99
- }
100
- ]
101
- );
102
- };
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
+ );
103
75
 
104
76
  // src/router.ts
105
77
  var historyCreator = __VUEPRESS_SSR__ ? createMemoryHistory : createWebHistory;
106
- var createVueRouter = async () => {
78
+ var createVueRouter = () => {
107
79
  const router = createRouter({
108
- history: historyCreator(removeEndingSlash(siteData.value.base)),
109
- routes: await createRoutes(),
80
+ history: historyCreator(removeEndingSlash(__VUEPRESS_BASE__)),
81
+ routes: createRoutes(),
110
82
  scrollBehavior: (to, from, savedPosition) => {
111
83
  if (savedPosition)
112
84
  return savedPosition;
@@ -134,37 +106,43 @@ var setupGlobalComponents = (app) => {
134
106
  };
135
107
 
136
108
  // src/setupGlobalComputed.ts
137
- import { computed as computed2 } from "vue";
138
- var setupGlobalComputed = (app, router) => {
139
- const routeLocale = computed2(
109
+ import { computed } from "vue";
110
+ var setupGlobalComputed = (app, router, clientConfigs2) => {
111
+ const layouts = computed(() => resolvers.resolveLayouts(clientConfigs2));
112
+ const routeLocale = computed(
140
113
  () => resolvers.resolveRouteLocale(
141
114
  siteData.value.locales,
142
115
  router.currentRoute.value.path
143
116
  )
144
117
  );
145
- const siteLocaleData = computed2(
118
+ const siteLocaleData = computed(
146
119
  () => resolvers.resolveSiteLocaleData(siteData.value, routeLocale.value)
147
120
  );
148
- const pageFrontmatter = computed2(
121
+ const pageFrontmatter = computed(
149
122
  () => resolvers.resolvePageFrontmatter(pageData.value)
150
123
  );
151
- const pageHeadTitle = computed2(
124
+ const pageHeadTitle = computed(
152
125
  () => resolvers.resolvePageHeadTitle(pageData.value, siteLocaleData.value)
153
126
  );
154
- const pageHead = computed2(
127
+ const pageHead = computed(
155
128
  () => resolvers.resolvePageHead(
156
129
  pageHeadTitle.value,
157
130
  pageFrontmatter.value,
158
131
  siteLocaleData.value
159
132
  )
160
133
  );
161
- const pageLang = computed2(() => resolvers.resolvePageLang(pageData.value));
162
- app.provide(routeLocaleSymbol, routeLocale);
163
- app.provide(siteLocaleDataSymbol, siteLocaleData);
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);
164
139
  app.provide(pageFrontmatterSymbol, pageFrontmatter);
165
140
  app.provide(pageHeadTitleSymbol, pageHeadTitle);
166
141
  app.provide(pageHeadSymbol, pageHead);
167
142
  app.provide(pageLangSymbol, pageLang);
143
+ app.provide(pageLayoutSymbol, pageLayout);
144
+ app.provide(routeLocaleSymbol, routeLocale);
145
+ app.provide(siteLocaleDataSymbol, siteLocaleData);
168
146
  Object.defineProperties(app.config.globalProperties, {
169
147
  $frontmatter: { get: () => pageFrontmatter.value },
170
148
  $head: { get: () => pageHead.value },
@@ -177,11 +155,13 @@ var setupGlobalComputed = (app, router) => {
177
155
  $withBase: { get: () => withBase }
178
156
  });
179
157
  return {
158
+ layouts,
180
159
  pageData,
181
160
  pageFrontmatter,
182
161
  pageHead,
183
162
  pageHeadTitle,
184
163
  pageLang,
164
+ pageLayout,
185
165
  routeLocale,
186
166
  siteData,
187
167
  siteLocaleData
@@ -189,7 +169,7 @@ var setupGlobalComputed = (app, router) => {
189
169
  };
190
170
 
191
171
  // src/setupUpdateHead.ts
192
- import { isPlainObject, isString as isString2 } from "@vuepress/shared";
172
+ import { isPlainObject, isString } from "@vuepress/shared";
193
173
  import { onMounted, provide, ref, useSSRContext, watch } from "vue";
194
174
  import { useRoute } from "vue-router";
195
175
  var setupUpdateHead = () => {
@@ -245,7 +225,7 @@ var queryHeadTag = ([
245
225
  content = ""
246
226
  ]) => {
247
227
  const attrsSelector = Object.entries(attrs).map(([key, value]) => {
248
- if (isString2(value)) {
228
+ if (isString(value)) {
249
229
  return `[${key}=${JSON.stringify(value)}]`;
250
230
  }
251
231
  if (value === true) {
@@ -263,20 +243,20 @@ var createHeadTag = ([
263
243
  attrs,
264
244
  content
265
245
  ]) => {
266
- if (!isString2(tagName)) {
246
+ if (!isString(tagName)) {
267
247
  return null;
268
248
  }
269
249
  const tag = document.createElement(tagName);
270
250
  if (isPlainObject(attrs)) {
271
251
  Object.entries(attrs).forEach(([key, value]) => {
272
- if (isString2(value)) {
252
+ if (isString(value)) {
273
253
  tag.setAttribute(key, value);
274
254
  } else if (value === true) {
275
255
  tag.setAttribute(key, "");
276
256
  }
277
257
  });
278
258
  }
279
- if (isString2(content)) {
259
+ if (isString(content)) {
280
260
  tag.appendChild(document.createTextNode(content));
281
261
  }
282
262
  return tag;
@@ -285,7 +265,6 @@ var createHeadTag = ([
285
265
  // src/app.ts
286
266
  var appCreator = __VUEPRESS_DEV__ ? createApp : createSSRApp;
287
267
  var createVueApp = async () => {
288
- const { clientConfigs } = await import("@internal/clientConfigs");
289
268
  const app = appCreator({
290
269
  name: "VuepressApp",
291
270
  setup() {
@@ -301,9 +280,9 @@ var createVueApp = async () => {
301
280
  ];
302
281
  }
303
282
  });
304
- const router = await createVueRouter();
283
+ const router = createVueRouter();
305
284
  setupGlobalComponents(app);
306
- const globalComputed = setupGlobalComputed(app, router);
285
+ const globalComputed = setupGlobalComputed(app, router, clientConfigs);
307
286
  if (__VUEPRESS_DEV__ || __VUE_PROD_DEVTOOLS__) {
308
287
  const { setupDevtools } = await import("./setupDevtools-EXVHPMXB.js");
309
288
  setupDevtools(app, globalComputed);
@@ -1,3 +1,16 @@
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
+
1
14
  // src/composables/pagesData.ts
2
15
  import { pagesData as pagesDataRaw } from "@internal/pagesData";
3
16
  import { ref } from "vue";
@@ -12,7 +25,6 @@ var pageDataEmpty = readonly({
12
25
  title: "",
13
26
  lang: "",
14
27
  frontmatter: {},
15
- excerpt: "",
16
28
  headers: []
17
29
  });
18
30
  var pageData = ref2(pageDataEmpty);
@@ -27,12 +39,12 @@ if (__VUEPRESS_DEV__ && (import.meta.webpackHot || import.meta.hot)) {
27
39
  }
28
40
 
29
41
  // src/composables/pageFrontmatter.ts
30
- import { inject } from "vue";
42
+ import { inject as inject2 } from "vue";
31
43
  var pageFrontmatterSymbol = Symbol(
32
44
  __VUEPRESS_DEV__ ? "pageFrontmatter" : ""
33
45
  );
34
46
  var usePageFrontmatter = () => {
35
- const pageFrontmatter = inject(pageFrontmatterSymbol);
47
+ const pageFrontmatter = inject2(pageFrontmatterSymbol);
36
48
  if (!pageFrontmatter) {
37
49
  throw new Error("usePageFrontmatter() is called without provider.");
38
50
  }
@@ -40,12 +52,12 @@ var usePageFrontmatter = () => {
40
52
  };
41
53
 
42
54
  // src/composables/pageHead.ts
43
- import { inject as inject2 } from "vue";
55
+ import { inject as inject3 } from "vue";
44
56
  var pageHeadSymbol = Symbol(
45
57
  __VUEPRESS_DEV__ ? "pageHead" : ""
46
58
  );
47
59
  var usePageHead = () => {
48
- const pageHead = inject2(pageHeadSymbol);
60
+ const pageHead = inject3(pageHeadSymbol);
49
61
  if (!pageHead) {
50
62
  throw new Error("usePageHead() is called without provider.");
51
63
  }
@@ -53,12 +65,12 @@ var usePageHead = () => {
53
65
  };
54
66
 
55
67
  // src/composables/pageHeadTitle.ts
56
- import { inject as inject3 } from "vue";
68
+ import { inject as inject4 } from "vue";
57
69
  var pageHeadTitleSymbol = Symbol(
58
70
  __VUEPRESS_DEV__ ? "pageHeadTitle" : ""
59
71
  );
60
72
  var usePageHeadTitle = () => {
61
- const pageHeadTitle = inject3(pageHeadTitleSymbol);
73
+ const pageHeadTitle = inject4(pageHeadTitleSymbol);
62
74
  if (!pageHeadTitle) {
63
75
  throw new Error("usePageHeadTitle() is called without provider.");
64
76
  }
@@ -66,25 +78,40 @@ var usePageHeadTitle = () => {
66
78
  };
67
79
 
68
80
  // src/composables/pageLang.ts
69
- import { inject as inject4 } from "vue";
81
+ import { inject as inject5 } from "vue";
70
82
  var pageLangSymbol = Symbol(
71
83
  __VUEPRESS_DEV__ ? "pageLang" : ""
72
84
  );
73
85
  var usePageLang = () => {
74
- const pageLang = inject4(pageLangSymbol);
86
+ const pageLang = inject5(pageLangSymbol);
75
87
  if (!pageLang) {
76
88
  throw new Error("usePageLang() is called without provider.");
77
89
  }
78
90
  return pageLang;
79
91
  };
80
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
+
81
108
  // src/composables/routeLocale.ts
82
- import { inject as inject5 } from "vue";
109
+ import { inject as inject7 } from "vue";
83
110
  var routeLocaleSymbol = Symbol(
84
111
  __VUEPRESS_DEV__ ? "routeLocale" : ""
85
112
  );
86
113
  var useRouteLocale = () => {
87
- const routeLocale = inject5(routeLocaleSymbol);
114
+ const routeLocale = inject7(routeLocaleSymbol);
88
115
  if (!routeLocale) {
89
116
  throw new Error("useRouteLocale() is called without provider.");
90
117
  }
@@ -103,12 +130,12 @@ if (__VUEPRESS_DEV__ && (import.meta.webpackHot || import.meta.hot)) {
103
130
  }
104
131
 
105
132
  // src/composables/siteLocaleData.ts
106
- import { inject as inject6 } from "vue";
133
+ import { inject as inject8 } from "vue";
107
134
  var siteLocaleDataSymbol = Symbol(
108
135
  __VUEPRESS_DEV__ ? "siteLocaleData" : ""
109
136
  );
110
137
  var useSiteLocaleData = () => {
111
- const siteLocaleData = inject6(siteLocaleDataSymbol);
138
+ const siteLocaleData = inject8(siteLocaleDataSymbol);
112
139
  if (!siteLocaleData) {
113
140
  throw new Error("useSiteLocaleData() is called without provider.");
114
141
  }
@@ -116,12 +143,12 @@ var useSiteLocaleData = () => {
116
143
  };
117
144
 
118
145
  // src/composables/updateHead.ts
119
- import { inject as inject7 } from "vue";
146
+ import { inject as inject9 } from "vue";
120
147
  var updateHeadSymbol = Symbol(
121
148
  __VUEPRESS_DEV__ ? "updateHead" : ""
122
149
  );
123
150
  var useUpdateHead = () => {
124
- const updateHead = inject7(updateHeadSymbol);
151
+ const updateHead = inject9(updateHeadSymbol);
125
152
  if (!updateHead) {
126
153
  throw new Error("useUpdateHead() is called without provider.");
127
154
  }
@@ -136,7 +163,20 @@ import {
136
163
  resolveLocalePath
137
164
  } from "@vuepress/shared";
138
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
139
172
  var resolvers = reactive({
173
+ resolveLayouts: (clientConfigs) => clientConfigs.reduce(
174
+ (prev, item) => ({
175
+ ...prev,
176
+ ...item.layouts
177
+ }),
178
+ {}
179
+ ),
140
180
  resolvePageData: async (pageKey) => {
141
181
  const pageDataResolver = pagesData.value[pageKey];
142
182
  const pageData2 = await pageDataResolver?.();
@@ -154,7 +194,21 @@ var resolvers = reactive({
154
194
  return dedupeHead(head);
155
195
  },
156
196
  resolvePageHeadTitle: (page, siteLocale) => `${page.title ? `${page.title}` : ``}${siteLocale.title ? ` | ${siteLocale.title}` : ``}`,
157
- resolvePageLang: (pageData2) => pageData2.lang || "en",
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
+ },
158
212
  resolveRouteLocale: (locales, routePath) => resolveLocalePath(locales, routePath),
159
213
  resolveSiteLocaleData: (site, routeLocale) => ({
160
214
  ...site,
@@ -199,16 +253,20 @@ var Content = defineComponent2({
199
253
  }
200
254
  });
201
255
 
202
- // src/withBase.ts
256
+ // src/helpers/defineClientConfig.ts
257
+ var defineClientConfig = (clientConfig = {}) => clientConfig;
258
+
259
+ // src/helpers/withBase.ts
203
260
  import { isLinkHttp, removeLeadingSlash } from "@vuepress/shared";
204
261
  var withBase = (url) => {
205
262
  if (isLinkHttp(url))
206
263
  return url;
207
- const base = useSiteData().value.base;
208
- return `${base}${removeLeadingSlash(url)}`;
264
+ return `${__VUEPRESS_BASE__}${removeLeadingSlash(url)}`;
209
265
  };
210
266
 
211
267
  export {
268
+ layoutsSymbol,
269
+ useLayouts,
212
270
  pagesData,
213
271
  usePagesData,
214
272
  pageDataEmpty,
@@ -222,6 +280,8 @@ export {
222
280
  usePageHeadTitle,
223
281
  pageLangSymbol,
224
282
  usePageLang,
283
+ pageLayoutSymbol,
284
+ usePageLayout,
225
285
  routeLocaleSymbol,
226
286
  useRouteLocale,
227
287
  siteData,
@@ -233,5 +293,6 @@ export {
233
293
  resolvers,
234
294
  ClientOnly,
235
295
  Content,
296
+ defineClientConfig,
236
297
  withBase
237
298
  };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PageData, PageFrontmatter, HeadConfig, SiteData } from '@vuepress/shared';
2
2
  export { PageData, PageFrontmatter, PageHeader, SiteData } from '@vuepress/shared';
3
3
  import * as vue from 'vue';
4
- import { Ref, ComputedRef, InjectionKey, App, Component } from 'vue';
4
+ import { Component, App, ComputedRef, InjectionKey, Ref } from 'vue';
5
5
  import { Router, RouteMeta } from 'vue-router';
6
6
 
7
7
  declare const ClientOnly: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
@@ -29,6 +29,60 @@ declare const Content: vue.DefineComponent<{
29
29
  pageKey: string;
30
30
  }>;
31
31
 
32
+ type Layouts = Record<string, Component>;
33
+
34
+ /**
35
+ * Configure vuepress client
36
+ */
37
+ interface ClientConfig {
38
+ /**
39
+ * An enhance function to be called after vue app instance and
40
+ * vue-router instance has been created
41
+ */
42
+ enhance?: (context: {
43
+ app: App;
44
+ router: Router;
45
+ siteData: SiteDataRef;
46
+ }) => void | Promise<void>;
47
+ /**
48
+ * A function to be called inside the setup function of vue app
49
+ */
50
+ setup?: () => void;
51
+ /**
52
+ * Layout components
53
+ */
54
+ layouts?: Layouts;
55
+ /**
56
+ * Components to be placed directly into the root node of vue app
57
+ */
58
+ rootComponents?: Component[];
59
+ }
60
+
61
+ type CreateVueAppFunction = () => Promise<{
62
+ app: App;
63
+ router: Router;
64
+ }>;
65
+
66
+ type PageRouteItem = [
67
+ name: string,
68
+ path: string,
69
+ meta: RouteMeta,
70
+ redirects: string[]
71
+ ];
72
+
73
+ /**
74
+ * Ref wrapper of `Layouts`
75
+ */
76
+ type LayoutsRef = ComputedRef<Layouts>;
77
+ /**
78
+ * Injection key for layouts
79
+ */
80
+ declare const layoutsSymbol: InjectionKey<LayoutsRef>;
81
+ /**
82
+ * Returns layouts component map
83
+ */
84
+ declare const useLayouts: () => LayoutsRef;
85
+
32
86
  /**
33
87
  * Ref wrapper of `PageData`
34
88
  */
@@ -110,6 +164,19 @@ declare const pageLangSymbol: InjectionKey<PageLangRef>;
110
164
  */
111
165
  declare const usePageLang: () => PageLangRef;
112
166
 
167
+ /**
168
+ * Ref wrapper of `PageLayout`
169
+ */
170
+ type PageLayoutRef = ComputedRef<Component>;
171
+ /**
172
+ * Injection key for page layout
173
+ */
174
+ declare const pageLayoutSymbol: InjectionKey<PageLayoutRef>;
175
+ /**
176
+ * Returns layout component of current page
177
+ */
178
+ declare const usePageLayout: () => ComputedRef<Component>;
179
+
113
180
  /**
114
181
  * Data resolvers of all pages
115
182
  *
@@ -191,48 +258,14 @@ declare const updateHeadSymbol: InjectionKey<UpdateHead>;
191
258
  declare const useUpdateHead: () => UpdateHead;
192
259
 
193
260
  /**
194
- * Configure vuepress client
261
+ * A helper function to help you define vuepress client config file
195
262
  */
196
- interface ClientConfig {
197
- /**
198
- * An enhance function to be called after vue app instance and
199
- * vue-router instance has been created
200
- */
201
- enhance?: (context: {
202
- app: App;
203
- router: Router;
204
- siteData: SiteDataRef;
205
- }) => void | Promise<void>;
206
- /**
207
- * A function to be called inside the setup function of vue app
208
- */
209
- setup?: () => void;
210
- /**
211
- * Layout components
212
- */
213
- layouts?: Record<string, Component>;
214
- /**
215
- * Components to be placed directly into the root node of vue app
216
- */
217
- rootComponents?: Component[];
218
- }
219
-
220
- type CreateVueAppFunction = () => Promise<{
221
- app: App;
222
- router: Router;
223
- }>;
224
-
225
- type PageRouteItem = [
226
- name: string,
227
- path: string,
228
- meta: RouteMeta,
229
- redirects: string[]
230
- ];
263
+ declare const defineClientConfig: (clientConfig?: ClientConfig) => ClientConfig;
231
264
 
232
265
  /**
233
- * A helper function to help you define vuepress client config file
266
+ * Prefix url with site base
234
267
  */
235
- declare const defineClientConfig: (clientConfig?: ClientConfig) => ClientConfig;
268
+ declare const withBase: (url: string) => string;
236
269
 
237
270
  /**
238
271
  * Resolver methods to get global computed
@@ -240,18 +273,15 @@ declare const defineClientConfig: (clientConfig?: ClientConfig) => ClientConfig;
240
273
  * Users can override corresponding method for advanced customization
241
274
  */
242
275
  declare const resolvers: {
276
+ resolveLayouts: (clientConfigs: ClientConfig[]) => Layouts;
243
277
  resolvePageData: (pageKey: string) => Promise<PageData>;
244
278
  resolvePageFrontmatter: (pageData: PageData) => PageFrontmatter;
245
279
  resolvePageHead: (headTitle: PageHeadTitle, frontmatter: PageFrontmatter, siteLocale: SiteLocaleData) => PageHead;
246
280
  resolvePageHeadTitle: (page: PageData, siteLocale: SiteLocaleData) => PageHeadTitle;
247
- resolvePageLang: (pageData: PageData) => PageLang;
281
+ resolvePageLang: (page: PageData) => PageLang;
282
+ resolvePageLayout: (page: PageData, layouts: Layouts) => Component;
248
283
  resolveRouteLocale: (locales: SiteData['locales'], routePath: string) => RouteLocale;
249
284
  resolveSiteLocaleData: (site: SiteData, routeLocale: RouteLocale) => SiteLocaleData;
250
285
  };
251
286
 
252
- /**
253
- * Prefix url with site base
254
- */
255
- declare const withBase: (url: string) => string;
256
-
257
- export { ClientConfig, ClientOnly, Content, CreateVueAppFunction, PageDataRef, PageFrontmatterRef, PageHead, PageHeadRef, PageHeadTitle, PageHeadTitleRef, PageLang, PageLangRef, PageRouteItem, PagesData, PagesDataRef, RouteLocale, RouteLocaleRef, SiteDataRef, SiteLocaleData, SiteLocaleDataRef, UpdateHead, defineClientConfig, pageData, pageDataEmpty, pageFrontmatterSymbol, pageHeadSymbol, pageHeadTitleSymbol, pageLangSymbol, pagesData, resolvers, routeLocaleSymbol, siteData, siteLocaleDataSymbol, updateHeadSymbol, usePageData, usePageFrontmatter, usePageHead, usePageHeadTitle, usePageLang, usePagesData, useRouteLocale, useSiteData, useSiteLocaleData, useUpdateHead, withBase };
287
+ export { ClientConfig, ClientOnly, Content, CreateVueAppFunction, Layouts, LayoutsRef, PageDataRef, PageFrontmatterRef, PageHead, PageHeadRef, PageHeadTitle, PageHeadTitleRef, PageLang, PageLangRef, PageLayoutRef, PageRouteItem, PagesData, PagesDataRef, RouteLocale, RouteLocaleRef, SiteDataRef, SiteLocaleData, SiteLocaleDataRef, UpdateHead, defineClientConfig, layoutsSymbol, pageData, pageDataEmpty, 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 CHANGED
@@ -1,54 +1,60 @@
1
1
  import {
2
2
  ClientOnly,
3
3
  Content,
4
+ defineClientConfig,
5
+ layoutsSymbol,
4
6
  pageData,
5
7
  pageDataEmpty,
6
8
  pageFrontmatterSymbol,
7
9
  pageHeadSymbol,
8
10
  pageHeadTitleSymbol,
9
11
  pageLangSymbol,
12
+ pageLayoutSymbol,
10
13
  pagesData,
11
14
  resolvers,
12
15
  routeLocaleSymbol,
13
16
  siteData,
14
17
  siteLocaleDataSymbol,
15
18
  updateHeadSymbol,
19
+ useLayouts,
16
20
  usePageData,
17
21
  usePageFrontmatter,
18
22
  usePageHead,
19
23
  usePageHeadTitle,
20
24
  usePageLang,
25
+ usePageLayout,
21
26
  usePagesData,
22
27
  useRouteLocale,
23
28
  useSiteData,
24
29
  useSiteLocaleData,
25
30
  useUpdateHead,
26
31
  withBase
27
- } from "./chunk-YRWD2ESJ.js";
28
-
29
- // src/helpers/defineClientConfig.ts
30
- var defineClientConfig = (clientConfig = {}) => clientConfig;
32
+ } from "./chunk-2OYZ7FSR.js";
31
33
  export {
32
34
  ClientOnly,
33
35
  Content,
34
36
  defineClientConfig,
37
+ layoutsSymbol,
35
38
  pageData,
36
39
  pageDataEmpty,
37
40
  pageFrontmatterSymbol,
38
41
  pageHeadSymbol,
39
42
  pageHeadTitleSymbol,
40
43
  pageLangSymbol,
44
+ pageLayoutSymbol,
41
45
  pagesData,
42
46
  resolvers,
43
47
  routeLocaleSymbol,
44
48
  siteData,
45
49
  siteLocaleDataSymbol,
46
50
  updateHeadSymbol,
51
+ useLayouts,
47
52
  usePageData,
48
53
  usePageFrontmatter,
49
54
  usePageHead,
50
55
  usePageHeadTitle,
51
56
  usePageLang,
57
+ usePageLayout,
52
58
  usePagesData,
53
59
  useRouteLocale,
54
60
  useSiteData,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/client",
3
- "version": "2.0.0-beta.56",
3
+ "version": "2.0.0-beta.58",
4
4
  "description": "Client package of VuePress",
5
5
  "keywords": [
6
6
  "vuepress",
@@ -36,7 +36,7 @@
36
36
  "@vue/devtools-api": "^6.4.5",
37
37
  "vue": "^3.2.45",
38
38
  "vue-router": "^4.1.6",
39
- "@vuepress/shared": "2.0.0-beta.56"
39
+ "@vuepress/shared": "2.0.0-beta.58"
40
40
  },
41
41
  "publishConfig": {
42
42
  "access": "public"
package/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  declare const __VUEPRESS_VERSION__: string
2
+ declare const __VUEPRESS_BASE__: string
2
3
  declare const __VUEPRESS_DEV__: boolean
3
4
  declare const __VUEPRESS_SSR__: boolean
4
5
  declare const __VUE_HMR_RUNTIME__: Record<string, any>