@vuepress/client 2.0.0-rc.4 → 2.0.0-rc.6

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-6BD5VZ74.js";
23
+ } from "./chunk-FKY5ACNS.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();
@@ -145,6 +145,9 @@ var resolveRoute = (path) => {
145
145
  };
146
146
  };
147
147
 
148
+ // src/router/index.ts
149
+ import { useRoute, useRouter } from "vue-router";
150
+
148
151
  // src/composables/routes.ts
149
152
  var useRedirects = () => redirects;
150
153
  var useRoutes = () => routes;
@@ -232,9 +235,9 @@ var withBase = (url) => {
232
235
  return `${__VUEPRESS_BASE__}${removeLeadingSlash(url)}`;
233
236
  };
234
237
 
235
- // src/components/VPLink.ts
238
+ // src/components/RouteLink.ts
236
239
  import { h as h2 } from "vue";
237
- import { useRouter } from "vue-router";
240
+ import { useRouter as useRouter2 } from "vue-router";
238
241
  var guardEvent = (event) => {
239
242
  if (event.metaKey || event.altKey || event.ctrlKey || event.shiftKey)
240
243
  return;
@@ -250,13 +253,14 @@ var guardEvent = (event) => {
250
253
  event.preventDefault();
251
254
  return true;
252
255
  };
253
- var VPLink = ({ to = "" }, { slots }) => {
254
- const router = useRouter();
256
+ var RouteLink = ({ active = false, activeClass = "route-link-active", to, ...attrs }, { slots }) => {
257
+ const router = useRouter2();
255
258
  const path = withBase(resolveRoutePath(to));
256
259
  return h2(
257
260
  "a",
258
261
  {
259
- class: "vp-link",
262
+ ...attrs,
263
+ class: ["route-link", { [activeClass]: active }],
260
264
  href: path,
261
265
  onClick: (event = {}) => {
262
266
  guardEvent(event) ? router.push(to).catch() : Promise.resolve();
@@ -265,7 +269,12 @@ var VPLink = ({ to = "" }, { slots }) => {
265
269
  slots.default?.()
266
270
  );
267
271
  };
268
- VPLink.displayName = "VPLink";
272
+ RouteLink.displayName = "RouteLink";
273
+ RouteLink.props = {
274
+ active: Boolean,
275
+ activeClass: String,
276
+ to: String
277
+ };
269
278
 
270
279
  // src/resolvers.ts
271
280
  import { dedupeHead, isString, resolveLocalePath } from "@vuepress/shared";
@@ -377,6 +386,8 @@ export {
377
386
  routes,
378
387
  resolveRoutePath,
379
388
  resolveRoute,
389
+ useRoute,
390
+ useRouter,
380
391
  useRedirects,
381
392
  useRoutes,
382
393
  siteData,
@@ -389,6 +400,6 @@ export {
389
400
  Content,
390
401
  defineClientConfig,
391
402
  withBase,
392
- VPLink,
403
+ RouteLink,
393
404
  resolvers
394
405
  };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
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, ComponentOptions, FunctionalComponent, VNode } from 'vue';
4
+ import { ComputedRef, InjectionKey, Ref, Component, App, ComponentOptions, HTMLAttributes, FunctionalComponent, VNode } from 'vue';
5
5
  import { Router } from 'vue-router';
6
+ export { useRoute, useRouter } from 'vue-router';
6
7
  export { C as CreateVueAppFunction } from './createVueAppFunction-YNGNKfE3.js';
7
8
 
8
9
  /**
@@ -241,6 +242,9 @@ interface Route<T extends RouteMeta = RouteMeta> {
241
242
  type Redirects = Record<string, string>;
242
243
  type Routes = Record<string, Route>;
243
244
 
245
+ /**
246
+ * Wrapper component that only renders its content on the client side and skips server side rendering
247
+ */
244
248
  declare const ClientOnly: vue.DefineComponent<{}, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
245
249
  [key: string]: any;
246
250
  }>[] | null | undefined, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{}>>, {}, {}>;
@@ -266,10 +270,34 @@ declare const Content: vue.DefineComponent<{
266
270
  path: string;
267
271
  }, {}>;
268
272
 
269
- interface VPLinkProps {
273
+ interface RouteLinkProps extends HTMLAttributes {
274
+ /**
275
+ * Whether the link is active to have an active class
276
+ *
277
+ * Notice that the active status is not automatically determined according to the current route.
278
+ *
279
+ * @default false
280
+ */
281
+ active?: boolean;
282
+ /**
283
+ * The class to add when the link is active
284
+ *
285
+ * @default 'route-link-active'
286
+ */
287
+ activeClass?: string;
288
+ /**
289
+ * The route path to link to
290
+ */
270
291
  to: string;
271
292
  }
272
- declare const VPLink: FunctionalComponent<VPLinkProps, Record<never, never>, {
293
+ /**
294
+ * Component to render a link to another route.
295
+ *
296
+ * It's similar to `RouterLink` in `vue-router`, but more lightweight.
297
+ *
298
+ * It's recommended to use `RouteLink` in VuePress.
299
+ */
300
+ declare const RouteLink: FunctionalComponent<RouteLinkProps, Record<never, never>, {
273
301
  default: () => string | VNode | (string | VNode)[];
274
302
  }>;
275
303
 
@@ -301,4 +329,4 @@ declare const resolvers: {
301
329
  resolveSiteLocaleData: (site: SiteData, routeLocale: RouteLocale) => SiteLocaleData;
302
330
  };
303
331
 
304
- 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, type RouteLocale, type RouteLocaleRef, type RouteMeta, type Routes, 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 };
332
+ 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,
@@ -27,17 +27,19 @@ import {
27
27
  usePageLang,
28
28
  usePageLayout,
29
29
  useRedirects,
30
+ useRoute,
30
31
  useRouteLocale,
32
+ useRouter,
31
33
  useRoutes,
32
34
  useSiteData,
33
35
  useSiteLocaleData,
34
36
  useUpdateHead,
35
37
  withBase
36
- } from "./chunk-6BD5VZ74.js";
38
+ } from "./chunk-FKY5ACNS.js";
37
39
  export {
38
40
  ClientOnly,
39
41
  Content,
40
- VPLink,
42
+ RouteLink,
41
43
  defineClientConfig,
42
44
  layoutsSymbol,
43
45
  pageDataSymbol,
@@ -63,7 +65,9 @@ export {
63
65
  usePageLang,
64
66
  usePageLayout,
65
67
  useRedirects,
68
+ useRoute,
66
69
  useRouteLocale,
70
+ useRouter,
67
71
  useRoutes,
68
72
  useSiteData,
69
73
  useSiteLocaleData,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/client",
3
- "version": "2.0.0-rc.4",
3
+ "version": "2.0.0-rc.6",
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.4"
40
+ "@vuepress/shared": "2.0.0-rc.6"
41
41
  },
42
42
  "publishConfig": {
43
43
  "access": "public"