@vuepress/theme-default 2.0.0-rc.123 → 2.0.0-rc.125

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 (195) hide show
  1. package/{lib → dist}/client/components/VPHomeHero.vue +7 -14
  2. package/{lib → dist}/client/components/VPNavbar.vue +8 -11
  3. package/{lib → dist}/client/components/VPNavbarBrand.vue +4 -5
  4. package/dist/client/composables/index.d.ts +12 -0
  5. package/dist/client/composables/index.js +1 -0
  6. package/dist/client/composables/useDarkMode.d.ts +2 -0
  7. package/dist/client/composables/useDarkMode.js +2 -0
  8. package/dist/client/composables/useDarkMode.js.map +1 -0
  9. package/dist/client/composables/useData.d.ts +2 -0
  10. package/dist/client/composables/useData.js +2 -0
  11. package/dist/client/composables/useData.js.map +1 -0
  12. package/dist/client/composables/useEditLink.d.ts +2 -0
  13. package/dist/client/composables/useEditLink.js +2 -0
  14. package/dist/client/composables/useEditLink.js.map +1 -0
  15. package/dist/client/composables/useHeaders.d.ts +18 -0
  16. package/dist/client/composables/useHeaders.js +2 -0
  17. package/dist/client/composables/useHeaders.js.map +1 -0
  18. package/dist/client/composables/useNavbarConfig.d.ts +2 -0
  19. package/dist/client/composables/useNavbarConfig.js +2 -0
  20. package/dist/client/composables/useNavbarConfig.js.map +1 -0
  21. package/dist/client/composables/useNavbarRepo.d.ts +2 -0
  22. package/dist/client/composables/useNavbarRepo.js +2 -0
  23. package/dist/client/composables/useNavbarRepo.js.map +1 -0
  24. package/dist/client/composables/useNavbarSelectLanguage.d.ts +2 -0
  25. package/dist/client/composables/useNavbarSelectLanguage.js +2 -0
  26. package/dist/client/composables/useNavbarSelectLanguage.js.map +1 -0
  27. package/dist/client/composables/useNavigate.d.ts +2 -0
  28. package/dist/client/composables/useNavigate.js +2 -0
  29. package/dist/client/composables/useNavigate.js.map +1 -0
  30. package/dist/client/composables/useRelatedLinks.d.ts +2 -0
  31. package/dist/client/composables/useRelatedLinks.js +2 -0
  32. package/dist/client/composables/useRelatedLinks.js.map +1 -0
  33. package/dist/client/composables/useScrollPromise.d.ts +2 -0
  34. package/dist/client/composables/useScrollPromise.js +2 -0
  35. package/dist/client/composables/useScrollPromise.js.map +1 -0
  36. package/dist/client/composables/useSidebarItems.d.ts +2 -0
  37. package/dist/client/composables/useSidebarItems.js +2 -0
  38. package/dist/client/composables/useSidebarItems.js.map +1 -0
  39. package/dist/client/composables/useUpdateDeviceStatus.d.ts +2 -0
  40. package/dist/client/composables/useUpdateDeviceStatus.js +2 -0
  41. package/dist/client/composables/useUpdateDeviceStatus.js.map +1 -0
  42. package/dist/client/config.d.ts +6 -0
  43. package/dist/client/config.js +2 -0
  44. package/dist/client/config.js.map +1 -0
  45. package/dist/client/index.d.ts +21 -0
  46. package/dist/client/index.js +1 -0
  47. package/{lib → dist}/client/layouts/Layout.vue +2 -5
  48. package/{lib → dist}/client/layouts/NotFound.vue +1 -2
  49. package/{lib → dist}/client/styles/arrow.scss +1 -2
  50. package/{lib → dist}/client/styles/vars.scss +1 -2
  51. package/dist/client/utils/index.d.ts +6 -0
  52. package/dist/client/utils/index.js +1 -0
  53. package/dist/client/utils/isActiveSidebarItem.d.ts +2 -0
  54. package/dist/client/utils/isActiveSidebarItem.js +2 -0
  55. package/dist/client/utils/isActiveSidebarItem.js.map +1 -0
  56. package/dist/client/utils/resolveAutoLink.d.ts +2 -0
  57. package/dist/client/utils/resolveAutoLink.js +2 -0
  58. package/dist/client/utils/resolveAutoLink.js.map +1 -0
  59. package/dist/client/utils/resolveEditLink.d.ts +2 -0
  60. package/dist/client/utils/resolveEditLink.js +2 -0
  61. package/dist/client/utils/resolveEditLink.js.map +1 -0
  62. package/dist/client/utils/resolvePrefix.d.ts +2 -0
  63. package/dist/client/utils/resolvePrefix.js +2 -0
  64. package/dist/client/utils/resolvePrefix.js.map +1 -0
  65. package/dist/client/utils/resolveRepoType.d.ts +2 -0
  66. package/dist/client/utils/resolveRepoType.js +2 -0
  67. package/dist/client/utils/resolveRepoType.js.map +1 -0
  68. package/dist/isActiveSidebarItem-aythFTeC.d.ts +8 -0
  69. package/dist/nav-DikslSJ_.d.ts +36 -0
  70. package/dist/node/index.d.ts +108 -0
  71. package/dist/node/index.js +2 -0
  72. package/dist/node/index.js.map +1 -0
  73. package/dist/page-FWcDnzJp.d.ts +292 -0
  74. package/{lib/client/utils/resolveAutoLink.d.ts → dist/resolveAutoLink-BR2Z05MD.d.ts} +7 -2
  75. package/dist/resolveEditLink-DazcWeGf.d.ts +20 -0
  76. package/dist/resolvePrefix-BN9K9RA5.d.ts +5 -0
  77. package/dist/resolveRepoType-Wcj35_rs.d.ts +6 -0
  78. package/dist/sidebar-CF1YPYLN.d.ts +53 -0
  79. package/dist/typings-NbQSzbOn.d.ts +19 -0
  80. package/dist/useDarkMode-DLor2cV7.d.ts +19 -0
  81. package/dist/useData-JDen_Bxm.d.ts +13 -0
  82. package/dist/useEditLink-DPCTvXmM.d.ts +8 -0
  83. package/dist/useNavbarConfig-C19TGFg7.d.ts +8 -0
  84. package/dist/useNavbarRepo-DxhSIAFq.d.ts +13 -0
  85. package/dist/useNavbarSelectLanguage-4GkrPvc2.d.ts +13 -0
  86. package/dist/useNavigate-lH4xyHOV.d.ts +5 -0
  87. package/dist/useRelatedLinks-ChTW2RRU.d.ts +12 -0
  88. package/dist/useScrollPromise-BAl732Uv.d.ts +10 -0
  89. package/dist/useSidebarItems-CdpB96Ta.d.ts +80 -0
  90. package/dist/useUpdateDeviceStatus-SBnOZx8J.d.ts +14 -0
  91. package/package.json +39 -30
  92. package/lib/client/components/global/index.d.ts +0 -2
  93. package/lib/client/components/global/index.js +0 -2
  94. package/lib/client/composables/index.d.ts +0 -11
  95. package/lib/client/composables/index.js +0 -11
  96. package/lib/client/composables/useDarkMode.d.ts +0 -14
  97. package/lib/client/composables/useDarkMode.js +0 -64
  98. package/lib/client/composables/useData.d.ts +0 -8
  99. package/lib/client/composables/useData.js +0 -7
  100. package/lib/client/composables/useEditLink.d.ts +0 -3
  101. package/lib/client/composables/useEditLink.js +0 -28
  102. package/lib/client/composables/useHeaders.d.ts +0 -13
  103. package/lib/client/composables/useHeaders.js +0 -42
  104. package/lib/client/composables/useNavbarConfig.d.ts +0 -3
  105. package/lib/client/composables/useNavbarConfig.js +0 -27
  106. package/lib/client/composables/useNavbarRepo.d.ts +0 -8
  107. package/lib/client/composables/useNavbarRepo.js +0 -40
  108. package/lib/client/composables/useNavbarSelectLanguage.d.ts +0 -8
  109. package/lib/client/composables/useNavbarSelectLanguage.js +0 -60
  110. package/lib/client/composables/useNavigate.d.ts +0 -1
  111. package/lib/client/composables/useNavigate.js +0 -22
  112. package/lib/client/composables/useRelatedLinks.d.ts +0 -8
  113. package/lib/client/composables/useRelatedLinks.js +0 -95
  114. package/lib/client/composables/useScrollPromise.d.ts +0 -6
  115. package/lib/client/composables/useScrollPromise.js +0 -16
  116. package/lib/client/composables/useSidebarItems.d.ts +0 -75
  117. package/lib/client/composables/useSidebarItems.js +0 -164
  118. package/lib/client/composables/useUpdateDeviceStatus.d.ts +0 -10
  119. package/lib/client/composables/useUpdateDeviceStatus.js +0 -34
  120. package/lib/client/config.d.ts +0 -5
  121. package/lib/client/config.js +0 -35
  122. package/lib/client/index.d.ts +0 -4
  123. package/lib/client/index.js +0 -2
  124. package/lib/client/typings.d.ts +0 -13
  125. package/lib/client/typings.js +0 -1
  126. package/lib/client/utils/index.d.ts +0 -5
  127. package/lib/client/utils/index.js +0 -5
  128. package/lib/client/utils/isActiveSidebarItem.d.ts +0 -3
  129. package/lib/client/utils/isActiveSidebarItem.js +0 -20
  130. package/lib/client/utils/resolveAutoLink.js +0 -23
  131. package/lib/client/utils/resolveEditLink.d.ts +0 -9
  132. package/lib/client/utils/resolveEditLink.js +0 -29
  133. package/lib/client/utils/resolvePrefix.d.ts +0 -1
  134. package/lib/client/utils/resolvePrefix.js +0 -4
  135. package/lib/client/utils/resolveRepoType.d.ts +0 -2
  136. package/lib/client/utils/resolveRepoType.js +0 -12
  137. package/lib/node/defaultTheme.d.ts +0 -15
  138. package/lib/node/defaultTheme.js +0 -140
  139. package/lib/node/index.d.ts +0 -4
  140. package/lib/node/index.js +0 -2
  141. package/lib/node/typings.d.ts +0 -59
  142. package/lib/node/typings.js +0 -1
  143. package/lib/node/utils/assignDefaultLocaleOptions.d.ts +0 -7
  144. package/lib/node/utils/assignDefaultLocaleOptions.js +0 -51
  145. package/lib/node/utils/index.d.ts +0 -2
  146. package/lib/node/utils/index.js +0 -2
  147. package/lib/node/utils/resolveMarkdownHintLocales.d.ts +0 -12
  148. package/lib/node/utils/resolveMarkdownHintLocales.js +0 -22
  149. package/lib/shared/index.d.ts +0 -5
  150. package/lib/shared/index.js +0 -1
  151. package/lib/shared/nav.d.ts +0 -32
  152. package/lib/shared/nav.js +0 -1
  153. package/lib/shared/navbar.d.ts +0 -21
  154. package/lib/shared/navbar.js +0 -1
  155. package/lib/shared/options.d.ts +0 -244
  156. package/lib/shared/options.js +0 -1
  157. package/lib/shared/page.d.ts +0 -44
  158. package/lib/shared/page.js +0 -1
  159. package/lib/shared/sidebar.d.ts +0 -26
  160. package/lib/shared/sidebar.js +0 -1
  161. /package/{lib → dist}/client/components/VPAutoLink.vue +0 -0
  162. /package/{lib → dist}/client/components/VPDarkIcon.vue +0 -0
  163. /package/{lib → dist}/client/components/VPDropdownTransition.vue +0 -0
  164. /package/{lib → dist}/client/components/VPEditIcon.vue +0 -0
  165. /package/{lib → dist}/client/components/VPFadeSlideYTransition.vue +0 -0
  166. /package/{lib → dist}/client/components/VPHome.vue +0 -0
  167. /package/{lib → dist}/client/components/VPHomeFeatures.vue +0 -0
  168. /package/{lib → dist}/client/components/VPHomeFooter.vue +0 -0
  169. /package/{lib → dist}/client/components/VPLightIcon.vue +0 -0
  170. /package/{lib → dist}/client/components/VPNavbarDropdown.vue +0 -0
  171. /package/{lib → dist}/client/components/VPNavbarItems.vue +0 -0
  172. /package/{lib → dist}/client/components/VPPage.vue +0 -0
  173. /package/{lib → dist}/client/components/VPPageMeta.vue +0 -0
  174. /package/{lib → dist}/client/components/VPPageNav.vue +0 -0
  175. /package/{lib → dist}/client/components/VPSidebar.vue +0 -0
  176. /package/{lib → dist}/client/components/VPSidebarItem.vue +0 -0
  177. /package/{lib → dist}/client/components/VPSidebarItems.vue +0 -0
  178. /package/{lib → dist}/client/components/VPToggleColorModeButton.vue +0 -0
  179. /package/{lib → dist}/client/components/VPToggleSidebarButton.vue +0 -0
  180. /package/{lib → dist}/client/components/global/Badge.vue +0 -0
  181. /package/{lib → dist}/client/shim.d.ts +0 -0
  182. /package/{lib → dist}/client/styles/_mixins.scss +0 -0
  183. /package/{lib → dist}/client/styles/_variables.module.scss +0 -0
  184. /package/{lib → dist}/client/styles/_variables.scss +0 -0
  185. /package/{lib → dist}/client/styles/code-group.scss +0 -0
  186. /package/{lib → dist}/client/styles/content/code.scss +0 -0
  187. /package/{lib → dist}/client/styles/content/index.scss +0 -0
  188. /package/{lib → dist}/client/styles/content/normalize.scss +0 -0
  189. /package/{lib → dist}/client/styles/content/toc.scss +0 -0
  190. /package/{lib → dist}/client/styles/external-link-icon.scss +0 -0
  191. /package/{lib → dist}/client/styles/index.scss +0 -0
  192. /package/{lib → dist}/client/styles/layout.scss +0 -0
  193. /package/{lib → dist}/client/styles/normalize.scss +0 -0
  194. /package/{lib → dist}/client/styles/plugins.scss +0 -0
  195. /package/{lib → dist}/client/styles/vars-dark.scss +0 -0
@@ -1,8 +0,0 @@
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 {};
@@ -1,95 +0,0 @@
1
- import { resolveAutoLink } from '@theme/resolveAutoLink';
2
- import { useData } from '@theme/useData';
3
- import { useSidebarItems } from '@theme/useSidebarItems';
4
- import { computed } from 'vue';
5
- import { resolveRoute, useRoutePath } from 'vuepress/client';
6
- import { isPlainObject, isString } from 'vuepress/shared';
7
- const resolveFromFrontmatterConfig = (config, currentPath) => {
8
- if (config === false) {
9
- return false;
10
- }
11
- if (isString(config)) {
12
- return resolveAutoLink(config, currentPath);
13
- }
14
- if (isPlainObject(config)) {
15
- return {
16
- ...config,
17
- link: resolveAutoLink(config.link, currentPath).link,
18
- };
19
- }
20
- return null;
21
- };
22
- /**
23
- * Resolve `prev` or `next` config from sidebar items
24
- *
25
- * @param sidebarItems - Sidebar items / 侧边栏配置项
26
- * @param currentPath - Current route path / 当前路由路径
27
- * @param offset - The offset to find the target link, -1 for `prev` and 1 for `next` / 查找目标链接的偏移量,-1 表示查找 `prev`,1 表示查找 `next`
28
- * @returns Resolved link or null if not found
29
- */
30
- const resolveFromSidebarItems = (sidebarItems, currentPath, offset) => {
31
- const linkIndex = sidebarItems.findIndex((item) => item.link === currentPath);
32
- if (linkIndex !== -1) {
33
- const targetItem = sidebarItems[linkIndex + offset];
34
- if (!targetItem)
35
- return null;
36
- if (targetItem.link)
37
- return targetItem;
38
- if ('prefix' in targetItem && !resolveRoute(targetItem.prefix).notFound)
39
- return {
40
- ...targetItem,
41
- link: targetItem.prefix,
42
- };
43
- return null;
44
- }
45
- for (const item of sidebarItems) {
46
- if ('children' in item) {
47
- const childResult = resolveFromSidebarItems(item.children, currentPath, offset);
48
- if (childResult) {
49
- return childResult;
50
- }
51
- }
52
- }
53
- const prefixIndex = sidebarItems.findIndex((item) => 'prefix' in item && item.prefix === currentPath);
54
- if (prefixIndex !== -1) {
55
- const targetItem = sidebarItems[prefixIndex + offset];
56
- if (!targetItem)
57
- return null;
58
- if (targetItem.link)
59
- return targetItem;
60
- if ('prefix' in targetItem && !resolveRoute(targetItem.prefix).notFound)
61
- return {
62
- ...targetItem,
63
- link: targetItem.prefix,
64
- };
65
- return null;
66
- }
67
- return null;
68
- };
69
- export const useRelatedLinks = () => {
70
- const { frontmatter, themeLocale } = useData();
71
- const sidebarItems = useSidebarItems();
72
- const routePath = useRoutePath();
73
- const prevLink = computed(() => {
74
- const prevConfig = resolveFromFrontmatterConfig(frontmatter.value.prev, routePath.value);
75
- return prevConfig === false
76
- ? null
77
- : (prevConfig ??
78
- (themeLocale.value.prev === false
79
- ? null
80
- : resolveFromSidebarItems(sidebarItems.value, routePath.value, -1)));
81
- });
82
- const nextLink = computed(() => {
83
- const nextConfig = resolveFromFrontmatterConfig(frontmatter.value.next, routePath.value);
84
- return nextConfig === false
85
- ? null
86
- : (nextConfig ??
87
- (themeLocale.value.next === false
88
- ? null
89
- : resolveFromSidebarItems(sidebarItems.value, routePath.value, 1)));
90
- });
91
- return {
92
- prevLink,
93
- nextLink,
94
- };
95
- };
@@ -1,6 +0,0 @@
1
- export interface ScrollPromise {
2
- wait(): Promise<void> | null;
3
- pending: () => void;
4
- resolve: () => void;
5
- }
6
- export declare const useScrollPromise: () => ScrollPromise;
@@ -1,16 +0,0 @@
1
- let promise = null;
2
- let promiseResolve = null;
3
- const scrollPromise = {
4
- wait: () => promise,
5
- pending: () => {
6
- promise = new Promise((resolve) => {
7
- promiseResolve = resolve;
8
- });
9
- },
10
- resolve: () => {
11
- promiseResolve?.();
12
- promise = null;
13
- promiseResolve = null;
14
- },
15
- };
16
- export const useScrollPromise = () => scrollPromise;
@@ -1,75 +0,0 @@
1
- import type { ComputedRef, InjectionKey } from 'vue';
2
- import type { PageData, PageHeader } from 'vuepress/client';
3
- import type { SidebarArrayOptions, SidebarObjectOptions, SidebarOptions } from '../../shared/index.js';
4
- import type { SidebarHeaderItem, SidebarItem } from '../typings.js';
5
- /**
6
- * Util to transform page header to sidebar item
7
- *
8
- * @param header page header
9
- * @returns sidebar item from header
10
- */
11
- export declare const resolveSidebarPageHeader: (header: PageHeader) => SidebarHeaderItem;
12
- /**
13
- * get sidebar header items from page headers
14
- *
15
- * @param headers page headers
16
- * @returns sidebar header items
17
- */
18
- export declare const resolveSidebarPageHeaders: (headers?: PageHeader[]) => SidebarHeaderItem[];
19
- /**
20
- * Resolve current page and its header to sidebar items if the config is `heading`
21
- *
22
- * @param page current page data
23
- * @param headers current page headers
24
- *
25
- * @returns sidebar items
26
- */
27
- export declare const resolveSidebarHeadingItem: (page: PageData, headers: PageHeader[]) => SidebarItem[];
28
- /**
29
- * Resolve sidebar items if the config is an array
30
- *
31
- * @param sidebarConfig sidebar config array
32
- * @param headers current page headers
33
- * @param path current page path
34
- * @param prefix path prefix
35
- *
36
- * @returns resolved sidebar items
37
- */
38
- export declare const resolveArraySidebarItems: (sidebarConfig: SidebarArrayOptions, headers: PageHeader[], path: string, prefix?: string) => SidebarItem[];
39
- /**
40
- * Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
41
- *
42
- * @param sidebarConfig sidebar config object
43
- * @param page current page data
44
- * @param headers current page headers
45
- * @param path current page path
46
- *
47
- * @returns resolved sidebar items
48
- */
49
- export declare const resolveMultiSidebarItems: (sidebarConfig: SidebarObjectOptions, page: PageData, headers: PageHeader[], path: string) => SidebarItem[];
50
- export type SidebarItemsRef = ComputedRef<SidebarItem[]>;
51
- export declare const sidebarItemsSymbol: InjectionKey<SidebarItemsRef>;
52
- /**
53
- * Inject sidebar items global computed
54
- *
55
- * @returns sidebar items global computed
56
- */
57
- export declare const useSidebarItems: () => SidebarItemsRef;
58
- /**
59
- * Resolve sidebar items global computed
60
- *
61
- * It should only be resolved and provided once
62
- *
63
- * @param sidebarConfig sidebar config
64
- * @param page current page data
65
- * @param path current page path
66
- * @param routeLocale current route locale
67
- * @param headers current page headers
68
- *
69
- * @returns resolved sidebar items
70
- */
71
- export declare const resolveSidebarItems: (sidebarConfig: SidebarOptions | false, page: PageData, path: string, routeLocale: string, headers: PageHeader[]) => SidebarItem[];
72
- /**
73
- * Create sidebar items ref and provide as global computed in setup
74
- */
75
- export declare const setupSidebarItems: () => void;
@@ -1,164 +0,0 @@
1
- import { resolveAutoLink } from '@theme/resolveAutoLink';
2
- import { resolvePrefix } from '@theme/resolvePrefix';
3
- import { useData } from '@theme/useData';
4
- import { useHeaders } from '@theme/useHeaders';
5
- import { isLinkRelative, keys, startsWith } from '@vuepress/helper/client';
6
- import { computed, inject, provide } from 'vue';
7
- import { useRoutePath } from 'vuepress/client';
8
- import { isPlainObject, isString } from 'vuepress/shared';
9
- /**
10
- * Util to transform page header to sidebar item
11
- *
12
- * @param header page header
13
- * @returns sidebar item from header
14
- */
15
- export const resolveSidebarPageHeader = (header) => ({
16
- text: header.title,
17
- link: header.link,
18
- children: resolveSidebarPageHeaders(header.children),
19
- });
20
- /**
21
- * get sidebar header items from page headers
22
- *
23
- * @param headers page headers
24
- * @returns sidebar header items
25
- */
26
- export const resolveSidebarPageHeaders = (headers) => headers ? headers.map((header) => resolveSidebarPageHeader(header)) : [];
27
- /**
28
- * Resolve current page and its header to sidebar items if the config is `heading`
29
- *
30
- * @param page current page data
31
- * @param headers current page headers
32
- *
33
- * @returns sidebar items
34
- */
35
- export const resolveSidebarHeadingItem = (page, headers) => [
36
- {
37
- text: page.title,
38
- children: resolveSidebarPageHeaders(headers),
39
- },
40
- ];
41
- /**
42
- * Resolve sidebar items if the config is an array
43
- *
44
- * @param sidebarConfig sidebar config array
45
- * @param headers current page headers
46
- * @param path current page path
47
- * @param prefix path prefix
48
- *
49
- * @returns resolved sidebar items
50
- */
51
- export const resolveArraySidebarItems = (sidebarConfig, headers, path, prefix = '') => {
52
- const handleChildItem = (item, pathPrefix) => {
53
- const childItem = isString(item)
54
- ? resolveAutoLink(resolvePrefix(pathPrefix, item))
55
- : isString(item.link)
56
- ? {
57
- ...item,
58
- link: isLinkRelative(item.link)
59
- ? resolveAutoLink(resolvePrefix(pathPrefix, item.link)).link
60
- : item.link,
61
- }
62
- : item;
63
- if ('children' in childItem) {
64
- return {
65
- ...childItem,
66
- children: childItem.children.map((child) => handleChildItem(child, resolvePrefix(pathPrefix, childItem.prefix))),
67
- };
68
- }
69
- // if the sidebar item is current page and children is not set
70
- // use headers of current page as children
71
- if (childItem.link === path) {
72
- // skip h1 header
73
- const currentHeaders = headers[0]?.level === 1 ? headers[0].children : headers;
74
- return {
75
- ...childItem,
76
- children: resolveSidebarPageHeaders(currentHeaders),
77
- };
78
- }
79
- return childItem;
80
- };
81
- return sidebarConfig.map((item) => handleChildItem(item, prefix));
82
- };
83
- /**
84
- * Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
85
- *
86
- * @param sidebarConfig sidebar config object
87
- * @param page current page data
88
- * @param headers current page headers
89
- * @param path current page path
90
- *
91
- * @returns resolved sidebar items
92
- */
93
- export const resolveMultiSidebarItems = (sidebarConfig, page, headers, path) => {
94
- const sidebarRoutes = keys(sidebarConfig).sort((a, b) => b.length - a.length);
95
- // Find matching config
96
- for (const base of sidebarRoutes)
97
- if (startsWith(decodeURI(path), base)) {
98
- const matched = sidebarConfig[base];
99
- return matched === false
100
- ? []
101
- : matched === 'heading'
102
- ? resolveSidebarHeadingItem(page, headers)
103
- : resolveArraySidebarItems(matched, headers, path, base);
104
- }
105
- // eslint-disable-next-line no-console
106
- console.warn(`${decodeURI(path)} is missing sidebar config.`);
107
- return [];
108
- };
109
- export const sidebarItemsSymbol = Symbol('sidebarItems');
110
- /**
111
- * Inject sidebar items global computed
112
- *
113
- * @returns sidebar items global computed
114
- */
115
- export const useSidebarItems = () => {
116
- const sidebarItems = inject(sidebarItemsSymbol);
117
- if (!sidebarItems) {
118
- throw new Error('useSidebarItems() is called without provider.');
119
- }
120
- return sidebarItems;
121
- };
122
- /**
123
- * Resolve sidebar items global computed
124
- *
125
- * It should only be resolved and provided once
126
- *
127
- * @param sidebarConfig sidebar config
128
- * @param page current page data
129
- * @param path current page path
130
- * @param routeLocale current route locale
131
- * @param headers current page headers
132
- *
133
- * @returns resolved sidebar items
134
- */
135
- export const resolveSidebarItems = (sidebarConfig, page, path, routeLocale, headers) => {
136
- // resolve sidebar items according to the config
137
- if (sidebarConfig === false) {
138
- return [];
139
- }
140
- if (sidebarConfig === 'heading') {
141
- return resolveSidebarHeadingItem(page, headers);
142
- }
143
- if (Array.isArray(sidebarConfig)) {
144
- return resolveArraySidebarItems(sidebarConfig, headers, path, routeLocale);
145
- }
146
- if (isPlainObject(sidebarConfig)) {
147
- return resolveMultiSidebarItems(sidebarConfig, page, headers, path);
148
- }
149
- return [];
150
- };
151
- /**
152
- * Create sidebar items ref and provide as global computed in setup
153
- */
154
- export const setupSidebarItems = () => {
155
- const { frontmatter, page, routeLocale, themeLocale } = useData();
156
- const headers = useHeaders();
157
- const routePath = useRoutePath();
158
- const sidebarConfig = computed(() => !frontmatter.value.home &&
159
- (frontmatter.value.sidebar ??
160
- themeLocale.value.sidebar ??
161
- 'heading'));
162
- const sidebarItems = computed(() => resolveSidebarItems(sidebarConfig.value, page.value, routePath.value, routeLocale.value, headers.value));
163
- provide(sidebarItemsSymbol, sidebarItems);
164
- };
@@ -1,10 +0,0 @@
1
- export declare enum DeviceType {
2
- Mobile = "mobile"
3
- }
4
- /**
5
- * add listener to detect screen though device type
6
- *
7
- * @param deviceType - Device type to detect / 要检测的设备类型
8
- * @param callback - Callback function to call when device status changes / 设备状态改变时调用的回调函数
9
- */
10
- export declare const useUpdateDeviceStatus: (deviceType: DeviceType, callback: (width: number) => void) => void;
@@ -1,34 +0,0 @@
1
- // oxlint-disable promise/prefer-await-to-callbacks
2
- import { useEventListener } from '@vueuse/core';
3
- import { onMounted } from 'vue';
4
- import cssVariables from '../styles/_variables.module.scss';
5
- export var DeviceType;
6
- (function (DeviceType) {
7
- DeviceType["Mobile"] = "mobile";
8
- })(DeviceType || (DeviceType = {}));
9
- const DeviceTypeMap = {
10
- [DeviceType.Mobile]: Number.parseInt(cssVariables.mobile.replace('px', ''), 10),
11
- };
12
- /**
13
- * add listener to detect screen though device type
14
- *
15
- * @param deviceType - Device type to detect / 要检测的设备类型
16
- * @param callback - Callback function to call when device status changes / 设备状态改变时调用的回调函数
17
- */
18
- export const useUpdateDeviceStatus = (deviceType, callback) => {
19
- const width = DeviceTypeMap[deviceType];
20
- if (!Number.isInteger(width)) {
21
- if (__VUEPRESS_DEV__)
22
- throw new Error('device width must be a integer');
23
- return;
24
- }
25
- useEventListener('orientationchange', () => {
26
- callback(width);
27
- });
28
- useEventListener('resize', () => {
29
- callback(width);
30
- });
31
- onMounted(() => {
32
- callback(width);
33
- });
34
- };
@@ -1,5 +0,0 @@
1
- import '@vuepress/helper/colors.css';
2
- import '@vuepress/helper/normalize.css';
3
- import './styles/index.scss';
4
- declare const _default: import("vuepress/client").ClientConfig;
5
- export default _default;
@@ -1,35 +0,0 @@
1
- import { setupDarkMode } from '@theme/useDarkMode';
2
- import { setupHeaders } from '@theme/useHeaders';
3
- import { useScrollPromise } from '@theme/useScrollPromise';
4
- import { setupSidebarItems } from '@theme/useSidebarItems';
5
- import { hasGlobalComponent } from '@vuepress/helper/client';
6
- import { defineClientConfig } from 'vuepress/client';
7
- import { Badge } from './components/global/index.js';
8
- import Layout from './layouts/Layout.vue';
9
- import NotFound from './layouts/NotFound.vue';
10
- import '@vuepress/helper/colors.css';
11
- import '@vuepress/helper/normalize.css';
12
- import './styles/index.scss';
13
- export default defineClientConfig({
14
- enhance({ app, router }) {
15
- if (!hasGlobalComponent('Badge'))
16
- app.component('Badge', Badge);
17
- // handle scrollBehavior with transition
18
- const scrollBehavior = router.options.scrollBehavior;
19
- // scrollBehavior is a bit hard to typed here
20
- // oxlint-disable-next-line typescript/explicit-function-return-type
21
- router.options.scrollBehavior = async (...args) => {
22
- await useScrollPromise().wait();
23
- return scrollBehavior(...args);
24
- };
25
- },
26
- setup() {
27
- setupDarkMode();
28
- setupHeaders();
29
- setupSidebarItems();
30
- },
31
- layouts: {
32
- Layout,
33
- NotFound,
34
- },
35
- });
@@ -1,4 +0,0 @@
1
- export * from './composables/index.js';
2
- export type * from './typings.js';
3
- export * from './utils/index.js';
4
- export type * from '../shared/index.js';
@@ -1,2 +0,0 @@
1
- export * from './composables/index.js';
2
- export * from './utils/index.js';
@@ -1,13 +0,0 @@
1
- import type { AutoLinkOptions, NavGroup, SidebarGroupOptions, SidebarLinkOptions } from '../shared/index.js';
2
- export type NavbarItem = AutoLinkOptions | NavGroup<NavbarItem>;
3
- export type SidebarLinkItem = SidebarLinkOptions;
4
- export interface SidebarHeaderItem {
5
- text: string;
6
- link: string;
7
- children?: SidebarHeaderItem[];
8
- }
9
- export interface SidebarGroupItem extends SidebarGroupOptions {
10
- prefix?: string;
11
- children: (SidebarHeaderItem | SidebarItem)[];
12
- }
13
- export type SidebarItem = SidebarGroupItem | SidebarLinkItem;
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- export * from './isActiveSidebarItem.js';
2
- export * from './resolveAutoLink.js';
3
- export * from './resolveEditLink.js';
4
- export * from './resolvePrefix.js';
5
- export * from './resolveRepoType.js';
@@ -1,5 +0,0 @@
1
- export * from './isActiveSidebarItem.js';
2
- export * from './resolveAutoLink.js';
3
- export * from './resolveEditLink.js';
4
- export * from './resolvePrefix.js';
5
- export * from './resolveRepoType.js';
@@ -1,3 +0,0 @@
1
- import type { RouteLocationNormalizedLoaded } from 'vuepress/client';
2
- import type { SidebarItem } from '../typings.js';
3
- export declare const isActiveSidebarItem: (item: SidebarItem, route: RouteLocationNormalizedLoaded) => boolean;
@@ -1,20 +0,0 @@
1
- const normalizePath = (path) => decodeURI(path)
2
- .replace(/#.*$/, '')
3
- .replace(/(index)?\.(md|html)$/, '');
4
- const isActiveLink = (link, route) => {
5
- if (route.hash === link) {
6
- return true;
7
- }
8
- const currentPath = normalizePath(route.path);
9
- const targetPath = normalizePath(link);
10
- return currentPath === targetPath;
11
- };
12
- export const isActiveSidebarItem = (item, route) => {
13
- if (item.link && isActiveLink(item.link, route)) {
14
- return true;
15
- }
16
- if ('children' in item) {
17
- return item.children.some((child) => isActiveSidebarItem(child, route));
18
- }
19
- return false;
20
- };
@@ -1,23 +0,0 @@
1
- import { resolveRoute } from 'vuepress/client';
2
- /**
3
- * Resolve AutoLink props from string
4
- *
5
- * 从字符串解析 AutoLink 属性
6
- *
7
- * @param config - The string to resolve / 要解析的字符串
8
- * @param currentPath - The current route path / 当前路由路径
9
- * @returns Resolved AutoLink options / 解析后的 AutoLink 选项
10
- *
11
- * @example
12
- * - Input: '/README.md'
13
- * - Output: { text: 'Home', link: '/' }
14
- */
15
- export const resolveAutoLink = (config, currentPath) => {
16
- const { notFound, meta, path } = resolveRoute(config, currentPath);
17
- return notFound
18
- ? { text: path, link: path }
19
- : {
20
- text: meta.title || path,
21
- link: path,
22
- };
23
- };
@@ -1,9 +0,0 @@
1
- import type { RepoType } from '@theme/resolveRepoType';
2
- export declare const EDIT_LINK_PATTERNS: Record<Exclude<RepoType, null>, string>;
3
- export declare const resolveEditLink: ({ docsRepo, docsBranch, docsDir, filePathRelative, editLinkPattern, }: {
4
- docsRepo: string;
5
- docsBranch: string;
6
- docsDir: string;
7
- filePathRelative: string | null;
8
- editLinkPattern?: string;
9
- }) => string | null;
@@ -1,29 +0,0 @@
1
- import { resolveRepoType } from '@theme/resolveRepoType';
2
- import { isLinkHttp, removeEndingSlash, removeLeadingSlash, } from 'vuepress/shared';
3
- export const EDIT_LINK_PATTERNS = {
4
- GitHub: ':repo/edit/:branch/:path',
5
- GitLab: ':repo/-/edit/:branch/:path',
6
- Gitee: ':repo/edit/:branch/:path',
7
- Bitbucket: ':repo/src/:branch/:path?mode=edit&spa=0&at=:branch&fileviewer=file-view-default',
8
- };
9
- const resolveEditLinkPatterns = ({ docsRepo, editLinkPattern, }) => {
10
- if (editLinkPattern) {
11
- return editLinkPattern;
12
- }
13
- const repoType = resolveRepoType(docsRepo);
14
- if (repoType != null) {
15
- return EDIT_LINK_PATTERNS[repoType];
16
- }
17
- return null;
18
- };
19
- export const resolveEditLink = ({ docsRepo, docsBranch, docsDir, filePathRelative, editLinkPattern, }) => {
20
- if (!filePathRelative)
21
- return null;
22
- const pattern = resolveEditLinkPatterns({ docsRepo, editLinkPattern });
23
- if (!pattern)
24
- return null;
25
- return pattern
26
- .replace(/:repo/, isLinkHttp(docsRepo) ? docsRepo : `https://github.com/${docsRepo}`)
27
- .replace(/:branch/, docsBranch)
28
- .replace(/:path/, removeLeadingSlash(`${removeEndingSlash(docsDir)}/${filePathRelative}`));
29
- };
@@ -1 +0,0 @@
1
- export declare const resolvePrefix: (prefix?: string, path?: string) => string;
@@ -1,4 +0,0 @@
1
- import { ensureEndingSlash, isLinkAbsolute, isLinkWithProtocol, } from '@vuepress/helper/client';
2
- export const resolvePrefix = (prefix = '', path = '') => isLinkAbsolute(path) || isLinkWithProtocol(path)
3
- ? path
4
- : `${ensureEndingSlash(prefix)}${path}`;
@@ -1,2 +0,0 @@
1
- export type RepoType = 'Bitbucket' | 'Gitee' | 'GitHub' | 'GitLab' | null;
2
- export declare const resolveRepoType: (repo: string) => RepoType;
@@ -1,12 +0,0 @@
1
- import { isLinkHttp } from 'vuepress/shared';
2
- export const resolveRepoType = (repo) => {
3
- if (!isLinkHttp(repo) || repo.includes('github.com'))
4
- return 'GitHub';
5
- if (repo.includes('bitbucket.org'))
6
- return 'Bitbucket';
7
- if (repo.includes('gitlab.com'))
8
- return 'GitLab';
9
- if (repo.includes('gitee.com'))
10
- return 'Gitee';
11
- return null;
12
- };
@@ -1,15 +0,0 @@
1
- import type { Theme } from 'vuepress/core';
2
- import type { DefaultThemeLocaleOptions } from '../shared/index.js';
3
- import type { DefaultThemePluginsOptions } from './typings.js';
4
- export interface DefaultThemeOptions extends DefaultThemeLocaleOptions {
5
- /**
6
- * deployed hostname
7
- */
8
- hostname?: string;
9
- /**
10
- * To avoid confusion with the root `plugins` option,
11
- * we use `themePlugins`
12
- */
13
- themePlugins?: DefaultThemePluginsOptions;
14
- }
15
- export declare const defaultTheme: ({ hostname, themePlugins, ...localeOptions }?: DefaultThemeOptions) => Theme;