@vuepress/client 2.0.0-rc.3 → 2.0.0-rc.5

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,7 +1,7 @@
1
1
  import {
2
2
  ClientOnly,
3
3
  Content,
4
- VPLink,
4
+ RouteLink,
5
5
  layoutsSymbol,
6
6
  pageDataSymbol,
7
7
  pageFrontmatterSymbol,
@@ -20,12 +20,11 @@ import {
20
20
  usePageLang,
21
21
  usePageLayout,
22
22
  withBase
23
- } from "./chunk-2SMBJWK6.js";
23
+ } from "./chunk-VSQZBVKH.js";
24
24
 
25
25
  // src/app.ts
26
26
  import { clientConfigs } from "@internal/clientConfigs";
27
- import { createApp, createSSRApp, h as h2 } from "vue";
28
- import { RouterView } from "vue-router";
27
+ import { createApp, createSSRApp, h } from "vue";
29
28
 
30
29
  // src/createVueRouter.ts
31
30
  import { removeEndingSlash } from "@vuepress/shared";
@@ -35,18 +34,6 @@ import {
35
34
  createWebHistory,
36
35
  START_LOCATION
37
36
  } from "vue-router";
38
-
39
- // src/components/Vuepress.ts
40
- import { defineComponent, h } from "vue";
41
- var Vuepress = defineComponent({
42
- name: "Vuepress",
43
- setup() {
44
- const layout = usePageLayout();
45
- return () => h(layout.value);
46
- }
47
- });
48
-
49
- // src/createVueRouter.ts
50
37
  var historyCreator = __VUEPRESS_SSR__ ? createMemoryHistory : createWebHistory;
51
38
  var createVueRouter = () => {
52
39
  const router = createRouter({
@@ -56,7 +43,7 @@ var createVueRouter = () => {
56
43
  {
57
44
  name: "vuepress-route",
58
45
  path: "/:catchAll(.*)",
59
- component: Vuepress
46
+ components: {}
60
47
  }
61
48
  ],
62
49
  scrollBehavior: (to, _from, savedPosition) => {
@@ -89,7 +76,7 @@ var createVueRouter = () => {
89
76
  var setupGlobalComponents = (app) => {
90
77
  app.component("ClientOnly", ClientOnly);
91
78
  app.component("Content", Content);
92
- app.component("VPLink", VPLink);
79
+ app.component("RouteLink", RouteLink);
93
80
  };
94
81
 
95
82
  // src/setupGlobalComputed.ts
@@ -284,18 +271,17 @@ var createHeadElement = ([
284
271
  var appCreator = __VUEPRESS_DEV__ ? createApp : createSSRApp;
285
272
  var createVueApp = async () => {
286
273
  const app = appCreator({
287
- name: "VuepressApp",
274
+ name: "Vuepress",
288
275
  setup() {
289
276
  setupUpdateHead();
290
277
  for (const clientConfig of clientConfigs) {
291
278
  clientConfig.setup?.();
292
279
  }
293
- return () => [
294
- h2(RouterView),
295
- ...clientConfigs.flatMap(
296
- ({ rootComponents = [] }) => rootComponents.map((component) => h2(component))
297
- )
298
- ];
280
+ const rootComponents = clientConfigs.flatMap(
281
+ ({ rootComponents: rootComponents2 = [] }) => rootComponents2.map((component) => h(component))
282
+ );
283
+ const layout = usePageLayout();
284
+ return () => [h(layout.value), rootComponents];
299
285
  }
300
286
  });
301
287
  const router = createVueRouter();
@@ -111,12 +111,12 @@ import { shallowRef } from "vue";
111
111
  var redirects = shallowRef(redirectsRaw);
112
112
  var routes = shallowRef(routesRaw);
113
113
  if (__VUEPRESS_DEV__ && (import.meta.webpackHot || import.meta.hot)) {
114
- __VUE_HMR_RUNTIME__.updateRoutes = (data) => {
115
- routes.value = data;
116
- };
117
114
  __VUE_HMR_RUNTIME__.updateRedirects = (data) => {
118
115
  redirects.value = data;
119
116
  };
117
+ __VUE_HMR_RUNTIME__.updateRoutes = (data) => {
118
+ routes.value = data;
119
+ };
120
120
  }
121
121
 
122
122
  // src/router/resolveRoutePath.ts
@@ -232,7 +232,7 @@ var withBase = (url) => {
232
232
  return `${__VUEPRESS_BASE__}${removeLeadingSlash(url)}`;
233
233
  };
234
234
 
235
- // src/components/VPLink.ts
235
+ // src/components/RouteLink.ts
236
236
  import { h as h2 } from "vue";
237
237
  import { useRouter } from "vue-router";
238
238
  var guardEvent = (event) => {
@@ -250,13 +250,14 @@ var guardEvent = (event) => {
250
250
  event.preventDefault();
251
251
  return true;
252
252
  };
253
- var VPLink = ({ to = "" }, { slots }) => {
253
+ var RouteLink = ({ active = false, activeClass = "route-link-active", to, ...attrs }, { slots }) => {
254
254
  const router = useRouter();
255
255
  const path = withBase(resolveRoutePath(to));
256
256
  return h2(
257
257
  "a",
258
258
  {
259
- class: "vp-link",
259
+ ...attrs,
260
+ class: ["route-link", { [activeClass]: active }],
260
261
  href: path,
261
262
  onClick: (event = {}) => {
262
263
  guardEvent(event) ? router.push(to).catch() : Promise.resolve();
@@ -265,7 +266,12 @@ var VPLink = ({ to = "" }, { slots }) => {
265
266
  slots.default?.()
266
267
  );
267
268
  };
268
- VPLink.displayName = "VPLink";
269
+ RouteLink.displayName = "RouteLink";
270
+ RouteLink.props = {
271
+ active: Boolean,
272
+ activeClass: String,
273
+ to: String
274
+ };
269
275
 
270
276
  // src/resolvers.ts
271
277
  import { dedupeHead, isString, resolveLocalePath } from "@vuepress/shared";
@@ -389,6 +395,6 @@ export {
389
395
  Content,
390
396
  defineClientConfig,
391
397
  withBase,
392
- VPLink,
398
+ RouteLink,
393
399
  resolvers
394
400
  };
package/dist/index.d.ts CHANGED
@@ -1,9 +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 { ComputedRef, InjectionKey, Ref, Component, App, FunctionalComponent, VNode } from 'vue';
5
- import { Redirects, Routes, PageMetaDefault, Route } from '@internal/routes';
6
- export { PageChunk, PageMetaDefault, Redirects, Route, Routes } from '@internal/routes';
4
+ import { ComputedRef, InjectionKey, Ref, Component, App, ComponentOptions, HTMLAttributes, FunctionalComponent, VNode } from 'vue';
7
5
  import { Router } from 'vue-router';
8
6
  export { C as CreateVueAppFunction } from './createVueAppFunction-YNGNKfE3.js';
9
7
 
@@ -127,29 +125,29 @@ declare const routeLocaleSymbol: InjectionKey<RouteLocaleRef>;
127
125
  */
128
126
  declare const useRouteLocale: () => RouteLocaleRef;
129
127
 
130
- /**
131
- * Global redirects ref
132
- */
133
- declare const redirects: Ref<Redirects>;
134
- /**
135
- * Global routes ref
136
- */
137
- declare const routes: Ref<Routes>;
138
-
139
- interface ResolvedRoute<PageMeta extends PageMetaDefault = PageMetaDefault> extends Route<PageMeta> {
128
+ interface ResolvedRoute<T extends RouteMeta = RouteMeta> extends Route<T> {
140
129
  path: string;
141
130
  notFound: boolean;
142
131
  }
143
132
  /**
144
133
  * Resolve route with given path
145
134
  */
146
- declare const resolveRoute: <PageMeta extends PageMetaDefault = PageMetaDefault>(path: string) => ResolvedRoute<PageMeta>;
135
+ declare const resolveRoute: <T extends RouteMeta = RouteMeta>(path: string) => ResolvedRoute<T>;
147
136
 
148
137
  /**
149
138
  * Resolve route path with given raw path
150
139
  */
151
140
  declare const resolveRoutePath: (path: string) => string;
152
141
 
142
+ /**
143
+ * Global redirects ref
144
+ */
145
+ declare const redirects: Ref<Redirects>;
146
+ /**
147
+ * Global routes ref
148
+ */
149
+ declare const routes: Ref<Routes>;
150
+
153
151
  /**
154
152
  * Returns the ref of pages map
155
153
  */
@@ -231,6 +229,21 @@ interface ClientConfig {
231
229
  rootComponents?: Component[];
232
230
  }
233
231
 
232
+ interface PageChunk {
233
+ comp: ComponentOptions;
234
+ data: PageData;
235
+ }
236
+ type RouteMeta = Record<string, unknown>;
237
+ interface Route<T extends RouteMeta = RouteMeta> {
238
+ loader: () => Promise<PageChunk>;
239
+ meta: T;
240
+ }
241
+ type Redirects = Record<string, string>;
242
+ type Routes = Record<string, Route>;
243
+
244
+ /**
245
+ * Wrapper component that only renders its content on the client side and skips server side rendering
246
+ */
234
247
  declare const ClientOnly: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
235
248
  [key: string]: any;
236
249
  }>[] | null | undefined, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{}>>, {}, {}>;
@@ -256,10 +269,34 @@ declare const Content: vue.DefineComponent<{
256
269
  path: string;
257
270
  }, {}>;
258
271
 
259
- interface VPLinkProps {
272
+ interface RouteLinkProps extends HTMLAttributes {
273
+ /**
274
+ * Whether the link is active to have an active class
275
+ *
276
+ * Notice that the active status is not automatically determined according to the current route.
277
+ *
278
+ * @default false
279
+ */
280
+ active?: boolean;
281
+ /**
282
+ * The class to add when the link is active
283
+ *
284
+ * @default 'route-link-active'
285
+ */
286
+ activeClass?: string;
287
+ /**
288
+ * The route path to link to
289
+ */
260
290
  to: string;
261
291
  }
262
- declare const VPLink: FunctionalComponent<VPLinkProps, Record<never, never>, {
292
+ /**
293
+ * Component to render a link to another route.
294
+ *
295
+ * It's similar to `RouterLink` in `vue-router`, but more lightweight.
296
+ *
297
+ * It's recommended to use `RouteLink` in VuePress.
298
+ */
299
+ declare const RouteLink: FunctionalComponent<RouteLinkProps, Record<never, never>, {
263
300
  default: () => string | VNode | (string | VNode)[];
264
301
  }>;
265
302
 
@@ -291,4 +328,4 @@ declare const resolvers: {
291
328
  resolveSiteLocaleData: (site: SiteData, routeLocale: RouteLocale) => SiteLocaleData;
292
329
  };
293
330
 
294
- 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 RouteLocale, type RouteLocaleRef, type SiteDataRef, type SiteLocaleData, type SiteLocaleDataRef, type UpdateHead, VPLink, type VPLinkProps, defineClientConfig, layoutsSymbol, pageDataSymbol, pageFrontmatterSymbol, pageHeadSymbol, pageHeadTitleSymbol, pageLangSymbol, pageLayoutSymbol, redirects, resolveRoute, resolveRoutePath, resolvers, routeLocaleSymbol, routes, siteData, siteLocaleDataSymbol, updateHeadSymbol, useLayouts, usePageData, usePageFrontmatter, usePageHead, usePageHeadTitle, usePageLang, usePageLayout, useRedirects, useRouteLocale, useRoutes, useSiteData, useSiteLocaleData, useUpdateHead, withBase };
331
+ export { type ClientConfig, ClientOnly, Content, type Layouts, type LayoutsRef, type PageChunk, type PageDataRef, type PageFrontmatterRef, type PageHead, type PageHeadRef, type PageHeadTitle, type PageHeadTitleRef, type PageLang, type PageLangRef, type PageLayoutRef, type Redirects, type Route, RouteLink, type RouteLinkProps, type RouteLocale, type RouteLocaleRef, type RouteMeta, type Routes, type SiteDataRef, type SiteLocaleData, type SiteLocaleDataRef, type UpdateHead, defineClientConfig, layoutsSymbol, pageDataSymbol, pageFrontmatterSymbol, pageHeadSymbol, pageHeadTitleSymbol, pageLangSymbol, pageLayoutSymbol, redirects, resolveRoute, resolveRoutePath, resolvers, routeLocaleSymbol, routes, siteData, siteLocaleDataSymbol, updateHeadSymbol, useLayouts, usePageData, usePageFrontmatter, usePageHead, usePageHeadTitle, usePageLang, usePageLayout, useRedirects, useRouteLocale, useRoutes, useSiteData, useSiteLocaleData, useUpdateHead, withBase };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ClientOnly,
3
3
  Content,
4
- VPLink,
4
+ RouteLink,
5
5
  defineClientConfig,
6
6
  layoutsSymbol,
7
7
  pageDataSymbol,
@@ -33,11 +33,11 @@ import {
33
33
  useSiteLocaleData,
34
34
  useUpdateHead,
35
35
  withBase
36
- } from "./chunk-2SMBJWK6.js";
36
+ } from "./chunk-VSQZBVKH.js";
37
37
  export {
38
38
  ClientOnly,
39
39
  Content,
40
- VPLink,
40
+ RouteLink,
41
41
  defineClientConfig,
42
42
  layoutsSymbol,
43
43
  pageDataSymbol,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/client",
3
- "version": "2.0.0-rc.3",
3
+ "version": "2.0.0-rc.5",
4
4
  "description": "Client package of VuePress",
5
5
  "keywords": [
6
6
  "vuepress",
@@ -37,7 +37,7 @@
37
37
  "@vueuse/core": "^10.7.2",
38
38
  "vue": "^3.4.15",
39
39
  "vue-router": "^4.2.5",
40
- "@vuepress/shared": "2.0.0-rc.3"
40
+ "@vuepress/shared": "2.0.0-rc.5"
41
41
  },
42
42
  "publishConfig": {
43
43
  "access": "public"