@vuepress/theme-default 2.0.0-beta.9 → 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 (118) hide show
  1. package/LICENSE +1 -1
  2. package/lib/client/components/AutoLink.vue +113 -0
  3. package/lib/client/components/DropdownTransition.vue +15 -24
  4. package/lib/client/components/Home.vue +12 -130
  5. package/lib/client/components/HomeContent.vue +5 -0
  6. package/lib/client/components/HomeFeatures.vue +22 -0
  7. package/lib/client/components/HomeFooter.vue +17 -0
  8. package/lib/client/components/HomeHero.vue +97 -0
  9. package/lib/client/components/Navbar.vue +60 -95
  10. package/lib/client/components/NavbarBrand.vue +55 -0
  11. package/lib/client/components/NavbarDropdown.vue +126 -0
  12. package/lib/client/components/{NavbarLinks.vue → NavbarItems.vue} +81 -61
  13. package/lib/client/components/Page.vue +16 -15
  14. package/lib/client/components/PageMeta.vue +51 -66
  15. package/lib/client/components/PageNav.vue +61 -64
  16. package/lib/client/components/Sidebar.vue +12 -32
  17. package/lib/client/components/SidebarItem.vue +87 -0
  18. package/lib/client/components/SidebarItems.vue +57 -0
  19. package/lib/client/components/ToggleColorModeButton.vue +57 -0
  20. package/lib/client/components/ToggleSidebarButton.vue +21 -24
  21. package/lib/client/components/global/Badge.vue +24 -26
  22. package/lib/client/components/global/CodeGroup.d.ts +5 -4
  23. package/lib/client/components/global/CodeGroup.js +85 -17
  24. package/lib/client/components/global/CodeGroupItem.vue +22 -20
  25. package/lib/client/components/global/index.d.ts +4 -0
  26. package/lib/client/components/global/index.js +4 -0
  27. package/lib/client/composables/index.d.ts +5 -5
  28. package/lib/client/composables/index.js +5 -5
  29. package/lib/client/composables/useDarkMode.d.ts +12 -0
  30. package/lib/client/composables/useDarkMode.js +57 -0
  31. package/lib/client/composables/useScrollPromise.js +1 -1
  32. package/lib/client/composables/useSidebarItems.d.ts +14 -8
  33. package/lib/client/composables/useSidebarItems.js +49 -48
  34. package/lib/client/composables/useThemeData.d.ts +2 -2
  35. package/lib/client/composables/useThemeData.js +1 -1
  36. package/lib/client/composables/useUpdateDeviceStatus.d.ts +7 -0
  37. package/lib/client/composables/useUpdateDeviceStatus.js +25 -0
  38. package/lib/client/config.d.ts +4 -0
  39. package/lib/client/config.js +44 -0
  40. package/lib/client/index.d.ts +3 -4
  41. package/lib/client/index.js +3 -2
  42. package/lib/client/layouts/Layout.vue +133 -136
  43. package/lib/client/layouts/NotFound.vue +27 -0
  44. package/lib/client/shim.d.ts +5 -0
  45. package/lib/client/styles/{_wrapper.scss → _mixins.scss} +7 -2
  46. package/lib/client/styles/_variables.module.scss +5 -0
  47. package/lib/client/styles/_variables.scss +0 -34
  48. package/lib/client/styles/arrow.scss +4 -6
  49. package/lib/client/styles/badge.scss +14 -11
  50. package/lib/client/styles/code-group.scss +10 -10
  51. package/lib/client/styles/code.scss +33 -46
  52. package/lib/client/styles/custom-container.scss +82 -18
  53. package/lib/client/styles/home.scss +32 -24
  54. package/lib/client/styles/index.scss +4 -4
  55. package/lib/client/styles/layout.scss +82 -73
  56. package/lib/client/styles/{dropdown.scss → navbar-dropdown.scss} +36 -50
  57. package/lib/client/styles/navbar.scss +106 -50
  58. package/lib/client/styles/normalize.scss +199 -0
  59. package/lib/client/styles/page.scss +24 -8
  60. package/lib/client/styles/sidebar.scss +69 -87
  61. package/lib/client/styles/transitions.scss +13 -4
  62. package/lib/client/styles/vars-dark.scss +68 -0
  63. package/lib/client/styles/vars.scss +155 -0
  64. package/lib/client/utils/getNavLink.d.ts +15 -0
  65. package/lib/client/utils/getNavLink.js +18 -0
  66. package/lib/client/utils/getResolveRouteWithRedirect.d.ts +5 -0
  67. package/lib/client/{composables/useResolveRouteWithRedirect.js → utils/getResolveRouteWithRedirect.js} +4 -6
  68. package/lib/client/utils/index.d.ts +5 -2
  69. package/lib/client/utils/index.js +5 -2
  70. package/lib/client/utils/isActiveSidebarItem.d.ts +3 -0
  71. package/lib/client/utils/isActiveSidebarItem.js +20 -0
  72. package/lib/client/utils/resolveEditLink.d.ts +2 -2
  73. package/lib/client/utils/resolveEditLink.js +15 -9
  74. package/lib/client/utils/resolveRepoType.d.ts +1 -1
  75. package/lib/client/utils/resolveRepoType.js +4 -2
  76. package/lib/node/defaultTheme.d.ts +4 -4
  77. package/lib/node/defaultTheme.js +111 -48
  78. package/lib/node/index.d.ts +4 -4
  79. package/lib/node/index.js +5 -17
  80. package/lib/node/utils/assignDefaultLocaleOptions.d.ts +4 -2
  81. package/lib/node/utils/assignDefaultLocaleOptions.js +13 -13
  82. package/lib/node/utils/index.d.ts +2 -5
  83. package/lib/node/utils/index.js +2 -17
  84. package/lib/node/utils/resolveContainerPluginOptions.d.ts +2 -20
  85. package/lib/node/utils/resolveContainerPluginOptions.js +4 -66
  86. package/lib/shared/index.d.ts +3 -3
  87. package/lib/shared/index.js +3 -15
  88. package/lib/shared/nav.d.ts +16 -18
  89. package/lib/shared/nav.js +1 -2
  90. package/lib/shared/options.d.ts +51 -6
  91. package/lib/shared/options.js +1 -2
  92. package/lib/shared/page.d.ts +15 -6
  93. package/lib/shared/page.js +1 -2
  94. package/package.json +43 -25
  95. package/templates/build.html +34 -0
  96. package/CHANGELOG.md +0 -419
  97. package/lib/client/clientAppEnhance.d.ts +0 -3
  98. package/lib/client/clientAppEnhance.js +0 -28
  99. package/lib/client/clientAppSetup.d.ts +0 -2
  100. package/lib/client/clientAppSetup.js +0 -11
  101. package/lib/client/components/DropdownLink.vue +0 -141
  102. package/lib/client/components/NavLink.vue +0 -115
  103. package/lib/client/components/SidebarChild.d.ts +0 -6
  104. package/lib/client/components/SidebarChild.js +0 -91
  105. package/lib/client/components/global/OutboundLink.vue +0 -30
  106. package/lib/client/composables/useNavLink.d.ts +0 -9
  107. package/lib/client/composables/useNavLink.js +0 -15
  108. package/lib/client/composables/useResolveRouteWithRedirect.d.ts +0 -5
  109. package/lib/client/layouts/404.vue +0 -38
  110. package/lib/client/styles/_normalize.scss +0 -148
  111. package/lib/client/styles/plugins.scss +0 -18
  112. package/lib/client/styles/sr-only.scss +0 -12
  113. package/lib/node/utils/resolveActiveHeaderLinksPluginOptions.d.ts +0 -6
  114. package/lib/node/utils/resolveActiveHeaderLinksPluginOptions.js +0 -16
  115. package/lib/node/utils/resolveGitPluginOptions.d.ts +0 -6
  116. package/lib/node/utils/resolveGitPluginOptions.js +0 -22
  117. package/lib/node/utils/resolveMediumZoomPluginOptions.d.ts +0 -6
  118. package/lib/node/utils/resolveMediumZoomPluginOptions.js +0 -17
@@ -1,25 +1,27 @@
1
- <template>
2
- <div class="code-group-item" :class="{ 'code-group-item__active': active }">
3
- <slot />
4
- </div>
5
- </template>
6
-
7
- <script>
8
- import { defineComponent } from 'vue'
9
-
10
- export default defineComponent({
1
+ <script setup lang="ts">
2
+ defineOptions({
11
3
  name: 'CodeGroupItem',
4
+ })
12
5
 
13
- props: {
14
- title: {
15
- type: String,
16
- required: true,
17
- },
18
- active: {
19
- type: Boolean,
20
- required: false,
21
- default: false,
22
- },
6
+ defineProps({
7
+ title: {
8
+ type: String,
9
+ required: true,
10
+ },
11
+ active: {
12
+ type: Boolean,
13
+ required: false,
14
+ default: false,
23
15
  },
24
16
  })
25
17
  </script>
18
+
19
+ <template>
20
+ <div
21
+ class="code-group-item"
22
+ :class="{ 'code-group-item__active': active }"
23
+ role="tabpanel"
24
+ >
25
+ <slot />
26
+ </div>
27
+ </template>
@@ -0,0 +1,4 @@
1
+ import Badge from './Badge.vue';
2
+ import { CodeGroup } from './CodeGroup.js';
3
+ import CodeGroupItem from './CodeGroupItem.vue';
4
+ export { Badge, CodeGroup, CodeGroupItem };
@@ -0,0 +1,4 @@
1
+ import Badge from './Badge.vue';
2
+ import { CodeGroup } from './CodeGroup.js';
3
+ import CodeGroupItem from './CodeGroupItem.vue';
4
+ export { Badge, CodeGroup, CodeGroupItem };
@@ -1,5 +1,5 @@
1
- export * from './useNavLink';
2
- export * from './useResolveRouteWithRedirect';
3
- export * from './useScrollPromise';
4
- export * from './useSidebarItems';
5
- export * from './useThemeData';
1
+ export * from './useDarkMode.js';
2
+ export * from './useScrollPromise.js';
3
+ export * from './useSidebarItems.js';
4
+ export * from './useThemeData.js';
5
+ export * from './useUpdateDeviceStatus.js';
@@ -1,5 +1,5 @@
1
- export * from './useNavLink';
2
- export * from './useResolveRouteWithRedirect';
3
- export * from './useScrollPromise';
4
- export * from './useSidebarItems';
5
- export * from './useThemeData';
1
+ export * from './useDarkMode.js';
2
+ export * from './useScrollPromise.js';
3
+ export * from './useSidebarItems.js';
4
+ export * from './useThemeData.js';
5
+ export * from './useUpdateDeviceStatus.js';
@@ -0,0 +1,12 @@
1
+ import type { InjectionKey, WritableComputedRef } from 'vue';
2
+ export type DarkModeRef = WritableComputedRef<boolean>;
3
+ export declare const darkModeSymbol: InjectionKey<DarkModeRef>;
4
+ /**
5
+ * Inject dark mode global computed
6
+ */
7
+ export declare const useDarkMode: () => DarkModeRef;
8
+ /**
9
+ * Create dark mode ref and provide as global computed in setup
10
+ */
11
+ export declare const setupDarkMode: () => void;
12
+ export declare const updateHtmlDarkClass: (isDarkMode: DarkModeRef) => void;
@@ -0,0 +1,57 @@
1
+ import { usePreferredDark, useStorage } from '@vueuse/core';
2
+ import { computed, inject, onMounted, onUnmounted, provide, watch } from 'vue';
3
+ import { useThemeLocaleData } from './useThemeData.js';
4
+ export const darkModeSymbol = Symbol(__VUEPRESS_DEV__ ? 'darkMode' : '');
5
+ /**
6
+ * Inject dark mode global computed
7
+ */
8
+ export const useDarkMode = () => {
9
+ const isDarkMode = inject(darkModeSymbol);
10
+ if (!isDarkMode) {
11
+ throw new Error('useDarkMode() is called without provider.');
12
+ }
13
+ return isDarkMode;
14
+ };
15
+ /**
16
+ * Create dark mode ref and provide as global computed in setup
17
+ */
18
+ export const setupDarkMode = () => {
19
+ const themeLocale = useThemeLocaleData();
20
+ const isDarkPreferred = usePreferredDark();
21
+ const darkStorage = useStorage('vuepress-color-scheme', themeLocale.value.colorMode);
22
+ const isDarkMode = computed({
23
+ get() {
24
+ // disable color mode switching
25
+ if (!themeLocale.value.colorModeSwitch) {
26
+ return themeLocale.value.colorMode === 'dark';
27
+ }
28
+ // auto detected from prefers-color-scheme
29
+ if (darkStorage.value === 'auto') {
30
+ return isDarkPreferred.value;
31
+ }
32
+ // storage value
33
+ return darkStorage.value === 'dark';
34
+ },
35
+ set(val) {
36
+ if (val === isDarkPreferred.value) {
37
+ darkStorage.value = 'auto';
38
+ }
39
+ else {
40
+ darkStorage.value = val ? 'dark' : 'light';
41
+ }
42
+ },
43
+ });
44
+ provide(darkModeSymbol, isDarkMode);
45
+ updateHtmlDarkClass(isDarkMode);
46
+ };
47
+ export const updateHtmlDarkClass = (isDarkMode) => {
48
+ const update = (value = isDarkMode.value) => {
49
+ // set `class="dark"` on `<html>` element
50
+ const htmlEl = window?.document.querySelector('html');
51
+ htmlEl?.classList.toggle('dark', value);
52
+ };
53
+ onMounted(() => {
54
+ watch(isDarkMode, update, { immediate: true });
55
+ });
56
+ onUnmounted(() => update());
57
+ };
@@ -6,7 +6,7 @@ const scrollPromise = {
6
6
  promise = new Promise((resolve) => (promiseResolve = resolve));
7
7
  },
8
8
  resolve: () => {
9
- promiseResolve === null || promiseResolve === void 0 ? void 0 : promiseResolve();
9
+ promiseResolve?.();
10
10
  promise = null;
11
11
  promiseResolve = null;
12
12
  },
@@ -1,31 +1,37 @@
1
1
  import type { ComputedRef, InjectionKey } from 'vue';
2
- import type { PageHeader } from '@vuepress/client';
3
- import type { DefaultThemeData, DefaultThemePageFrontmatter, SidebarConfigArray, SidebarConfigObject, ResolvedSidebarItem } from '../../shared';
4
- export declare type SidebarItemsRef = ComputedRef<ResolvedSidebarItem[]>;
2
+ import type { Router } from 'vue-router';
3
+ import type { PageData, PageHeader } from 'vuepress/client';
4
+ import type { DefaultThemeData, DefaultThemeNormalPageFrontmatter, ResolvedSidebarItem, SidebarConfigArray, SidebarConfigObject } from '../../shared/index.js';
5
+ export type SidebarItemsRef = ComputedRef<ResolvedSidebarItem[]>;
5
6
  export declare const sidebarItemsSymbol: InjectionKey<SidebarItemsRef>;
6
7
  /**
7
8
  * Inject sidebar items global computed
8
9
  */
9
10
  export declare const useSidebarItems: () => SidebarItemsRef;
11
+ /**
12
+ * Create sidebar items ref and provide as global computed in setup
13
+ */
14
+ export declare const setupSidebarItems: () => void;
10
15
  /**
11
16
  * Resolve sidebar items global computed
12
17
  *
13
18
  * It should only be resolved and provided once
14
19
  */
15
- export declare const resolveSidebarItems: (frontmatter: DefaultThemePageFrontmatter, themeLocale: DefaultThemeData) => ResolvedSidebarItem[];
20
+ export declare const resolveSidebarItems: (frontmatter: DefaultThemeNormalPageFrontmatter, themeLocale: DefaultThemeData, page: PageData, router: Router, path: string) => ResolvedSidebarItem[];
16
21
  /**
17
22
  * Util to transform page header to sidebar item
18
23
  */
19
- export declare const headerToSidebarItem: (header: PageHeader) => ResolvedSidebarItem;
24
+ export declare const headerToSidebarItem: (header: PageHeader, sidebarDepth: number) => ResolvedSidebarItem;
25
+ export declare const headersToSidebarItemChildren: (headers: PageHeader[], sidebarDepth: number) => ResolvedSidebarItem[];
20
26
  /**
21
27
  * Resolve sidebar items if the config is `auto`
22
28
  */
23
- export declare const resolveAutoSidebarItems: () => ResolvedSidebarItem[];
29
+ export declare const resolveAutoSidebarItems: (page: PageData, sidebarDepth: number) => ResolvedSidebarItem[];
24
30
  /**
25
31
  * Resolve sidebar items if the config is an array
26
32
  */
27
- export declare const resolveArraySidebarItems: (sidebarConfig: SidebarConfigArray) => ResolvedSidebarItem[];
33
+ export declare const resolveArraySidebarItems: (page: PageData, router: Router, path: string, sidebarConfig: SidebarConfigArray, sidebarDepth: number) => ResolvedSidebarItem[];
28
34
  /**
29
35
  * Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
30
36
  */
31
- export declare const resolveMultiSidebarItems: (sidebarConfig: SidebarConfigObject) => ResolvedSidebarItem[];
37
+ export declare const resolveMultiSidebarItems: (page: PageData, router: Router, path: string, sidebarConfig: SidebarConfigObject, sidebarDepth: number) => ResolvedSidebarItem[];
@@ -1,8 +1,9 @@
1
- import { inject } from 'vue';
2
- import { useRoute } from 'vue-router';
3
- import { usePageData } from '@vuepress/client';
4
- import { isArray, isPlainObject, isString, resolveLocalePath, } from '@vuepress/shared';
5
- import { useNavLink } from './useNavLink';
1
+ import { computed, inject, provide } from 'vue';
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
+ import { useThemeLocaleData } from './useThemeData.js';
6
7
  export const sidebarItemsSymbol = Symbol('sidebarItems');
7
8
  /**
8
9
  * Inject sidebar items global computed
@@ -14,101 +15,101 @@ export const useSidebarItems = () => {
14
15
  }
15
16
  return sidebarItems;
16
17
  };
18
+ /**
19
+ * Create sidebar items ref and provide as global computed in setup
20
+ */
21
+ export const setupSidebarItems = () => {
22
+ const themeLocale = useThemeLocaleData();
23
+ const frontmatter = usePageFrontmatter();
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));
28
+ provide(sidebarItemsSymbol, sidebarItems);
29
+ };
17
30
  /**
18
31
  * Resolve sidebar items global computed
19
32
  *
20
33
  * It should only be resolved and provided once
21
34
  */
22
- export const resolveSidebarItems = (frontmatter, themeLocale) => {
23
- var _a, _b;
24
- // get sidebar config from frontmatter > themeConfig
25
- const sidebarConfig = (_b = (_a = frontmatter.sidebar) !== null && _a !== void 0 ? _a : themeLocale.sidebar) !== null && _b !== void 0 ? _b : 'auto';
35
+ export const resolveSidebarItems = (frontmatter, themeLocale, page, router, path) => {
36
+ // get sidebar config from frontmatter > theme data
37
+ const sidebarConfig = frontmatter.sidebar ?? themeLocale.sidebar ?? 'auto';
38
+ const sidebarDepth = frontmatter.sidebarDepth ?? themeLocale.sidebarDepth ?? 2;
26
39
  // resolve sidebar items according to the config
27
- if (frontmatter.home === true || sidebarConfig === false) {
40
+ if (frontmatter.home || sidebarConfig === false) {
28
41
  return [];
29
42
  }
30
43
  if (sidebarConfig === 'auto') {
31
- return resolveAutoSidebarItems();
44
+ return resolveAutoSidebarItems(page, sidebarDepth);
32
45
  }
33
- if (isArray(sidebarConfig)) {
34
- return resolveArraySidebarItems(sidebarConfig);
46
+ if (Array.isArray(sidebarConfig)) {
47
+ return resolveArraySidebarItems(page, router, path, sidebarConfig, sidebarDepth);
35
48
  }
36
49
  if (isPlainObject(sidebarConfig)) {
37
- return resolveMultiSidebarItems(sidebarConfig);
50
+ return resolveMultiSidebarItems(page, router, path, sidebarConfig, sidebarDepth);
38
51
  }
39
52
  return [];
40
53
  };
41
54
  /**
42
55
  * Util to transform page header to sidebar item
43
56
  */
44
- export const headerToSidebarItem = (header) => ({
57
+ export const headerToSidebarItem = (header, sidebarDepth) => ({
45
58
  text: header.title,
46
- link: `#${header.slug}`,
47
- children: header.children.map(headerToSidebarItem),
59
+ link: header.link,
60
+ children: headersToSidebarItemChildren(header.children, sidebarDepth),
48
61
  });
62
+ export const headersToSidebarItemChildren = (headers, sidebarDepth) => sidebarDepth > 0
63
+ ? headers.map((header) => headerToSidebarItem(header, sidebarDepth - 1))
64
+ : [];
49
65
  /**
50
66
  * Resolve sidebar items if the config is `auto`
51
67
  */
52
- export const resolveAutoSidebarItems = () => {
53
- const page = usePageData();
68
+ export const resolveAutoSidebarItems = (page, sidebarDepth) => {
54
69
  return [
55
70
  {
56
- isGroup: true,
57
- text: page.value.title,
58
- children: page.value.headers.map(headerToSidebarItem),
71
+ text: page.title,
72
+ children: headersToSidebarItemChildren(page.headers, sidebarDepth),
59
73
  },
60
74
  ];
61
75
  };
62
76
  /**
63
77
  * Resolve sidebar items if the config is an array
64
78
  */
65
- export const resolveArraySidebarItems = (sidebarConfig) => {
66
- const route = useRoute();
67
- const page = usePageData();
79
+ export const resolveArraySidebarItems = (page, router, path, sidebarConfig, sidebarDepth) => {
68
80
  const handleChildItem = (item) => {
69
81
  let childItem;
70
82
  if (isString(item)) {
71
- childItem = useNavLink(item);
83
+ childItem = getNavLink(router, item);
72
84
  }
73
85
  else {
74
86
  childItem = item;
75
87
  }
76
- if (childItem.isGroup && childItem.children) {
88
+ if (childItem.children) {
77
89
  return {
78
90
  ...childItem,
79
- children: childItem.children.map(handleChildItem),
91
+ children: childItem.children.map((item) => handleChildItem(item)),
80
92
  };
81
93
  }
82
94
  // if the sidebar item is current page and children is not set
83
95
  // use headers of current page as children
84
- if (childItem.link === route.path && childItem.children === undefined) {
96
+ if (childItem.link === path) {
97
+ // skip h1 header
98
+ const headers = page.headers[0]?.level === 1 ? page.headers[0].children : page.headers;
85
99
  return {
86
100
  ...childItem,
87
- children: page.value.headers.map(headerToSidebarItem),
101
+ children: headersToSidebarItemChildren(headers, sidebarDepth),
88
102
  };
89
103
  }
90
104
  return childItem;
91
105
  };
92
- return sidebarConfig.map((item) => {
93
- if (isString(item)) {
94
- return useNavLink(item);
95
- }
96
- if (!item.isGroup) {
97
- return item;
98
- }
99
- return {
100
- ...item,
101
- children: item.children.map(handleChildItem),
102
- };
103
- });
106
+ return sidebarConfig.map((item) => handleChildItem(item));
104
107
  };
105
108
  /**
106
109
  * Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
107
110
  */
108
- export const resolveMultiSidebarItems = (sidebarConfig) => {
109
- var _a;
110
- const route = useRoute();
111
- const sidebarPath = resolveLocalePath(sidebarConfig, route.path);
112
- const matchedSidebarConfig = (_a = sidebarConfig[sidebarPath]) !== null && _a !== void 0 ? _a : [];
113
- return resolveArraySidebarItems(matchedSidebarConfig);
111
+ export const resolveMultiSidebarItems = (page, router, path, sidebarConfig, sidebarDepth) => {
112
+ const sidebarPath = resolveLocalePath(sidebarConfig, path);
113
+ const matchedSidebarConfig = sidebarConfig[sidebarPath] ?? [];
114
+ return resolveArraySidebarItems(page, router, path, matchedSidebarConfig, sidebarDepth);
114
115
  };
@@ -1,4 +1,4 @@
1
- import type { ThemeDataRef, ThemeLocaleDataRef } from '@vuepress/plugin-theme-data/lib/client';
2
- import type { DefaultThemeData } from '../../shared';
1
+ import type { ThemeDataRef, ThemeLocaleDataRef } from '@vuepress/plugin-theme-data/client';
2
+ import type { DefaultThemeData } from '../../shared/index.js';
3
3
  export declare const useThemeData: () => ThemeDataRef<DefaultThemeData>;
4
4
  export declare const useThemeLocaleData: () => ThemeLocaleDataRef<DefaultThemeData>;
@@ -1,3 +1,3 @@
1
- import { useThemeData as _useThemeData, useThemeLocaleData as _useThemeLocaleData, } from '@vuepress/plugin-theme-data/lib/client';
1
+ import { useThemeData as _useThemeData, useThemeLocaleData as _useThemeLocaleData, } from '@vuepress/plugin-theme-data/client';
2
2
  export const useThemeData = () => _useThemeData();
3
3
  export const useThemeLocaleData = () => _useThemeLocaleData();
@@ -0,0 +1,7 @@
1
+ export declare enum DeviceType {
2
+ MOBILE = "mobile"
3
+ }
4
+ /**
5
+ * add listener to detect screen though device type
6
+ */
7
+ export declare const useUpdateDeviceStatus: (deviceType: DeviceType, callback: (width: number) => void) => void;
@@ -0,0 +1,25 @@
1
+ import { onMounted } from 'vue';
2
+ import cssVars from '../styles/_variables.module.scss?module';
3
+ export var DeviceType;
4
+ (function (DeviceType) {
5
+ DeviceType["MOBILE"] = "mobile";
6
+ })(DeviceType || (DeviceType = {}));
7
+ const DeviceTypeMap = {
8
+ [DeviceType.MOBILE]: Number.parseInt(cssVars.mobile?.replace('px', ''), 10),
9
+ };
10
+ /**
11
+ * add listener to detect screen though device type
12
+ */
13
+ export const useUpdateDeviceStatus = (deviceType, callback) => {
14
+ const width = DeviceTypeMap[deviceType];
15
+ if (!Number.isInteger(width)) {
16
+ if (__VUEPRESS_DEV__)
17
+ throw new Error('device width must be a integer');
18
+ return;
19
+ }
20
+ onMounted(() => {
21
+ callback(width);
22
+ window.addEventListener('resize', () => callback(width), false);
23
+ window.addEventListener('orientationchange', () => callback(width), false);
24
+ });
25
+ };
@@ -0,0 +1,4 @@
1
+ import type { ClientConfig } from 'vuepress/client';
2
+ import './styles/index.scss';
3
+ declare const _default: ClientConfig;
4
+ export default _default;
@@ -0,0 +1,44 @@
1
+ import { h } from 'vue';
2
+ import { defineClientConfig } from 'vuepress/client';
3
+ import { Badge, CodeGroup, CodeGroupItem } from './components/global/index.js';
4
+ import { setupDarkMode, setupSidebarItems, useScrollPromise, } from './composables/index.js';
5
+ import Layout from './layouts/Layout.vue';
6
+ import NotFound from './layouts/NotFound.vue';
7
+ import './styles/index.scss';
8
+ export default defineClientConfig({
9
+ enhance({ app, router }) {
10
+ app.component('Badge', Badge);
11
+ app.component('CodeGroup', CodeGroup);
12
+ app.component('CodeGroupItem', CodeGroupItem);
13
+ // compat with @vuepress/plugin-external-link-icon
14
+ app.component('AutoLinkExternalIcon', () => {
15
+ const ExternalLinkIcon = app.component('ExternalLinkIcon');
16
+ if (ExternalLinkIcon) {
17
+ return h(ExternalLinkIcon);
18
+ }
19
+ return null;
20
+ });
21
+ // compat with @vuepress/plugin-docsearch and @vuepress/plugin-search
22
+ app.component('NavbarSearch', () => {
23
+ const SearchComponent = app.component('Docsearch') || app.component('SearchBox');
24
+ if (SearchComponent) {
25
+ return h(SearchComponent);
26
+ }
27
+ return null;
28
+ });
29
+ // handle scrollBehavior with transition
30
+ const scrollBehavior = router.options.scrollBehavior;
31
+ router.options.scrollBehavior = async (...args) => {
32
+ await useScrollPromise().wait();
33
+ return scrollBehavior(...args);
34
+ };
35
+ },
36
+ setup() {
37
+ setupDarkMode();
38
+ setupSidebarItems();
39
+ },
40
+ layouts: {
41
+ Layout,
42
+ NotFound,
43
+ },
44
+ });
@@ -1,4 +1,3 @@
1
- import type { NavItem, NavGroup, NavLink, NavbarItem, NavbarGroup, NavbarConfig, ResolvedNavbarItem, SidebarItem, SidebarGroup, SidebarConfigArray, SidebarConfigObject, SidebarConfig, ResolvedSidebarItem, DefaultThemePluginsOptions, DefaultThemeLocaleOptions, DefaultThemeData, DefaultThemeLocaleData, DefaultThemePageData, DefaultThemeHomePageFrontmatter, DefaultThemePageFrontmatter } from '../shared';
2
- export type { NavItem, NavGroup, NavLink, NavbarItem, NavbarGroup, NavbarConfig, ResolvedNavbarItem, SidebarItem, SidebarGroup, SidebarConfigArray, SidebarConfigObject, SidebarConfig, ResolvedSidebarItem, DefaultThemePluginsOptions, DefaultThemeLocaleOptions, DefaultThemeData, DefaultThemeLocaleData, DefaultThemePageData, DefaultThemeHomePageFrontmatter, DefaultThemePageFrontmatter, };
3
- export * from './composables';
4
- export * from './utils';
1
+ export * from '../shared/index.js';
2
+ export * from './composables/index.js';
3
+ export * from './utils/index.js';
@@ -1,2 +1,3 @@
1
- export * from './composables';
2
- export * from './utils';
1
+ export * from '../shared/index.js';
2
+ export * from './composables/index.js';
3
+ export * from './utils/index.js';