@vuepress/theme-default 2.0.0-rc.0 → 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.
Files changed (38) hide show
  1. package/LICENSE +1 -1
  2. package/lib/client/components/AutoLink.vue +6 -12
  3. package/lib/client/components/HomeFeatures.vue +2 -3
  4. package/lib/client/components/HomeFooter.vue +1 -1
  5. package/lib/client/components/HomeHero.vue +4 -5
  6. package/lib/client/components/NavbarBrand.vue +4 -4
  7. package/lib/client/components/NavbarItems.vue +16 -11
  8. package/lib/client/components/PageMeta.vue +1 -1
  9. package/lib/client/components/PageNav.vue +17 -7
  10. package/lib/client/components/global/CodeGroup.d.ts +1 -1
  11. package/lib/client/components/global/CodeGroup.js +6 -6
  12. package/lib/client/components/global/CodeGroupItem.vue +3 -7
  13. package/lib/client/composables/index.d.ts +0 -2
  14. package/lib/client/composables/index.js +0 -2
  15. package/lib/client/composables/useSidebarItems.d.ts +6 -5
  16. package/lib/client/composables/useSidebarItems.js +23 -26
  17. package/lib/client/config.d.ts +2 -1
  18. package/lib/client/config.js +1 -1
  19. package/lib/client/layouts/Layout.vue +1 -1
  20. package/lib/client/layouts/NotFound.vue +1 -1
  21. package/lib/client/styles/code-group.scss +4 -11
  22. package/lib/client/styles/code.scss +1 -1
  23. package/lib/client/styles/layout.scss +1 -1
  24. package/lib/client/styles/normalize.scss +23 -24
  25. package/lib/client/styles/vars.scss +6 -0
  26. package/lib/client/{composables/useNavLink.d.ts → utils/getNavLink.d.ts} +2 -1
  27. package/lib/client/{composables/useNavLink.js → utils/getNavLink.js} +3 -3
  28. package/lib/client/utils/getResolveRouteWithRedirect.d.ts +5 -0
  29. package/lib/client/{composables/useResolveRouteWithRedirect.js → utils/getResolveRouteWithRedirect.js} +3 -5
  30. package/lib/client/utils/index.d.ts +2 -0
  31. package/lib/client/utils/index.js +2 -0
  32. package/lib/client/utils/resolveEditLink.js +1 -1
  33. package/lib/client/utils/resolveRepoType.js +1 -1
  34. package/lib/node/defaultTheme.d.ts +1 -1
  35. package/lib/node/defaultTheme.js +1 -1
  36. package/lib/shared/options.d.ts +1 -1
  37. package/package.json +26 -28
  38. package/lib/client/composables/useResolveRouteWithRedirect.d.ts +0 -5
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018-present, Yuxi (Evan) You
3
+ Copyright (c) 2018-present, VuePress Community
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,21 +1,15 @@
1
- <script lang="ts">
2
- /* eslint-disable import/first, import/no-duplicates, import/order */
3
- import { defineComponent } from 'vue'
4
-
5
- export default defineComponent({
6
- inheritAttrs: false,
7
- })
8
- /* eslint-enable import/order */
9
- </script>
10
-
11
1
  <script setup lang="ts">
12
- import { useSiteData } from '@vuepress/client'
13
- import { isLinkHttp, isLinkWithProtocol } from '@vuepress/shared'
14
2
  import { computed, toRefs } from 'vue'
15
3
  import type { PropType } from 'vue'
16
4
  import { useRoute } from 'vue-router'
5
+ import { useSiteData } from 'vuepress/client'
6
+ import { isLinkHttp, isLinkWithProtocol } from 'vuepress/shared'
17
7
  import type { NavLink } from '../../shared/index.js'
18
8
 
9
+ defineOptions({
10
+ inheritAttrs: false,
11
+ })
12
+
19
13
  const props = defineProps({
20
14
  item: {
21
15
  type: Object as PropType<NavLink>,
@@ -1,12 +1,11 @@
1
1
  <script setup lang="ts">
2
- import { usePageFrontmatter } from '@vuepress/client'
3
- import { isArray } from '@vuepress/shared'
4
2
  import { computed } from 'vue'
3
+ import { usePageFrontmatter } from 'vuepress/client'
5
4
  import type { DefaultThemeHomePageFrontmatter } from '../../shared/index.js'
6
5
 
7
6
  const frontmatter = usePageFrontmatter<DefaultThemeHomePageFrontmatter>()
8
7
  const features = computed(() => {
9
- if (isArray(frontmatter.value.features)) {
8
+ if (Array.isArray(frontmatter.value.features)) {
10
9
  return frontmatter.value.features
11
10
  }
12
11
  return []
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts">
2
- import { usePageFrontmatter } from '@vuepress/client'
3
2
  import { computed } from 'vue'
3
+ import { usePageFrontmatter } from 'vuepress/client'
4
4
  import type { DefaultThemeHomePageFrontmatter } from '../../shared/index.js'
5
5
 
6
6
  const frontmatter = usePageFrontmatter<DefaultThemeHomePageFrontmatter>()
@@ -1,14 +1,13 @@
1
1
  <script setup lang="ts">
2
2
  import AutoLink from '@theme/AutoLink.vue'
3
+ import type { FunctionalComponent } from 'vue'
4
+ import { computed, h } from 'vue'
3
5
  import {
4
6
  ClientOnly,
5
7
  usePageFrontmatter,
6
8
  useSiteLocaleData,
7
9
  withBase,
8
- } from '@vuepress/client'
9
- import { isArray } from '@vuepress/shared'
10
- import type { FunctionalComponent } from 'vue'
11
- import { computed, h } from 'vue'
10
+ } from 'vuepress/client'
12
11
  import type { DefaultThemeHomePageFrontmatter } from '../../shared/index.js'
13
12
  import { useDarkMode } from '../composables/index.js'
14
13
 
@@ -46,7 +45,7 @@ const tagline = computed(() => {
46
45
  })
47
46
 
48
47
  const actions = computed(() => {
49
- if (!isArray(frontmatter.value.actions)) {
48
+ if (!Array.isArray(frontmatter.value.actions)) {
50
49
  return []
51
50
  }
52
51
 
@@ -1,12 +1,12 @@
1
1
  <script setup lang="ts">
2
+ import { computed, h } from 'vue'
3
+ import type { FunctionalComponent } from 'vue'
2
4
  import {
3
5
  ClientOnly,
4
6
  useRouteLocale,
5
7
  useSiteLocaleData,
6
8
  withBase,
7
- } from '@vuepress/client'
8
- import { computed, h } from 'vue'
9
- import type { FunctionalComponent } from 'vue'
9
+ } from 'vuepress/client'
10
10
  import { useDarkMode, useThemeLocaleData } from '../composables/index.js'
11
11
 
12
12
  const routeLocale = useRouteLocale()
@@ -29,7 +29,7 @@ const NavbarBrandLogo: FunctionalComponent = () => {
29
29
  const img = h('img', {
30
30
  class: 'logo',
31
31
  src: withBase(navbarBrandLogo.value),
32
- alt: navbarBrandTitle.value,
32
+ alt: '',
33
33
  })
34
34
  if (themeLocale.value.logoDark === undefined) {
35
35
  return img
@@ -1,15 +1,12 @@
1
1
  <script setup lang="ts">
2
2
  import AutoLink from '@theme/AutoLink.vue'
3
3
  import NavbarDropdown from '@theme/NavbarDropdown.vue'
4
- import {
5
- useRouteLocale,
6
- useSiteData,
7
- useSiteLocaleData,
8
- } from '@vuepress/client'
9
- import { isLinkHttp, isString } from '@vuepress/shared'
10
4
  import { computed, ref } from 'vue'
11
5
  import type { ComputedRef } from 'vue'
12
6
  import { useRouter } from 'vue-router'
7
+ import type { Router } from 'vue-router'
8
+ import { useRouteLocale, useSiteData, useSiteLocaleData } from 'vuepress/client'
9
+ import { isLinkHttp, isString } from 'vuepress/shared'
13
10
  import type {
14
11
  NavbarGroup,
15
12
  NavbarItem,
@@ -17,12 +14,11 @@ import type {
17
14
  } from '../../shared/index.js'
18
15
  import {
19
16
  DeviceType,
20
- useNavLink,
21
17
  useThemeData,
22
18
  useThemeLocaleData,
23
19
  useUpdateDeviceStatus,
24
20
  } from '../composables/index.js'
25
- import { resolveRepoType } from '../utils/index.js'
21
+ import { getNavLink, resolveRepoType } from '../utils/index.js'
26
22
 
27
23
  /**
28
24
  * Get navbar config of select language dropdown
@@ -133,23 +129,32 @@ const useNavbarRepo = (): ComputedRef<ResolvedNavbarItem[]> => {
133
129
  }
134
130
 
135
131
  const resolveNavbarItem = (
132
+ router: Router,
136
133
  item: NavbarItem | NavbarGroup | string,
137
134
  ): ResolvedNavbarItem => {
138
135
  if (isString(item)) {
139
- return useNavLink(item)
136
+ return getNavLink(router, item)
140
137
  }
141
138
  if ((item as NavbarGroup).children) {
142
139
  return {
143
140
  ...item,
144
- children: (item as NavbarGroup).children.map(resolveNavbarItem),
141
+ children: (item as NavbarGroup).children.map((item) =>
142
+ resolveNavbarItem(router, item),
143
+ ),
145
144
  }
146
145
  }
147
146
  return item as ResolvedNavbarItem
148
147
  }
149
148
 
150
149
  const useNavbarConfig = (): ComputedRef<ResolvedNavbarItem[]> => {
150
+ const router = useRouter()
151
151
  const themeLocale = useThemeLocaleData()
152
- return computed(() => (themeLocale.value.navbar || []).map(resolveNavbarItem))
152
+
153
+ return computed(() =>
154
+ (themeLocale.value.navbar || []).map((item) =>
155
+ resolveNavbarItem(router, item),
156
+ ),
157
+ )
153
158
  }
154
159
 
155
160
  const isMobile = ref(false)
@@ -1,8 +1,8 @@
1
1
  <script setup lang="ts">
2
2
  import AutoLink from '@theme/AutoLink.vue'
3
- import { usePageData, usePageFrontmatter } from '@vuepress/client'
4
3
  import { computed } from 'vue'
5
4
  import type { ComputedRef } from 'vue'
5
+ import { usePageData, usePageFrontmatter } from 'vuepress/client'
6
6
  import type {
7
7
  DefaultThemeNormalPageFrontmatter,
8
8
  DefaultThemePageData,
@@ -1,20 +1,23 @@
1
1
  <script setup lang="ts">
2
2
  import AutoLink from '@theme/AutoLink.vue'
3
- import { usePageFrontmatter } from '@vuepress/client'
4
- import { isPlainObject, isString } from '@vuepress/shared'
5
3
  import { computed } from 'vue'
6
- import { useRoute } from 'vue-router'
4
+ import type { Router } from 'vue-router'
5
+ import { useRoute, useRouter } from 'vue-router'
6
+ import { usePageFrontmatter } from 'vuepress/client'
7
+ import { isPlainObject, isString } from 'vuepress/shared'
7
8
  import type {
8
9
  DefaultThemeNormalPageFrontmatter,
9
10
  NavLink,
10
11
  ResolvedSidebarItem,
11
12
  } from '../../shared/index.js'
12
- import { useNavLink, useSidebarItems } from '../composables/index.js'
13
+ import { useSidebarItems } from '../composables/index.js'
14
+ import { getNavLink } from '../utils/index.js'
13
15
 
14
16
  /**
15
17
  * Resolve `prev` or `next` config from frontmatter
16
18
  */
17
19
  const resolveFromFrontmatterConfig = (
20
+ router: Router,
18
21
  conf: unknown,
19
22
  ): null | false | NavLink => {
20
23
  if (conf === false) {
@@ -22,7 +25,7 @@ const resolveFromFrontmatterConfig = (
22
25
  }
23
26
 
24
27
  if (isString(conf)) {
25
- return useNavLink(conf)
28
+ return getNavLink(router, conf)
26
29
  }
27
30
 
28
31
  if (isPlainObject<NavLink>(conf)) {
@@ -68,9 +71,13 @@ const resolveFromSidebarItems = (
68
71
  const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
69
72
  const sidebarItems = useSidebarItems()
70
73
  const route = useRoute()
74
+ const router = useRouter()
71
75
 
72
76
  const prevNavLink = computed(() => {
73
- const prevConfig = resolveFromFrontmatterConfig(frontmatter.value.prev)
77
+ const prevConfig = resolveFromFrontmatterConfig(
78
+ router,
79
+ frontmatter.value.prev,
80
+ )
74
81
  if (prevConfig !== false) {
75
82
  return prevConfig
76
83
  }
@@ -79,7 +86,10 @@ const prevNavLink = computed(() => {
79
86
  })
80
87
 
81
88
  const nextNavLink = computed(() => {
82
- const nextConfig = resolveFromFrontmatterConfig(frontmatter.value.next)
89
+ const nextConfig = resolveFromFrontmatterConfig(
90
+ router,
91
+ frontmatter.value.next,
92
+ )
83
93
  if (nextConfig !== false) {
84
94
  return nextConfig
85
95
  }
@@ -1,6 +1,6 @@
1
1
  import type { SlotsType, VNode } from 'vue';
2
2
  export declare const CodeGroup: import("vue").DefineComponent<{}, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
3
3
  [key: string]: any;
4
- }> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, SlotsType<{
4
+ }> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, SlotsType<{
5
5
  default: () => VNode[];
6
6
  }>>;
@@ -95,9 +95,9 @@ export const CodeGroup = defineComponent({
95
95
  });
96
96
  }
97
97
  return h('div', { class: 'code-group' }, [
98
- h('div', { class: 'code-group__nav' }, h('ul', { class: 'code-group__ul' }, items.map((vnode, i) => {
98
+ h('div', { class: 'code-group__nav', role: 'tablist' }, items.map((vnode, i) => {
99
99
  const isActive = i === activeIndex.value;
100
- return h('li', { class: 'code-group__li' }, h('button', {
100
+ return h('button', {
101
101
  ref: (element) => {
102
102
  if (element) {
103
103
  tabRefs.value[i] = element;
@@ -107,12 +107,12 @@ export const CodeGroup = defineComponent({
107
107
  'code-group__nav-tab': true,
108
108
  'code-group__nav-tab-active': isActive,
109
109
  },
110
- ariaPressed: isActive,
111
- ariaExpanded: isActive,
110
+ role: 'tab',
111
+ ariaSelected: isActive,
112
112
  onClick: () => (activeIndex.value = i),
113
113
  onKeydown: (e) => keyboardHandler(e, i),
114
- }, vnode.props.title));
115
- }))),
114
+ }, vnode.props.title);
115
+ })),
116
116
  items,
117
117
  ]);
118
118
  };
@@ -1,12 +1,8 @@
1
- <script lang="ts">
2
- import { defineComponent } from 'vue'
3
-
4
- export default defineComponent({
1
+ <script setup lang="ts">
2
+ defineOptions({
5
3
  name: 'CodeGroupItem',
6
4
  })
7
- </script>
8
5
 
9
- <script setup lang="ts">
10
6
  defineProps({
11
7
  title: {
12
8
  type: String,
@@ -24,7 +20,7 @@ defineProps({
24
20
  <div
25
21
  class="code-group-item"
26
22
  :class="{ 'code-group-item__active': active }"
27
- :aria-selected="active"
23
+ role="tabpanel"
28
24
  >
29
25
  <slot />
30
26
  </div>
@@ -1,6 +1,4 @@
1
1
  export * from './useDarkMode.js';
2
- export * from './useNavLink.js';
3
- export * from './useResolveRouteWithRedirect.js';
4
2
  export * from './useScrollPromise.js';
5
3
  export * from './useSidebarItems.js';
6
4
  export * from './useThemeData.js';
@@ -1,6 +1,4 @@
1
1
  export * from './useDarkMode.js';
2
- export * from './useNavLink.js';
3
- export * from './useResolveRouteWithRedirect.js';
4
2
  export * from './useScrollPromise.js';
5
3
  export * from './useSidebarItems.js';
6
4
  export * from './useThemeData.js';
@@ -1,5 +1,6 @@
1
- import type { PageHeader } from '@vuepress/client';
2
1
  import type { ComputedRef, InjectionKey } from 'vue';
2
+ import type { Router } from 'vue-router';
3
+ import type { PageData, PageHeader } from 'vuepress/client';
3
4
  import type { DefaultThemeData, DefaultThemeNormalPageFrontmatter, ResolvedSidebarItem, SidebarConfigArray, SidebarConfigObject } from '../../shared/index.js';
4
5
  export type SidebarItemsRef = ComputedRef<ResolvedSidebarItem[]>;
5
6
  export declare const sidebarItemsSymbol: InjectionKey<SidebarItemsRef>;
@@ -16,7 +17,7 @@ export declare const setupSidebarItems: () => void;
16
17
  *
17
18
  * It should only be resolved and provided once
18
19
  */
19
- export declare const resolveSidebarItems: (frontmatter: DefaultThemeNormalPageFrontmatter, themeLocale: DefaultThemeData) => ResolvedSidebarItem[];
20
+ export declare const resolveSidebarItems: (frontmatter: DefaultThemeNormalPageFrontmatter, themeLocale: DefaultThemeData, page: PageData, router: Router, path: string) => ResolvedSidebarItem[];
20
21
  /**
21
22
  * Util to transform page header to sidebar item
22
23
  */
@@ -25,12 +26,12 @@ export declare const headersToSidebarItemChildren: (headers: PageHeader[], sideb
25
26
  /**
26
27
  * Resolve sidebar items if the config is `auto`
27
28
  */
28
- export declare const resolveAutoSidebarItems: (sidebarDepth: number) => ResolvedSidebarItem[];
29
+ export declare const resolveAutoSidebarItems: (page: PageData, sidebarDepth: number) => ResolvedSidebarItem[];
29
30
  /**
30
31
  * Resolve sidebar items if the config is an array
31
32
  */
32
- export declare const resolveArraySidebarItems: (sidebarConfig: SidebarConfigArray, sidebarDepth: number) => ResolvedSidebarItem[];
33
+ export declare const resolveArraySidebarItems: (page: PageData, router: Router, path: string, sidebarConfig: SidebarConfigArray, sidebarDepth: number) => ResolvedSidebarItem[];
33
34
  /**
34
35
  * Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
35
36
  */
36
- export declare const resolveMultiSidebarItems: (sidebarConfig: SidebarConfigObject, sidebarDepth: number) => ResolvedSidebarItem[];
37
+ export declare const resolveMultiSidebarItems: (page: PageData, router: Router, path: string, sidebarConfig: SidebarConfigObject, sidebarDepth: number) => ResolvedSidebarItem[];
@@ -1,8 +1,8 @@
1
- import { usePageData, usePageFrontmatter } from '@vuepress/client';
2
- import { isArray, isPlainObject, isString, resolveLocalePath, } from '@vuepress/shared';
3
1
  import { computed, inject, provide } from 'vue';
4
- import { useRoute } from 'vue-router';
5
- import { useNavLink } from './useNavLink.js';
2
+ import { useRoute, useRouter } from 'vue-router';
3
+ import { usePageData, usePageFrontmatter } from 'vuepress/client';
4
+ import { isPlainObject, isString, resolveLocalePath } from 'vuepress/shared';
5
+ import { getNavLink } from '../utils/index.js';
6
6
  import { useThemeLocaleData } from './useThemeData.js';
7
7
  export const sidebarItemsSymbol = Symbol('sidebarItems');
8
8
  /**
@@ -21,7 +21,10 @@ export const useSidebarItems = () => {
21
21
  export const setupSidebarItems = () => {
22
22
  const themeLocale = useThemeLocaleData();
23
23
  const frontmatter = usePageFrontmatter();
24
- const sidebarItems = computed(() => resolveSidebarItems(frontmatter.value, themeLocale.value));
24
+ const page = usePageData();
25
+ const route = useRoute();
26
+ const router = useRouter();
27
+ const sidebarItems = computed(() => resolveSidebarItems(frontmatter.value, themeLocale.value, page.value, router, route.path));
25
28
  provide(sidebarItemsSymbol, sidebarItems);
26
29
  };
27
30
  /**
@@ -29,7 +32,7 @@ export const setupSidebarItems = () => {
29
32
  *
30
33
  * It should only be resolved and provided once
31
34
  */
32
- export const resolveSidebarItems = (frontmatter, themeLocale) => {
35
+ export const resolveSidebarItems = (frontmatter, themeLocale, page, router, path) => {
33
36
  // get sidebar config from frontmatter > theme data
34
37
  const sidebarConfig = frontmatter.sidebar ?? themeLocale.sidebar ?? 'auto';
35
38
  const sidebarDepth = frontmatter.sidebarDepth ?? themeLocale.sidebarDepth ?? 2;
@@ -38,13 +41,13 @@ export const resolveSidebarItems = (frontmatter, themeLocale) => {
38
41
  return [];
39
42
  }
40
43
  if (sidebarConfig === 'auto') {
41
- return resolveAutoSidebarItems(sidebarDepth);
44
+ return resolveAutoSidebarItems(page, sidebarDepth);
42
45
  }
43
- if (isArray(sidebarConfig)) {
44
- return resolveArraySidebarItems(sidebarConfig, sidebarDepth);
46
+ if (Array.isArray(sidebarConfig)) {
47
+ return resolveArraySidebarItems(page, router, path, sidebarConfig, sidebarDepth);
45
48
  }
46
49
  if (isPlainObject(sidebarConfig)) {
47
- return resolveMultiSidebarItems(sidebarConfig, sidebarDepth);
50
+ return resolveMultiSidebarItems(page, router, path, sidebarConfig, sidebarDepth);
48
51
  }
49
52
  return [];
50
53
  };
@@ -62,25 +65,22 @@ export const headersToSidebarItemChildren = (headers, sidebarDepth) => sidebarDe
62
65
  /**
63
66
  * Resolve sidebar items if the config is `auto`
64
67
  */
65
- export const resolveAutoSidebarItems = (sidebarDepth) => {
66
- const page = usePageData();
68
+ export const resolveAutoSidebarItems = (page, sidebarDepth) => {
67
69
  return [
68
70
  {
69
- text: page.value.title,
70
- children: headersToSidebarItemChildren(page.value.headers, sidebarDepth),
71
+ text: page.title,
72
+ children: headersToSidebarItemChildren(page.headers, sidebarDepth),
71
73
  },
72
74
  ];
73
75
  };
74
76
  /**
75
77
  * Resolve sidebar items if the config is an array
76
78
  */
77
- export const resolveArraySidebarItems = (sidebarConfig, sidebarDepth) => {
78
- const route = useRoute();
79
- const page = usePageData();
79
+ export const resolveArraySidebarItems = (page, router, path, sidebarConfig, sidebarDepth) => {
80
80
  const handleChildItem = (item) => {
81
81
  let childItem;
82
82
  if (isString(item)) {
83
- childItem = useNavLink(item);
83
+ childItem = getNavLink(router, item);
84
84
  }
85
85
  else {
86
86
  childItem = item;
@@ -93,11 +93,9 @@ export const resolveArraySidebarItems = (sidebarConfig, sidebarDepth) => {
93
93
  }
94
94
  // if the sidebar item is current page and children is not set
95
95
  // use headers of current page as children
96
- if (childItem.link === route.path) {
96
+ if (childItem.link === path) {
97
97
  // skip h1 header
98
- const headers = page.value.headers[0]?.level === 1
99
- ? page.value.headers[0].children
100
- : page.value.headers;
98
+ const headers = page.headers[0]?.level === 1 ? page.headers[0].children : page.headers;
101
99
  return {
102
100
  ...childItem,
103
101
  children: headersToSidebarItemChildren(headers, sidebarDepth),
@@ -110,9 +108,8 @@ export const resolveArraySidebarItems = (sidebarConfig, sidebarDepth) => {
110
108
  /**
111
109
  * Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
112
110
  */
113
- export const resolveMultiSidebarItems = (sidebarConfig, sidebarDepth) => {
114
- const route = useRoute();
115
- const sidebarPath = resolveLocalePath(sidebarConfig, route.path);
111
+ export const resolveMultiSidebarItems = (page, router, path, sidebarConfig, sidebarDepth) => {
112
+ const sidebarPath = resolveLocalePath(sidebarConfig, path);
116
113
  const matchedSidebarConfig = sidebarConfig[sidebarPath] ?? [];
117
- return resolveArraySidebarItems(matchedSidebarConfig, sidebarDepth);
114
+ return resolveArraySidebarItems(page, router, path, matchedSidebarConfig, sidebarDepth);
118
115
  };
@@ -1,3 +1,4 @@
1
+ import type { ClientConfig } from 'vuepress/client';
1
2
  import './styles/index.scss';
2
- declare const _default: import("@vuepress/client").ClientConfig;
3
+ declare const _default: ClientConfig;
3
4
  export default _default;
@@ -1,5 +1,5 @@
1
- import { defineClientConfig } from '@vuepress/client';
2
1
  import { h } from 'vue';
2
+ import { defineClientConfig } from 'vuepress/client';
3
3
  import { Badge, CodeGroup, CodeGroupItem } from './components/global/index.js';
4
4
  import { setupDarkMode, setupSidebarItems, useScrollPromise, } from './composables/index.js';
5
5
  import Layout from './layouts/Layout.vue';
@@ -3,9 +3,9 @@ import Home from '@theme/Home.vue'
3
3
  import Navbar from '@theme/Navbar.vue'
4
4
  import Page from '@theme/Page.vue'
5
5
  import Sidebar from '@theme/Sidebar.vue'
6
- import { usePageData, usePageFrontmatter } from '@vuepress/client'
7
6
  import { computed, onMounted, onUnmounted, ref } from 'vue'
8
7
  import { useRouter } from 'vue-router'
8
+ import { usePageData, usePageFrontmatter } from 'vuepress/client'
9
9
  import type { DefaultThemePageFrontmatter } from '../../shared/index.js'
10
10
  import {
11
11
  useScrollPromise,
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { useRouteLocale } from '@vuepress/client'
2
+ import { useRouteLocale } from 'vuepress/client'
3
3
  import { useThemeLocaleData } from '../composables/index.js'
4
4
 
5
5
  const routeLocale = useRouteLocale()
@@ -12,14 +12,7 @@
12
12
  padding-top: 10px;
13
13
  border-top-left-radius: 6px;
14
14
  border-top-right-radius: 6px;
15
- background-color: var(--code-bg-color);
16
- }
17
-
18
- .code-group__ul {
19
- margin: auto 0;
20
- padding-left: 0;
21
- display: inline-flex;
22
- list-style: none;
15
+ background-color: var(--c-code-group-tab-bg);
23
16
  }
24
17
 
25
18
  .code-group__nav-tab {
@@ -29,7 +22,7 @@
29
22
  background-color: transparent;
30
23
  font-size: 0.85em;
31
24
  line-height: 1.4;
32
- color: rgba(255, 255, 255, 0.9);
25
+ color: var(--c-code-group-tab-title);
33
26
  font-weight: 600;
34
27
  }
35
28
 
@@ -38,11 +31,11 @@
38
31
  }
39
32
 
40
33
  .code-group__nav-tab:focus-visible {
41
- outline: 1px solid rgba(255, 255, 255, 0.9);
34
+ outline: 1px solid var(--c-code-group-tab-outline);
42
35
  }
43
36
 
44
37
  .code-group__nav-tab-active {
45
- border-bottom: var(--c-brand) 1px solid;
38
+ border-bottom: var(--c-code-group-tab-active-border) 1px solid;
46
39
  }
47
40
 
48
41
  @media (max-width: $MQMobileNarrow) {
@@ -156,7 +156,7 @@ div[class*='language-'] {
156
156
  border-radius: 6px;
157
157
 
158
158
  &::before {
159
- content: attr(data-ext);
159
+ content: attr(data-title);
160
160
  position: absolute;
161
161
  z-index: 3;
162
162
  top: 0.8em;
@@ -126,7 +126,7 @@
126
126
  }
127
127
 
128
128
  .theme-default-content {
129
- a:hover {
129
+ a:not(.header-anchor):hover {
130
130
  text-decoration: underline;
131
131
  }
132
132
 
@@ -92,8 +92,29 @@ h6 {
92
92
  outline: none;
93
93
  }
94
94
 
95
- &:hover .header-anchor {
96
- opacity: 1;
95
+ .header-anchor {
96
+ color: inherit;
97
+ text-decoration: none;
98
+ position: relative;
99
+
100
+ &:hover ::before {
101
+ content: '¶';
102
+ position: absolute;
103
+ left: -0.75em;
104
+ color: var(--c-brand);
105
+ }
106
+
107
+ &:focus-visible {
108
+ outline: none;
109
+
110
+ &::before {
111
+ content: '¶';
112
+ position: absolute;
113
+ left: -0.75em;
114
+ color: var(--c-brand);
115
+ outline: auto;
116
+ }
117
+ }
97
118
  }
98
119
  }
99
120
 
@@ -125,28 +146,6 @@ h6 {
125
146
  }
126
147
 
127
148
  a {
128
- &.header-anchor {
129
- font-size: 0.85em;
130
- float: left;
131
- margin-left: -0.87em;
132
- padding-right: 0.23em;
133
- margin-top: 0.125em;
134
- opacity: 0;
135
- user-select: none;
136
-
137
- @media print {
138
- display: none;
139
- }
140
-
141
- &:hover {
142
- text-decoration: none;
143
- }
144
-
145
- &:focus-visible {
146
- opacity: 1;
147
- }
148
- }
149
-
150
149
  @media print {
151
150
  &[href^="http://"],
152
151
  &[href^="https://"]
@@ -62,6 +62,12 @@
62
62
  --c-badge-danger: #dc2626;
63
63
  --c-badge-danger-text: var(--c-bg);
64
64
 
65
+ // code group colors
66
+ --c-code-group-tab-title: rgba(255, 255, 255, 0.9);
67
+ --c-code-group-tab-bg: var(--code-bg-color);
68
+ --c-code-group-tab-outline: var(var(--c-code-group-tab-title));
69
+ --c-code-group-tab-active-border: var(--c-brand);
70
+
65
71
  // transition vars
66
72
  --t-color: 0.3s ease;
67
73
  --t-transform: 0.3s ease;
@@ -1,3 +1,4 @@
1
+ import type { Router } from 'vue-router';
1
2
  import type { NavLink } from '../../shared/index.js';
2
3
  declare module 'vue-router' {
3
4
  interface RouteMeta {
@@ -11,4 +12,4 @@ declare module 'vue-router' {
11
12
  * - Input: '/README.md'
12
13
  * - Output: { text: 'Home', link: '/' }
13
14
  */
14
- export declare const useNavLink: (item: string) => NavLink;
15
+ export declare const getNavLink: (router: Router, item: string) => NavLink;
@@ -1,4 +1,4 @@
1
- import { useResolveRouteWithRedirect } from './useResolveRouteWithRedirect.js';
1
+ import { getResolveRouteWithRedirect } from './getResolveRouteWithRedirect.js';
2
2
  /**
3
3
  * Resolve NavLink props from string
4
4
  *
@@ -6,11 +6,11 @@ import { useResolveRouteWithRedirect } from './useResolveRouteWithRedirect.js';
6
6
  * - Input: '/README.md'
7
7
  * - Output: { text: 'Home', link: '/' }
8
8
  */
9
- export const useNavLink = (item) => {
9
+ export const getNavLink = (router, item) => {
10
10
  // the route path of vue-router is url-encoded, and we expect users are using
11
11
  // non-url-encoded string in theme config, so we need to url-encode it first to
12
12
  // resolve the route correctly
13
- const resolved = useResolveRouteWithRedirect(encodeURI(item));
13
+ const resolved = getResolveRouteWithRedirect(router, encodeURI(item));
14
14
  return {
15
15
  text: resolved.meta.title || item,
16
16
  link: resolved.name === '404' ? item : resolved.fullPath,
@@ -0,0 +1,5 @@
1
+ import type { Router } from 'vue-router';
2
+ /**
3
+ * Resolve a route with redirection
4
+ */
5
+ export declare const getResolveRouteWithRedirect: (router: Router, to: import("vue-router").RouteLocationRaw, currentLocation?: import("vue-router").RouteLocationNormalizedLoaded | undefined) => ReturnType<Router['resolve']>;
@@ -1,10 +1,8 @@
1
- import { isFunction, isString } from '@vuepress/shared';
2
- import { useRouter } from 'vue-router';
1
+ import { isFunction, isString } from 'vuepress/shared';
3
2
  /**
4
3
  * Resolve a route with redirection
5
4
  */
6
- export const useResolveRouteWithRedirect = (...args) => {
7
- const router = useRouter();
5
+ export const getResolveRouteWithRedirect = (router, ...args) => {
8
6
  const route = router.resolve(...args);
9
7
  const lastMatched = route.matched[route.matched.length - 1];
10
8
  if (!lastMatched?.redirect) {
@@ -15,7 +13,7 @@ export const useResolveRouteWithRedirect = (...args) => {
15
13
  const resolvedRedirectObj = isString(resolvedRedirect)
16
14
  ? { path: resolvedRedirect }
17
15
  : resolvedRedirect;
18
- return useResolveRouteWithRedirect({
16
+ return getResolveRouteWithRedirect(router, {
19
17
  hash: route.hash,
20
18
  query: route.query,
21
19
  params: route.params,
@@ -1,3 +1,5 @@
1
+ export * from './getNavLink.js';
2
+ export * from './getResolveRouteWithRedirect.js';
1
3
  export * from './isActiveSidebarItem.js';
2
4
  export * from './resolveEditLink.js';
3
5
  export * from './resolveRepoType.js';
@@ -1,3 +1,5 @@
1
+ export * from './getNavLink.js';
2
+ export * from './getResolveRouteWithRedirect.js';
1
3
  export * from './isActiveSidebarItem.js';
2
4
  export * from './resolveEditLink.js';
3
5
  export * from './resolveRepoType.js';
@@ -1,4 +1,4 @@
1
- import { isLinkHttp, removeEndingSlash, removeLeadingSlash, } from '@vuepress/shared';
1
+ import { isLinkHttp, removeEndingSlash, removeLeadingSlash, } from 'vuepress/shared';
2
2
  import { resolveRepoType } from './resolveRepoType.js';
3
3
  export const editLinkPatterns = {
4
4
  GitHub: ':repo/edit/:branch/:path',
@@ -1,4 +1,4 @@
1
- import { isLinkHttp } from '@vuepress/shared';
1
+ import { isLinkHttp } from 'vuepress/shared';
2
2
  export const resolveRepoType = (repo) => {
3
3
  if (!isLinkHttp(repo) || /github\.com/.test(repo))
4
4
  return 'GitHub';
@@ -1,4 +1,4 @@
1
- import type { Theme } from '@vuepress/core';
1
+ import type { Theme } from 'vuepress/core';
2
2
  import type { DefaultThemeLocaleOptions, DefaultThemePluginsOptions } from '../shared/index.js';
3
3
  export interface DefaultThemeOptions extends DefaultThemeLocaleOptions {
4
4
  /**
@@ -8,7 +8,7 @@ import { nprogressPlugin } from '@vuepress/plugin-nprogress';
8
8
  import { palettePlugin } from '@vuepress/plugin-palette';
9
9
  import { prismjsPlugin } from '@vuepress/plugin-prismjs';
10
10
  import { themeDataPlugin } from '@vuepress/plugin-theme-data';
11
- import { fs, getDirname, path } from '@vuepress/utils';
11
+ import { fs, getDirname, path } from 'vuepress/utils';
12
12
  import { assignDefaultLocaleOptions, resolveContainerPluginOptions, } from './utils/index.js';
13
13
  const __dirname = getDirname(import.meta.url);
14
14
  export const defaultTheme = ({ themePlugins = {}, ...localeOptions } = {}) => {
@@ -1,5 +1,5 @@
1
1
  import type { ThemeData } from '@vuepress/plugin-theme-data';
2
- import type { LocaleData } from '@vuepress/shared';
2
+ import type { LocaleData } from 'vuepress/shared';
3
3
  import type { NavbarConfig, SidebarConfig } from './nav.js';
4
4
  export interface DefaultThemePluginsOptions {
5
5
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/theme-default",
3
- "version": "2.0.0-rc.0",
3
+ "version": "2.0.0-rc.1",
4
4
  "description": "Default theme of VuePress",
5
5
  "keywords": [
6
6
  "vuepress-theme",
@@ -10,11 +10,11 @@
10
10
  ],
11
11
  "homepage": "https://github.com/vuepress",
12
12
  "bugs": {
13
- "url": "https://github.com/vuepress/vuepress-next/issues"
13
+ "url": "https://github.com/vuepress/ecosystem/issues"
14
14
  },
15
15
  "repository": {
16
16
  "type": "git",
17
- "url": "git+https://github.com/vuepress/vuepress-next.git"
17
+ "url": "git+https://github.com/vuepress/ecosystem.git"
18
18
  },
19
19
  "license": "MIT",
20
20
  "author": "meteorlxy",
@@ -35,28 +35,30 @@
35
35
  "lib",
36
36
  "templates"
37
37
  ],
38
+ "scripts": {
39
+ "build": "tsc -b tsconfig.build.json",
40
+ "clean": "rimraf lib *.tsbuildinfo",
41
+ "copy": "cpx \"src/**/*.{d.ts,vue,scss}\" lib"
42
+ },
38
43
  "dependencies": {
39
- "@vueuse/core": "^10.6.1",
40
- "sass": "^1.69.5",
41
- "vue": "^3.3.8",
42
- "vue-router": "^4.2.5",
43
- "@vuepress/core": "2.0.0-rc.0",
44
- "@vuepress/client": "2.0.0-rc.0",
45
- "@vuepress/plugin-active-header-links": "2.0.0-rc.0",
46
- "@vuepress/plugin-container": "2.0.0-rc.0",
47
- "@vuepress/plugin-external-link-icon": "2.0.0-rc.0",
48
- "@vuepress/plugin-nprogress": "2.0.0-rc.0",
49
- "@vuepress/plugin-back-to-top": "2.0.0-rc.0",
50
- "@vuepress/plugin-medium-zoom": "2.0.0-rc.0",
51
- "@vuepress/plugin-theme-data": "2.0.0-rc.0",
52
- "@vuepress/plugin-git": "2.0.0-rc.0",
53
- "@vuepress/plugin-palette": "2.0.0-rc.0",
54
- "@vuepress/utils": "2.0.0-rc.0",
55
- "@vuepress/shared": "2.0.0-rc.0",
56
- "@vuepress/plugin-prismjs": "2.0.0-rc.0"
44
+ "@vuepress/plugin-active-header-links": "2.0.0-rc.1",
45
+ "@vuepress/plugin-back-to-top": "2.0.0-rc.1",
46
+ "@vuepress/plugin-container": "2.0.0-rc.1",
47
+ "@vuepress/plugin-external-link-icon": "2.0.0-rc.1",
48
+ "@vuepress/plugin-git": "2.0.0-rc.1",
49
+ "@vuepress/plugin-medium-zoom": "2.0.0-rc.1",
50
+ "@vuepress/plugin-nprogress": "2.0.0-rc.1",
51
+ "@vuepress/plugin-palette": "2.0.0-rc.1",
52
+ "@vuepress/plugin-prismjs": "2.0.0-rc.1",
53
+ "@vuepress/plugin-theme-data": "2.0.0-rc.1",
54
+ "@vueuse/core": "^10.7.2",
55
+ "sass": "^1.70.0",
56
+ "vue": "^3.4.15",
57
+ "vue-router": "^4.2.5"
57
58
  },
58
59
  "peerDependencies": {
59
- "sass-loader": "^13.3.2"
60
+ "sass-loader": "^14.0.0",
61
+ "vuepress": "2.0.0-rc.2"
60
62
  },
61
63
  "peerDependenciesMeta": {
62
64
  "sass-loader": {
@@ -66,9 +68,5 @@
66
68
  "publishConfig": {
67
69
  "access": "public"
68
70
  },
69
- "scripts": {
70
- "build": "tsc -b tsconfig.build.json",
71
- "clean": "rimraf lib *.tsbuildinfo",
72
- "copy": "cpx \"src/**/*.{d.ts,vue,scss}\" lib"
73
- }
74
- }
71
+ "gitHead": "1de7fea6963c3dd6c89df21eca4accc2d31204a4"
72
+ }
@@ -1,5 +0,0 @@
1
- import type { Router } from 'vue-router';
2
- /**
3
- * Resolve a route with redirection
4
- */
5
- export declare const useResolveRouteWithRedirect: (to: import("vue-router").RouteLocationRaw, currentLocation?: import("vue-router").RouteLocationNormalizedLoaded | undefined) => ReturnType<Router['resolve']>;