@vuepress/theme-default 2.0.0-rc.33 → 2.0.0-rc.35

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 (107) hide show
  1. package/lib/client/components/VPDarkIcon.vue +8 -0
  2. package/lib/client/components/{DropdownTransition.vue → VPDropdownTransition.vue} +10 -1
  3. package/lib/client/components/VPEditIcon.vue +12 -0
  4. package/lib/client/components/VPHome.vue +38 -0
  5. package/lib/client/components/VPHomeFeatures.vue +68 -0
  6. package/lib/client/components/{HomeFooter.vue → VPHomeFooter.vue} +16 -2
  7. package/lib/client/components/{HomeHero.vue → VPHomeHero.vue} +107 -5
  8. package/lib/client/components/VPLightIcon.vue +28 -0
  9. package/lib/client/components/VPNavbar.vue +127 -0
  10. package/lib/client/components/{NavbarBrand.vue → VPNavbarBrand.vue} +36 -4
  11. package/lib/client/components/VPNavbarDropdown.vue +319 -0
  12. package/lib/client/components/VPNavbarItems.vue +110 -0
  13. package/lib/client/components/VPPage.vue +66 -0
  14. package/lib/client/components/VPPageMeta.vue +132 -0
  15. package/lib/client/components/VPPageNav.vue +118 -0
  16. package/lib/client/components/VPSidebar.vue +112 -0
  17. package/lib/client/components/VPSidebarItem.vue +169 -0
  18. package/lib/client/components/{SidebarItems.vue → VPSidebarItems.vue} +30 -6
  19. package/lib/client/components/VPToggleColorModeButton.vue +54 -0
  20. package/lib/client/components/VPToggleSidebarButton.vue +92 -0
  21. package/lib/client/components/global/Badge.vue +60 -18
  22. package/lib/client/components/global/CodeGroup.d.ts +1 -0
  23. package/lib/client/components/global/CodeGroup.js +4 -3
  24. package/lib/client/components/global/CodeGroupItem.vue +5 -16
  25. package/lib/client/composables/index.d.ts +4 -0
  26. package/lib/client/composables/index.js +4 -0
  27. package/lib/client/composables/useContributors.d.ts +3 -0
  28. package/lib/client/composables/useContributors.js +14 -0
  29. package/lib/client/composables/useDarkMode.js +1 -1
  30. package/lib/client/composables/useEditLink.d.ts +3 -0
  31. package/lib/client/composables/useEditLink.js +31 -0
  32. package/lib/client/composables/useLastUpdated.d.ts +2 -0
  33. package/lib/client/composables/useLastUpdated.js +17 -0
  34. package/lib/client/composables/useNavbarConfig.d.ts +2 -2
  35. package/lib/client/composables/useNavbarConfig.js +1 -1
  36. package/lib/client/composables/useNavbarRepo.d.ts +2 -2
  37. package/lib/client/composables/useNavbarRepo.js +1 -1
  38. package/lib/client/composables/useNavbarSelectLanguage.d.ts +2 -2
  39. package/lib/client/composables/useNavbarSelectLanguage.js +2 -2
  40. package/lib/client/composables/useNavigate.js +4 -7
  41. package/lib/client/composables/useRelatedLinks.d.ts +8 -0
  42. package/lib/client/composables/useRelatedLinks.js +91 -0
  43. package/lib/client/composables/useSidebarItems.d.ts +10 -9
  44. package/lib/client/composables/useSidebarItems.js +14 -14
  45. package/lib/client/config.js +4 -2
  46. package/lib/client/index.d.ts +1 -0
  47. package/lib/client/index.js +1 -0
  48. package/lib/client/layouts/Layout.vue +111 -18
  49. package/lib/client/layouts/NotFound.vue +1 -1
  50. package/lib/client/styles/_mixins.scss +4 -4
  51. package/lib/client/styles/_variables.module.scss +1 -1
  52. package/lib/client/styles/_variables.scss +1 -0
  53. package/lib/client/styles/code-group.scss +32 -29
  54. package/lib/client/styles/{code.scss → content/code.scss} +55 -31
  55. package/lib/client/styles/{custom-container.scss → content/custom-container.scss} +9 -5
  56. package/lib/client/styles/content/index.scss +4 -0
  57. package/lib/client/styles/content/normalize.scss +39 -0
  58. package/lib/client/styles/{toc.scss → content/toc.scss} +1 -1
  59. package/lib/client/styles/external-link-icon.scss +7 -3
  60. package/lib/client/styles/index.scss +2 -13
  61. package/lib/client/styles/layout.scss +3 -203
  62. package/lib/client/styles/normalize.scss +4 -3
  63. package/lib/client/styles/plugins.scss +20 -0
  64. package/lib/client/styles/vars-dark.scss +17 -16
  65. package/lib/client/styles/vars.scss +19 -23
  66. package/lib/client/typings.d.ts +13 -0
  67. package/lib/client/typings.js +1 -0
  68. package/lib/client/utils/getAutoLink.d.ts +9 -0
  69. package/lib/client/utils/{getNavLink.js → getAutoLink.js} +2 -2
  70. package/lib/client/utils/index.d.ts +1 -1
  71. package/lib/client/utils/index.js +1 -1
  72. package/lib/client/utils/isActiveSidebarItem.d.ts +2 -2
  73. package/lib/client/utils/isActiveSidebarItem.js +3 -3
  74. package/lib/node/defaultTheme.js +9 -1
  75. package/lib/node/utils/assignDefaultLocaleOptions.js +1 -1
  76. package/lib/shared/index.d.ts +2 -0
  77. package/lib/shared/index.js +2 -0
  78. package/lib/shared/nav.d.ts +21 -30
  79. package/lib/shared/navbar.d.ts +21 -0
  80. package/lib/shared/navbar.js +1 -0
  81. package/lib/shared/options.d.ts +6 -5
  82. package/lib/shared/page.d.ts +2 -2
  83. package/lib/shared/sidebar.d.ts +26 -0
  84. package/lib/shared/sidebar.js +1 -0
  85. package/package.json +18 -18
  86. package/templates/build.html +2 -0
  87. package/lib/client/components/Home.vue +0 -15
  88. package/lib/client/components/HomeContent.vue +0 -5
  89. package/lib/client/components/HomeFeatures.vue +0 -22
  90. package/lib/client/components/Navbar.vue +0 -80
  91. package/lib/client/components/NavbarDropdown.vue +0 -125
  92. package/lib/client/components/NavbarItems.vue +0 -51
  93. package/lib/client/components/Page.vue +0 -31
  94. package/lib/client/components/PageMeta.vue +0 -220
  95. package/lib/client/components/PageNav.vue +0 -228
  96. package/lib/client/components/Sidebar.vue +0 -18
  97. package/lib/client/components/SidebarItem.vue +0 -86
  98. package/lib/client/components/ToggleColorModeButton.vue +0 -57
  99. package/lib/client/components/ToggleSidebarButton.vue +0 -24
  100. package/lib/client/styles/badge.scss +0 -36
  101. package/lib/client/styles/home.scss +0 -168
  102. package/lib/client/styles/navbar-dropdown.scss +0 -177
  103. package/lib/client/styles/navbar.scss +0 -197
  104. package/lib/client/styles/page.scss +0 -11
  105. package/lib/client/styles/sidebar.scss +0 -128
  106. package/lib/client/styles/transitions.scss +0 -22
  107. package/lib/client/utils/getNavLink.d.ts +0 -9
@@ -1,5 +1,6 @@
1
1
  import { useStorage } from '@vueuse/core';
2
2
  import { computed, defineComponent, h, onBeforeUpdate, onMounted, ref, watch, } from 'vue';
3
+ import '../../styles/code-group.scss';
3
4
  export const CodeGroup = defineComponent({
4
5
  name: 'CodeGroup',
5
6
  slots: Object,
@@ -95,7 +96,7 @@ export const CodeGroup = defineComponent({
95
96
  });
96
97
  }
97
98
  return h('div', { class: 'code-group' }, [
98
- h('div', { class: 'code-group__nav', role: 'tablist' }, items.map((vnode, i) => {
99
+ h('div', { class: 'code-group-nav', role: 'tablist' }, items.map((vnode, i) => {
99
100
  const isActive = i === activeIndex.value;
100
101
  return h('button', {
101
102
  ref: (element) => {
@@ -104,8 +105,8 @@ export const CodeGroup = defineComponent({
104
105
  }
105
106
  },
106
107
  class: {
107
- 'code-group__nav-tab': true,
108
- 'code-group__nav-tab-active': isActive,
108
+ 'code-group-nav-tab': true,
109
+ 'active': isActive,
109
110
  },
110
111
  role: 'tab',
111
112
  ariaSelected: isActive,
@@ -3,25 +3,14 @@ defineOptions({
3
3
  name: 'CodeGroupItem',
4
4
  })
5
5
 
6
- defineProps({
7
- title: {
8
- type: String,
9
- required: true,
10
- },
11
- active: {
12
- type: Boolean,
13
- required: false,
14
- default: false,
15
- },
16
- })
6
+ defineProps<{
7
+ title: string
8
+ active?: boolean
9
+ }>()
17
10
  </script>
18
11
 
19
12
  <template>
20
- <div
21
- class="code-group-item"
22
- :class="{ 'code-group-item__active': active }"
23
- role="tabpanel"
24
- >
13
+ <div class="code-group-item" :class="{ active }" role="tabpanel">
25
14
  <slot />
26
15
  </div>
27
16
  </template>
@@ -1,8 +1,12 @@
1
+ export * from './useContributors.js';
1
2
  export * from './useDarkMode.js';
3
+ export * from './useEditLink.js';
4
+ export * from './useLastUpdated.js';
2
5
  export * from './useNavigate.js';
3
6
  export * from './useNavbarConfig.js';
4
7
  export * from './useNavbarRepo.js';
5
8
  export * from './useNavbarSelectLanguage.js';
9
+ export * from './useRelatedLinks.js';
6
10
  export * from './useScrollPromise.js';
7
11
  export * from './useSidebarItems.js';
8
12
  export * from './useThemeData.js';
@@ -1,8 +1,12 @@
1
+ export * from './useContributors.js';
1
2
  export * from './useDarkMode.js';
3
+ export * from './useEditLink.js';
4
+ export * from './useLastUpdated.js';
2
5
  export * from './useNavigate.js';
3
6
  export * from './useNavbarConfig.js';
4
7
  export * from './useNavbarRepo.js';
5
8
  export * from './useNavbarSelectLanguage.js';
9
+ export * from './useRelatedLinks.js';
6
10
  export * from './useScrollPromise.js';
7
11
  export * from './useSidebarItems.js';
8
12
  export * from './useThemeData.js';
@@ -0,0 +1,3 @@
1
+ import type { ComputedRef } from 'vue';
2
+ import type { DefaultThemePageData } from '../../shared/index.js';
3
+ export declare const useContributors: () => ComputedRef<null | Required<DefaultThemePageData['git']>['contributors']>;
@@ -0,0 +1,14 @@
1
+ import { useThemeLocaleData } from '@theme/useThemeData';
2
+ import { computed } from 'vue';
3
+ import { usePageData, usePageFrontmatter } from 'vuepress/client';
4
+ export const useContributors = () => {
5
+ const themeLocale = useThemeLocaleData();
6
+ const page = usePageData();
7
+ const frontmatter = usePageFrontmatter();
8
+ return computed(() => {
9
+ const showContributors = frontmatter.value.contributors ?? themeLocale.value.contributors ?? true;
10
+ if (!showContributors)
11
+ return null;
12
+ return page.value.git?.contributors ?? null;
13
+ });
14
+ };
@@ -1,6 +1,6 @@
1
+ import { useThemeLocaleData } from '@theme/useThemeData';
1
2
  import { usePreferredDark, useStorage } from '@vueuse/core';
2
3
  import { computed, inject, onMounted, onUnmounted, provide, watch } from 'vue';
3
- import { useThemeLocaleData } from './useThemeData.js';
4
4
  export const darkModeSymbol = Symbol(__VUEPRESS_DEV__ ? 'darkMode' : '');
5
5
  /**
6
6
  * Inject dark mode global computed
@@ -0,0 +1,3 @@
1
+ import type { ComputedRef } from 'vue';
2
+ import type { AutoLinkConfig } from 'vuepress/client';
3
+ export declare const useEditLink: () => ComputedRef<null | AutoLinkConfig>;
@@ -0,0 +1,31 @@
1
+ import { useThemeLocaleData } from '@theme/useThemeData';
2
+ import { computed } from 'vue';
3
+ import { usePageData, usePageFrontmatter } from 'vuepress/client';
4
+ import { resolveEditLink } from '../utils/index.js';
5
+ export const useEditLink = () => {
6
+ const themeLocale = useThemeLocaleData();
7
+ const page = usePageData();
8
+ const frontmatter = usePageFrontmatter();
9
+ return computed(() => {
10
+ const showEditLink = frontmatter.value.editLink ?? themeLocale.value.editLink ?? true;
11
+ if (!showEditLink) {
12
+ return null;
13
+ }
14
+ const { repo, docsRepo = repo, docsBranch = 'main', docsDir = '', editLinkText, } = themeLocale.value;
15
+ if (!docsRepo)
16
+ return null;
17
+ const editLink = resolveEditLink({
18
+ docsRepo,
19
+ docsBranch,
20
+ docsDir,
21
+ filePathRelative: page.value.filePathRelative,
22
+ editLinkPattern: frontmatter.value.editLinkPattern ?? themeLocale.value.editLinkPattern,
23
+ });
24
+ if (!editLink)
25
+ return null;
26
+ return {
27
+ text: editLinkText ?? 'Edit this page',
28
+ link: editLink,
29
+ };
30
+ });
31
+ };
@@ -0,0 +1,2 @@
1
+ import type { ComputedRef } from 'vue';
2
+ export declare const useLastUpdated: () => ComputedRef<null | string>;
@@ -0,0 +1,17 @@
1
+ import { useThemeLocaleData } from '@theme/useThemeData';
2
+ import { computed } from 'vue';
3
+ import { usePageData, usePageFrontmatter } from 'vuepress/client';
4
+ export const useLastUpdated = () => {
5
+ const themeLocale = useThemeLocaleData();
6
+ const page = usePageData();
7
+ const frontmatter = usePageFrontmatter();
8
+ return computed(() => {
9
+ const showLastUpdated = frontmatter.value.lastUpdated ?? themeLocale.value.lastUpdated ?? true;
10
+ if (!showLastUpdated)
11
+ return null;
12
+ if (!page.value.git?.updatedTime)
13
+ return null;
14
+ const updatedDate = new Date(page.value.git?.updatedTime);
15
+ return updatedDate.toLocaleString();
16
+ });
17
+ };
@@ -1,3 +1,3 @@
1
1
  import type { ComputedRef } from 'vue';
2
- import type { ResolvedNavbarItem } from '../../shared/index.js';
3
- export declare const useNavbarConfig: () => ComputedRef<ResolvedNavbarItem[]>;
2
+ import type { NavbarItem } from '../typings.js';
3
+ export declare const useNavbarConfig: () => ComputedRef<NavbarItem[]>;
@@ -1,7 +1,7 @@
1
+ import { useThemeLocaleData } from '@theme/useThemeData';
1
2
  import { computed } from 'vue';
2
3
  import { isString } from 'vuepress/shared';
3
4
  import { getAutoLink, isLinkInternal, resolvePrefix } from '../utils/index.js';
4
- import { useThemeLocaleData } from './useThemeData.js';
5
5
  const resolveNavbarItem = (item, prefix = '') => {
6
6
  if (isString(item)) {
7
7
  return getAutoLink(resolvePrefix(prefix, item));
@@ -1,6 +1,6 @@
1
1
  import type { ComputedRef } from 'vue';
2
- import type { ResolvedNavbarItem } from '../../shared/index.js';
2
+ import type { NavbarItem } from '../typings.js';
3
3
  /**
4
4
  * Get navbar config of repository link
5
5
  */
6
- export declare const useNavbarRepo: () => ComputedRef<ResolvedNavbarItem[]>;
6
+ export declare const useNavbarRepo: () => ComputedRef<NavbarItem[]>;
@@ -1,7 +1,7 @@
1
+ import { useThemeLocaleData } from '@theme/useThemeData';
1
2
  import { computed } from 'vue';
2
3
  import { isLinkHttp } from 'vuepress/shared';
3
4
  import { resolveRepoType } from '../utils/index.js';
4
- import { useThemeLocaleData } from './useThemeData.js';
5
5
  /**
6
6
  * Get navbar config of repository link
7
7
  */
@@ -1,6 +1,6 @@
1
1
  import type { ComputedRef } from 'vue';
2
- import type { ResolvedNavbarItem } from '../../shared/index.js';
2
+ import type { NavbarItem } from '../typings.js';
3
3
  /**
4
4
  * Get navbar config of select language dropdown
5
5
  */
6
- export declare const useNavbarSelectLanguage: () => ComputedRef<ResolvedNavbarItem[]>;
6
+ export declare const useNavbarSelectLanguage: () => ComputedRef<NavbarItem[]>;
@@ -1,7 +1,7 @@
1
+ import { useThemeData, useThemeLocaleData } from '@theme/useThemeData';
1
2
  import { useRoutePaths } from '@vuepress/helper/client';
2
3
  import { computed } from 'vue';
3
4
  import { useRoute, useRouteLocale, useSiteData, useSiteLocaleData, } from 'vuepress/client';
4
- import { useThemeData, useThemeLocaleData } from './useThemeData.js';
5
5
  /**
6
6
  * Get navbar config of select language dropdown
7
7
  */
@@ -36,7 +36,7 @@ export const useNavbarSelectLanguage = () => {
36
36
  if (targetLang === siteLocale.value.lang) {
37
37
  return {
38
38
  text,
39
- activeMatch: /./,
39
+ activeMatch: '.',
40
40
  link: route.fullPath,
41
41
  };
42
42
  }
@@ -1,6 +1,5 @@
1
1
  import { isLinkAbsolute, isLinkWithProtocol } from '@vuepress/helper/client';
2
2
  import { useRoute, useRouter } from 'vuepress/client';
3
- const FAKE_HOST = 'http://.';
4
3
  export const useNavigate = () => {
5
4
  const router = useRouter();
6
5
  const route = useRoute();
@@ -12,14 +11,12 @@ export const useNavigate = () => {
12
11
  router.push(url);
13
12
  }
14
13
  else if (isLinkWithProtocol(url)) {
15
- // Outer url
16
- if (window)
17
- window.open(url);
14
+ // external url
15
+ window?.open(url);
18
16
  }
19
17
  else {
20
- // Inner relative path
21
- const loc = route.path.slice(0, route.path.lastIndexOf('/'));
22
- router.push(new URL(`${loc}/${encodeURI(url)}`, FAKE_HOST).pathname);
18
+ // relative url
19
+ router.push(encodeURI(url));
23
20
  }
24
21
  };
25
22
  };
@@ -0,0 +1,8 @@
1
+ import type { ComputedRef } from 'vue';
2
+ import type { AutoLinkOptions } from '../../shared/index.js';
3
+ interface RelatedLinks {
4
+ prevLink: ComputedRef<AutoLinkOptions | null>;
5
+ nextLink: ComputedRef<AutoLinkOptions | null>;
6
+ }
7
+ export declare const useRelatedLinks: () => RelatedLinks;
8
+ export {};
@@ -0,0 +1,91 @@
1
+ import { useSidebarItems } from '@theme/useSidebarItems';
2
+ import { useThemeLocaleData } from '@theme/useThemeData';
3
+ import { computed } from 'vue';
4
+ import { resolveRoute, usePageFrontmatter, useRoute } from 'vuepress/client';
5
+ import { isPlainObject, isString } from 'vuepress/shared';
6
+ import { getAutoLink } from '../utils/index.js';
7
+ const resolveFromFrontmatterConfig = (config, currentPath) => {
8
+ if (config === false) {
9
+ return false;
10
+ }
11
+ if (isString(config)) {
12
+ return getAutoLink(config, currentPath);
13
+ }
14
+ if (isPlainObject(config)) {
15
+ return {
16
+ ...config,
17
+ link: getAutoLink(config.link, currentPath).link,
18
+ };
19
+ }
20
+ return null;
21
+ };
22
+ /**
23
+ * Resolve `prev` or `next` config from sidebar items
24
+ */
25
+ const resolveFromSidebarItems = (sidebarItems, currentPath, offset) => {
26
+ const linkIndex = sidebarItems.findIndex((item) => item.link === currentPath);
27
+ if (linkIndex !== -1) {
28
+ const targetItem = sidebarItems[linkIndex + offset];
29
+ if (!targetItem)
30
+ return null;
31
+ if (targetItem.link)
32
+ return targetItem;
33
+ if ('prefix' in targetItem && !resolveRoute(targetItem.prefix).notFound)
34
+ return {
35
+ ...targetItem,
36
+ link: targetItem.prefix,
37
+ };
38
+ return null;
39
+ }
40
+ for (const item of sidebarItems) {
41
+ if ('children' in item) {
42
+ const childResult = resolveFromSidebarItems(item.children, currentPath, offset);
43
+ if (childResult) {
44
+ return childResult;
45
+ }
46
+ }
47
+ }
48
+ const prefixIndex = sidebarItems.findIndex((item) => 'prefix' in item && item.prefix === currentPath);
49
+ if (prefixIndex !== -1) {
50
+ const targetItem = sidebarItems[prefixIndex + offset];
51
+ if (!targetItem)
52
+ return null;
53
+ if (targetItem.link)
54
+ return targetItem;
55
+ if ('prefix' in targetItem && !resolveRoute(targetItem.prefix).notFound)
56
+ return {
57
+ ...targetItem,
58
+ link: targetItem.prefix,
59
+ };
60
+ return null;
61
+ }
62
+ return null;
63
+ };
64
+ export const useRelatedLinks = () => {
65
+ const frontmatter = usePageFrontmatter();
66
+ const themeLocale = useThemeLocaleData();
67
+ const sidebarItems = useSidebarItems();
68
+ const route = useRoute();
69
+ const prevLink = computed(() => {
70
+ const prevConfig = resolveFromFrontmatterConfig(frontmatter.value.prev, route.path);
71
+ return prevConfig === false
72
+ ? null
73
+ : prevConfig ??
74
+ (themeLocale.value.prev === false
75
+ ? null
76
+ : resolveFromSidebarItems(sidebarItems.value, route.path, -1));
77
+ });
78
+ const nextLink = computed(() => {
79
+ const nextConfig = resolveFromFrontmatterConfig(frontmatter.value.next, route.path);
80
+ return nextConfig === false
81
+ ? null
82
+ : nextConfig ??
83
+ (themeLocale.value.next === false
84
+ ? null
85
+ : resolveFromSidebarItems(sidebarItems.value, route.path, 1));
86
+ });
87
+ return {
88
+ prevLink,
89
+ nextLink,
90
+ };
91
+ };
@@ -1,7 +1,8 @@
1
1
  import type { ComputedRef, InjectionKey } from 'vue';
2
2
  import type { PageData, PageHeader } from 'vuepress/client';
3
- import type { ResolvedSidebarItem, SidebarConfig, SidebarConfigArray, SidebarConfigObject } from '../../shared/index.js';
4
- export type SidebarItemsRef = ComputedRef<ResolvedSidebarItem[]>;
3
+ import type { SidebarArrayOptions, SidebarObjectOptions, SidebarOptions } from '../../shared/index.js';
4
+ import type { SidebarHeaderItem, SidebarItem } from '../typings.js';
5
+ export type SidebarItemsRef = ComputedRef<SidebarItem[]>;
5
6
  export declare const sidebarItemsSymbol: InjectionKey<SidebarItemsRef>;
6
7
  /**
7
8
  * Inject sidebar items global computed
@@ -16,21 +17,21 @@ export declare const setupSidebarItems: () => void;
16
17
  *
17
18
  * It should only be resolved and provided once
18
19
  */
19
- export declare const resolveSidebarItems: (sidebarConfig: SidebarConfig | 'auto' | false, sidebarDepth: number, page: PageData, path: string, routeLocale: string) => ResolvedSidebarItem[];
20
+ export declare const resolveSidebarItems: (sidebarConfig: false | SidebarOptions, sidebarDepth: number, page: PageData, path: string, routeLocale: string) => SidebarItem[];
20
21
  /**
21
22
  * Util to transform page header to sidebar item
22
23
  */
23
- export declare const headerToSidebarItem: (sidebarDepth: number, header: PageHeader) => ResolvedSidebarItem;
24
- export declare const headersToSidebarItemChildren: (sidebarDepth: number, headers: PageHeader[]) => ResolvedSidebarItem[];
24
+ export declare const resolveSidebarHeaderItem: (sidebarDepth: number, header: PageHeader) => SidebarHeaderItem;
25
+ export declare const resolveSidebarHeaderItems: (sidebarDepth: number, headers: PageHeader[]) => SidebarHeaderItem[];
25
26
  /**
26
- * Resolve sidebar items if the config is `auto`
27
+ * Resolve current page and its header to sidebar items if the config is `heading`
27
28
  */
28
- export declare const resolveAutoSidebarItems: (sidebarDepth: number, page: PageData) => ResolvedSidebarItem[];
29
+ export declare const resolveSidebarHeadingItem: (sidebarDepth: number, page: PageData) => SidebarItem[];
29
30
  /**
30
31
  * Resolve sidebar items if the config is an array
31
32
  */
32
- export declare const resolveArraySidebarItems: (sidebarConfig: SidebarConfigArray, sidebarDepth: number, page: PageData, path: string, prefix?: string) => ResolvedSidebarItem[];
33
+ export declare const resolveArraySidebarItems: (sidebarConfig: SidebarArrayOptions, sidebarDepth: number, page: PageData, path: string, prefix?: string) => SidebarItem[];
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, page: PageData, path: string) => ResolvedSidebarItem[];
37
+ export declare const resolveMultiSidebarItems: (sidebarConfig: SidebarObjectOptions, sidebarDepth: number, page: PageData, path: string) => SidebarItem[];
@@ -1,9 +1,9 @@
1
+ import { useThemeLocaleData } from '@theme/useThemeData';
1
2
  import { keys, startsWith } from '@vuepress/helper/client';
2
3
  import { computed, inject, provide } from 'vue';
3
4
  import { usePageData, usePageFrontmatter, useRoute, useRouteLocale, } from 'vuepress/client';
4
5
  import { isPlainObject, isString } from 'vuepress/shared';
5
6
  import { getAutoLink, isLinkInternal, resolvePrefix } from '../utils/index.js';
6
- import { useThemeLocaleData } from './useThemeData.js';
7
7
  export const sidebarItemsSymbol = Symbol('sidebarItems');
8
8
  /**
9
9
  * Inject sidebar items global computed
@@ -26,7 +26,7 @@ export const setupSidebarItems = () => {
26
26
  const routeLocale = useRouteLocale();
27
27
  const sidebarConfig = computed(() => frontmatter.value.home
28
28
  ? false
29
- : frontmatter.value.sidebar ?? themeLocale.value.sidebar ?? 'auto');
29
+ : frontmatter.value.sidebar ?? themeLocale.value.sidebar ?? 'heading');
30
30
  const sidebarDepth = computed(() => frontmatter.value.sidebarDepth ?? themeLocale.value.sidebarDepth ?? 2);
31
31
  const sidebarItems = computed(() => resolveSidebarItems(sidebarConfig.value, sidebarDepth.value, page.value, route.path, routeLocale.value));
32
32
  provide(sidebarItemsSymbol, sidebarItems);
@@ -41,8 +41,8 @@ export const resolveSidebarItems = (sidebarConfig, sidebarDepth, page, path, rou
41
41
  if (sidebarConfig === false) {
42
42
  return [];
43
43
  }
44
- if (sidebarConfig === 'auto') {
45
- return resolveAutoSidebarItems(sidebarDepth, page);
44
+ if (sidebarConfig === 'heading') {
45
+ return resolveSidebarHeadingItem(sidebarDepth, page);
46
46
  }
47
47
  if (Array.isArray(sidebarConfig)) {
48
48
  return resolveArraySidebarItems(sidebarConfig, sidebarDepth, page, path, routeLocale);
@@ -55,21 +55,21 @@ export const resolveSidebarItems = (sidebarConfig, sidebarDepth, page, path, rou
55
55
  /**
56
56
  * Util to transform page header to sidebar item
57
57
  */
58
- export const headerToSidebarItem = (sidebarDepth, header) => ({
58
+ export const resolveSidebarHeaderItem = (sidebarDepth, header) => ({
59
59
  text: header.title,
60
60
  link: header.link,
61
- children: headersToSidebarItemChildren(sidebarDepth, header.children),
61
+ children: resolveSidebarHeaderItems(sidebarDepth, header.children),
62
62
  });
63
- export const headersToSidebarItemChildren = (sidebarDepth, headers) => sidebarDepth > 0
64
- ? headers.map((header) => headerToSidebarItem(sidebarDepth - 1, header))
63
+ export const resolveSidebarHeaderItems = (sidebarDepth, headers) => sidebarDepth > 0
64
+ ? headers.map((header) => resolveSidebarHeaderItem(sidebarDepth - 1, header))
65
65
  : [];
66
66
  /**
67
- * Resolve sidebar items if the config is `auto`
67
+ * Resolve current page and its header to sidebar items if the config is `heading`
68
68
  */
69
- export const resolveAutoSidebarItems = (sidebarDepth, page) => [
69
+ export const resolveSidebarHeadingItem = (sidebarDepth, page) => [
70
70
  {
71
71
  text: page.title,
72
- children: headersToSidebarItemChildren(sidebarDepth, page.headers),
72
+ children: resolveSidebarHeaderItems(sidebarDepth, page.headers),
73
73
  },
74
74
  ];
75
75
  /**
@@ -87,7 +87,7 @@ export const resolveArraySidebarItems = (sidebarConfig, sidebarDepth, page, path
87
87
  : item.link,
88
88
  }
89
89
  : item;
90
- if (childItem.children) {
90
+ if ('children' in childItem) {
91
91
  return {
92
92
  ...childItem,
93
93
  children: childItem.children.map((item) => handleChildItem(item, resolvePrefix(pathPrefix, childItem.prefix))),
@@ -100,7 +100,7 @@ export const resolveArraySidebarItems = (sidebarConfig, sidebarDepth, page, path
100
100
  const headers = page.headers[0]?.level === 1 ? page.headers[0].children : page.headers;
101
101
  return {
102
102
  ...childItem,
103
- children: headersToSidebarItemChildren(sidebarDepth, headers),
103
+ children: resolveSidebarHeaderItems(sidebarDepth, headers),
104
104
  };
105
105
  }
106
106
  return childItem;
@@ -118,7 +118,7 @@ export const resolveMultiSidebarItems = (sidebarConfig, sidebarDepth, page, path
118
118
  const matched = sidebarConfig[base];
119
119
  return matched
120
120
  ? matched === 'heading'
121
- ? resolveAutoSidebarItems(sidebarDepth, page)
121
+ ? resolveSidebarHeadingItem(sidebarDepth, page)
122
122
  : resolveArraySidebarItems(matched, sidebarDepth, page, path, base)
123
123
  : [];
124
124
  }
@@ -1,8 +1,10 @@
1
+ import { setupDarkMode } from '@theme/useDarkMode';
2
+ import { useScrollPromise } from '@theme/useScrollPromise';
3
+ import { setupSidebarItems } from '@theme/useSidebarItems';
1
4
  import { hasGlobalComponent } from '@vuepress/helper/client';
2
5
  import { h } from 'vue';
3
6
  import { defineClientConfig } from 'vuepress/client';
4
7
  import { Badge, CodeGroup, CodeGroupItem } from './components/global/index.js';
5
- import { setupDarkMode, setupSidebarItems, useScrollPromise, } from './composables/index.js';
6
8
  import Layout from './layouts/Layout.vue';
7
9
  import NotFound from './layouts/NotFound.vue';
8
10
  import '@vuepress/helper/normalize.css';
@@ -16,7 +18,7 @@ export default defineClientConfig({
16
18
  if (!hasGlobalComponent('CodeGroupItem'))
17
19
  app.component('CodeGroupItem', CodeGroupItem);
18
20
  // compat with @vuepress/plugin-docsearch and @vuepress/plugin-search
19
- app.component('NavbarSearch', () => {
21
+ app.component('VPSearch', () => {
20
22
  const SearchComponent = app.component('Docsearch') || app.component('SearchBox');
21
23
  if (SearchComponent) {
22
24
  return h(SearchComponent);
@@ -1,3 +1,4 @@
1
1
  export * from './composables/index.js';
2
+ export * from './typings.js';
2
3
  export * from './utils/index.js';
3
4
  export type * from '../shared/index.js';
@@ -1,2 +1,3 @@
1
1
  export * from './composables/index.js';
2
+ export * from './typings.js';
2
3
  export * from './utils/index.js';