@vuepress/theme-default 2.0.0-beta.50-pre → 2.0.0-beta.51

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 (93) hide show
  1. package/lib/client/components/AutoLink.vue +114 -0
  2. package/lib/client/components/DropdownTransition.vue +21 -0
  3. package/lib/client/components/Home.vue +15 -0
  4. package/lib/client/components/HomeContent.vue +5 -0
  5. package/lib/client/components/HomeFeatures.vue +23 -0
  6. package/lib/client/components/HomeFooter.vue +17 -0
  7. package/lib/client/components/HomeHero.vue +97 -0
  8. package/lib/client/components/Navbar.vue +75 -0
  9. package/lib/client/components/NavbarBrand.vue +55 -0
  10. package/lib/client/components/NavbarDropdown.vue +126 -0
  11. package/lib/client/components/NavbarItems.vue +163 -0
  12. package/lib/client/components/Page.vue +24 -0
  13. package/lib/client/components/PageMeta.vue +124 -0
  14. package/lib/client/components/PageNav.vue +103 -0
  15. package/lib/client/components/Sidebar.vue +13 -0
  16. package/lib/client/components/SidebarItem.vue +87 -0
  17. package/lib/client/components/SidebarItems.vue +57 -0
  18. package/lib/client/components/ToggleColorModeButton.vue +57 -0
  19. package/lib/client/components/ToggleSidebarButton.vue +24 -0
  20. package/lib/client/components/global/Badge.vue +31 -0
  21. package/lib/client/components/global/CodeGroup.d.ts +4 -0
  22. package/lib/client/components/global/CodeGroup.js +106 -0
  23. package/lib/client/components/global/CodeGroupItem.vue +31 -0
  24. package/lib/client/components/global/index.d.ts +4 -0
  25. package/lib/client/components/global/index.js +4 -0
  26. package/lib/client/composables/index.d.ts +6 -0
  27. package/lib/client/composables/index.js +6 -0
  28. package/lib/client/composables/useDarkMode.d.ts +12 -0
  29. package/lib/client/composables/useDarkMode.js +57 -0
  30. package/lib/client/composables/useNavLink.d.ts +14 -0
  31. package/lib/client/composables/useNavLink.js +18 -0
  32. package/lib/client/composables/useResolveRouteWithRedirect.d.ts +5 -0
  33. package/lib/client/composables/useResolveRouteWithRedirect.js +24 -0
  34. package/lib/client/composables/useScrollPromise.d.ts +6 -0
  35. package/lib/client/composables/useScrollPromise.js +14 -0
  36. package/lib/client/composables/useSidebarItems.d.ts +36 -0
  37. package/lib/client/composables/useSidebarItems.js +118 -0
  38. package/lib/client/composables/useThemeData.d.ts +4 -0
  39. package/lib/client/composables/useThemeData.js +3 -0
  40. package/lib/client/config.d.ts +3 -0
  41. package/lib/client/config.js +44 -0
  42. package/lib/client/index.d.ts +3 -0
  43. package/lib/client/index.js +3 -0
  44. package/lib/client/layouts/Layout.vue +134 -0
  45. package/lib/client/layouts/NotFound.vue +27 -0
  46. package/lib/client/shim.d.ts +5 -0
  47. package/lib/client/styles/_mixins.scss +20 -0
  48. package/lib/client/styles/_variables.scss +11 -0
  49. package/lib/client/styles/arrow.scss +37 -0
  50. package/lib/client/styles/badge.scss +31 -0
  51. package/lib/client/styles/code-group.scss +69 -0
  52. package/lib/client/styles/code.scss +266 -0
  53. package/lib/client/styles/custom-container.scss +88 -0
  54. package/lib/client/styles/home.scss +168 -0
  55. package/lib/client/styles/index.scss +19 -0
  56. package/lib/client/styles/layout.scss +198 -0
  57. package/lib/client/styles/navbar-dropdown.scss +187 -0
  58. package/lib/client/styles/navbar.scss +177 -0
  59. package/lib/client/styles/normalize.scss +177 -0
  60. package/lib/client/styles/page.scss +83 -0
  61. package/lib/client/styles/sidebar.scss +134 -0
  62. package/lib/client/styles/toc.scss +5 -0
  63. package/lib/client/styles/transitions.scss +22 -0
  64. package/lib/client/styles/vars-dark.scss +46 -0
  65. package/lib/client/styles/vars.scss +133 -0
  66. package/lib/client/utils/index.d.ts +3 -0
  67. package/lib/client/utils/index.js +3 -0
  68. package/lib/client/utils/isActiveSidebarItem.d.ts +3 -0
  69. package/lib/client/utils/isActiveSidebarItem.js +20 -0
  70. package/lib/client/utils/resolveEditLink.d.ts +9 -0
  71. package/lib/client/utils/resolveEditLink.js +29 -0
  72. package/lib/client/utils/resolveRepoType.d.ts +2 -0
  73. package/lib/client/utils/resolveRepoType.js +12 -0
  74. package/lib/node/defaultTheme.d.ts +10 -0
  75. package/lib/node/defaultTheme.js +119 -0
  76. package/lib/node/index.d.ts +5 -0
  77. package/lib/node/index.js +5 -0
  78. package/lib/node/utils/assignDefaultLocaleOptions.d.ts +7 -0
  79. package/lib/node/utils/assignDefaultLocaleOptions.js +56 -0
  80. package/lib/node/utils/index.d.ts +2 -0
  81. package/lib/node/utils/index.js +2 -0
  82. package/lib/node/utils/resolveContainerPluginOptions.d.ts +8 -0
  83. package/lib/node/utils/resolveContainerPluginOptions.js +17 -0
  84. package/lib/shared/index.d.ts +3 -0
  85. package/lib/shared/index.js +3 -0
  86. package/lib/shared/nav.d.ts +43 -0
  87. package/lib/shared/nav.js +1 -0
  88. package/lib/shared/options.d.ts +243 -0
  89. package/lib/shared/options.js +1 -0
  90. package/lib/shared/page.d.ts +40 -0
  91. package/lib/shared/page.js +1 -0
  92. package/package.json +22 -20
  93. package/templates/build.html +33 -0
@@ -0,0 +1,106 @@
1
+ import { defineComponent, h, onBeforeUpdate, ref } from 'vue';
2
+ export const CodeGroup = defineComponent({
3
+ name: 'CodeGroup',
4
+ setup(_, { slots }) {
5
+ // index of current active item
6
+ const activeIndex = ref(-1);
7
+ // refs of the tab buttons
8
+ const tabRefs = ref([]);
9
+ if (__VUEPRESS_DEV__) {
10
+ // after removing a code-group-item, we need to clear the ref
11
+ // of the removed item to avoid issues caused by HMR
12
+ onBeforeUpdate(() => {
13
+ tabRefs.value = [];
14
+ });
15
+ }
16
+ // activate next tab
17
+ const activateNext = (i = activeIndex.value) => {
18
+ if (i < tabRefs.value.length - 1) {
19
+ activeIndex.value = i + 1;
20
+ }
21
+ else {
22
+ activeIndex.value = 0;
23
+ }
24
+ tabRefs.value[activeIndex.value].focus();
25
+ };
26
+ // activate previous tab
27
+ const activatePrev = (i = activeIndex.value) => {
28
+ if (i > 0) {
29
+ activeIndex.value = i - 1;
30
+ }
31
+ else {
32
+ activeIndex.value = tabRefs.value.length - 1;
33
+ }
34
+ tabRefs.value[activeIndex.value].focus();
35
+ };
36
+ // handle keyboard event
37
+ const keyboardHandler = (event, i) => {
38
+ if (event.key === ' ' || event.key === 'Enter') {
39
+ event.preventDefault();
40
+ activeIndex.value = i;
41
+ }
42
+ else if (event.key === 'ArrowRight') {
43
+ event.preventDefault();
44
+ activateNext(i);
45
+ }
46
+ else if (event.key === 'ArrowLeft') {
47
+ event.preventDefault();
48
+ activatePrev(i);
49
+ }
50
+ };
51
+ return () => {
52
+ // NOTICE: here we put the `slots.default()` inside the render function to make
53
+ // the slots reactive, otherwise the slot content won't be changed once the
54
+ // `setup()` function of current component is called
55
+ // get children code-group-item
56
+ const items = (slots.default?.() || [])
57
+ .filter((vnode) => vnode.type.name === 'CodeGroupItem')
58
+ .map((vnode) => {
59
+ if (vnode.props === null) {
60
+ vnode.props = {};
61
+ }
62
+ return vnode;
63
+ });
64
+ // do not render anything if there is no code-group-item
65
+ if (items.length === 0) {
66
+ return null;
67
+ }
68
+ if (activeIndex.value < 0 || activeIndex.value > items.length - 1) {
69
+ // if `activeIndex` is invalid
70
+ // find the index of the code-group-item with `active` props
71
+ activeIndex.value = items.findIndex((vnode) => vnode.props.active === '' || vnode.props.active === true);
72
+ // if there is no `active` props on code-group-item, set the first item active
73
+ if (activeIndex.value === -1) {
74
+ activeIndex.value = 0;
75
+ }
76
+ }
77
+ else {
78
+ // set the active item
79
+ items.forEach((vnode, i) => {
80
+ vnode.props.active = i === activeIndex.value;
81
+ });
82
+ }
83
+ return h('div', { class: 'code-group' }, [
84
+ h('div', { class: 'code-group__nav' }, h('ul', { class: 'code-group__ul' }, items.map((vnode, i) => {
85
+ const isActive = i === activeIndex.value;
86
+ return h('li', { class: 'code-group__li' }, h('button', {
87
+ ref: (element) => {
88
+ if (element) {
89
+ tabRefs.value[i] = element;
90
+ }
91
+ },
92
+ class: {
93
+ 'code-group__nav-tab': true,
94
+ 'code-group__nav-tab-active': isActive,
95
+ },
96
+ ariaPressed: isActive,
97
+ ariaExpanded: isActive,
98
+ onClick: () => (activeIndex.value = i),
99
+ onKeydown: (e) => keyboardHandler(e, i),
100
+ }, vnode.props.title));
101
+ }))),
102
+ items,
103
+ ]);
104
+ };
105
+ },
106
+ });
@@ -0,0 +1,31 @@
1
+ <script lang="ts">
2
+ import { defineComponent } from 'vue'
3
+
4
+ export default defineComponent({
5
+ name: 'CodeGroupItem',
6
+ })
7
+ </script>
8
+
9
+ <script setup lang="ts">
10
+ defineProps({
11
+ title: {
12
+ type: String,
13
+ required: true,
14
+ },
15
+ active: {
16
+ type: Boolean,
17
+ required: false,
18
+ default: false,
19
+ },
20
+ })
21
+ </script>
22
+
23
+ <template>
24
+ <div
25
+ class="code-group-item"
26
+ :class="{ 'code-group-item__active': active }"
27
+ :aria-selected="active"
28
+ >
29
+ <slot />
30
+ </div>
31
+ </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 };
@@ -0,0 +1,6 @@
1
+ export * from './useDarkMode.js';
2
+ export * from './useNavLink.js';
3
+ export * from './useResolveRouteWithRedirect.js';
4
+ export * from './useScrollPromise.js';
5
+ export * from './useSidebarItems.js';
6
+ export * from './useThemeData.js';
@@ -0,0 +1,6 @@
1
+ export * from './useDarkMode.js';
2
+ export * from './useNavLink.js';
3
+ export * from './useResolveRouteWithRedirect.js';
4
+ export * from './useScrollPromise.js';
5
+ export * from './useSidebarItems.js';
6
+ export * from './useThemeData.js';
@@ -0,0 +1,12 @@
1
+ import type { InjectionKey, WritableComputedRef } from 'vue';
2
+ export declare 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
+ };
@@ -0,0 +1,14 @@
1
+ import type { NavLink } from '../../shared/index.js';
2
+ declare module 'vue-router' {
3
+ interface RouteMeta {
4
+ title?: string;
5
+ }
6
+ }
7
+ /**
8
+ * Resolve NavLink props from string
9
+ *
10
+ * @example
11
+ * - Input: '/README.md'
12
+ * - Output: { text: 'Home', link: '/' }
13
+ */
14
+ export declare const useNavLink: (item: string) => NavLink;
@@ -0,0 +1,18 @@
1
+ import { useResolveRouteWithRedirect } from './useResolveRouteWithRedirect.js';
2
+ /**
3
+ * Resolve NavLink props from string
4
+ *
5
+ * @example
6
+ * - Input: '/README.md'
7
+ * - Output: { text: 'Home', link: '/' }
8
+ */
9
+ export const useNavLink = (item) => {
10
+ // the route path of vue-router is url-encoded, and we expect users are using
11
+ // non-url-encoded string in theme config, so we need to url-encode it first to
12
+ // resolve the route correctly
13
+ const resolved = useResolveRouteWithRedirect(encodeURI(item));
14
+ return {
15
+ text: resolved.meta.title || item,
16
+ link: resolved.name === '404' ? item : resolved.fullPath,
17
+ };
18
+ };
@@ -0,0 +1,5 @@
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']>;
@@ -0,0 +1,24 @@
1
+ import { isFunction, isString } from '@vuepress/shared';
2
+ import { useRouter } from 'vue-router';
3
+ /**
4
+ * Resolve a route with redirection
5
+ */
6
+ export const useResolveRouteWithRedirect = (...args) => {
7
+ const router = useRouter();
8
+ const route = router.resolve(...args);
9
+ const lastMatched = route.matched[route.matched.length - 1];
10
+ if (!lastMatched?.redirect) {
11
+ return route;
12
+ }
13
+ const { redirect } = lastMatched;
14
+ const resolvedRedirect = isFunction(redirect) ? redirect(route) : redirect;
15
+ const resolvedRedirectObj = isString(resolvedRedirect)
16
+ ? { path: resolvedRedirect }
17
+ : resolvedRedirect;
18
+ return useResolveRouteWithRedirect({
19
+ hash: route.hash,
20
+ query: route.query,
21
+ params: route.params,
22
+ ...resolvedRedirectObj,
23
+ });
24
+ };
@@ -0,0 +1,6 @@
1
+ export interface ScrollPromise {
2
+ wait(): Promise<void> | null;
3
+ pending: () => void;
4
+ resolve: () => void;
5
+ }
6
+ export declare const useScrollPromise: () => ScrollPromise;
@@ -0,0 +1,14 @@
1
+ let promise = null;
2
+ let promiseResolve = null;
3
+ const scrollPromise = {
4
+ wait: () => promise,
5
+ pending: () => {
6
+ promise = new Promise((resolve) => (promiseResolve = resolve));
7
+ },
8
+ resolve: () => {
9
+ promiseResolve?.();
10
+ promise = null;
11
+ promiseResolve = null;
12
+ },
13
+ };
14
+ export const useScrollPromise = () => scrollPromise;
@@ -0,0 +1,36 @@
1
+ import type { PageHeader } from '@vuepress/client';
2
+ import type { ComputedRef, InjectionKey } from 'vue';
3
+ import type { DefaultThemeData, DefaultThemeNormalPageFrontmatter, ResolvedSidebarItem, SidebarConfigArray, SidebarConfigObject } from '../../shared/index.js';
4
+ export declare type SidebarItemsRef = ComputedRef<ResolvedSidebarItem[]>;
5
+ export declare const sidebarItemsSymbol: InjectionKey<SidebarItemsRef>;
6
+ /**
7
+ * Inject sidebar items global computed
8
+ */
9
+ export declare const useSidebarItems: () => SidebarItemsRef;
10
+ /**
11
+ * Create sidebar items ref and provide as global computed in setup
12
+ */
13
+ export declare const setupSidebarItems: () => void;
14
+ /**
15
+ * Resolve sidebar items global computed
16
+ *
17
+ * It should only be resolved and provided once
18
+ */
19
+ export declare const resolveSidebarItems: (frontmatter: DefaultThemeNormalPageFrontmatter, themeLocale: DefaultThemeData) => ResolvedSidebarItem[];
20
+ /**
21
+ * Util to transform page header to sidebar item
22
+ */
23
+ export declare const headerToSidebarItem: (header: PageHeader, sidebarDepth: number) => ResolvedSidebarItem;
24
+ export declare const headersToSidebarItemChildren: (headers: PageHeader[], sidebarDepth: number) => ResolvedSidebarItem[];
25
+ /**
26
+ * Resolve sidebar items if the config is `auto`
27
+ */
28
+ export declare const resolveAutoSidebarItems: (sidebarDepth: number) => ResolvedSidebarItem[];
29
+ /**
30
+ * Resolve sidebar items if the config is an array
31
+ */
32
+ export declare const resolveArraySidebarItems: (sidebarConfig: SidebarConfigArray, sidebarDepth: number) => ResolvedSidebarItem[];
33
+ /**
34
+ * Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
35
+ */
36
+ export declare const resolveMultiSidebarItems: (sidebarConfig: SidebarConfigObject, sidebarDepth: number) => ResolvedSidebarItem[];
@@ -0,0 +1,118 @@
1
+ import { usePageData, usePageFrontmatter } from '@vuepress/client';
2
+ import { isArray, isPlainObject, isString, resolveLocalePath, } from '@vuepress/shared';
3
+ import { computed, inject, provide } from 'vue';
4
+ import { useRoute } from 'vue-router';
5
+ import { useNavLink } from './useNavLink.js';
6
+ import { useThemeLocaleData } from './useThemeData.js';
7
+ export const sidebarItemsSymbol = Symbol('sidebarItems');
8
+ /**
9
+ * Inject sidebar items global computed
10
+ */
11
+ export const useSidebarItems = () => {
12
+ const sidebarItems = inject(sidebarItemsSymbol);
13
+ if (!sidebarItems) {
14
+ throw new Error('useSidebarItems() is called without provider.');
15
+ }
16
+ return sidebarItems;
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 sidebarItems = computed(() => resolveSidebarItems(frontmatter.value, themeLocale.value));
25
+ provide(sidebarItemsSymbol, sidebarItems);
26
+ };
27
+ /**
28
+ * Resolve sidebar items global computed
29
+ *
30
+ * It should only be resolved and provided once
31
+ */
32
+ export const resolveSidebarItems = (frontmatter, themeLocale) => {
33
+ // get sidebar config from frontmatter > theme data
34
+ const sidebarConfig = frontmatter.sidebar ?? themeLocale.sidebar ?? 'auto';
35
+ const sidebarDepth = frontmatter.sidebarDepth ?? themeLocale.sidebarDepth ?? 2;
36
+ // resolve sidebar items according to the config
37
+ if (frontmatter.home || sidebarConfig === false) {
38
+ return [];
39
+ }
40
+ if (sidebarConfig === 'auto') {
41
+ return resolveAutoSidebarItems(sidebarDepth);
42
+ }
43
+ if (isArray(sidebarConfig)) {
44
+ return resolveArraySidebarItems(sidebarConfig, sidebarDepth);
45
+ }
46
+ if (isPlainObject(sidebarConfig)) {
47
+ return resolveMultiSidebarItems(sidebarConfig, sidebarDepth);
48
+ }
49
+ return [];
50
+ };
51
+ /**
52
+ * Util to transform page header to sidebar item
53
+ */
54
+ export const headerToSidebarItem = (header, sidebarDepth) => ({
55
+ text: header.title,
56
+ link: header.link,
57
+ children: headersToSidebarItemChildren(header.children, sidebarDepth),
58
+ });
59
+ export const headersToSidebarItemChildren = (headers, sidebarDepth) => sidebarDepth > 0
60
+ ? headers.map((header) => headerToSidebarItem(header, sidebarDepth - 1))
61
+ : [];
62
+ /**
63
+ * Resolve sidebar items if the config is `auto`
64
+ */
65
+ export const resolveAutoSidebarItems = (sidebarDepth) => {
66
+ const page = usePageData();
67
+ return [
68
+ {
69
+ text: page.value.title,
70
+ children: headersToSidebarItemChildren(page.value.headers, sidebarDepth),
71
+ },
72
+ ];
73
+ };
74
+ /**
75
+ * Resolve sidebar items if the config is an array
76
+ */
77
+ export const resolveArraySidebarItems = (sidebarConfig, sidebarDepth) => {
78
+ const route = useRoute();
79
+ const page = usePageData();
80
+ const handleChildItem = (item) => {
81
+ let childItem;
82
+ if (isString(item)) {
83
+ childItem = useNavLink(item);
84
+ }
85
+ else {
86
+ childItem = item;
87
+ }
88
+ if (childItem.children) {
89
+ return {
90
+ ...childItem,
91
+ children: childItem.children.map((item) => handleChildItem(item)),
92
+ };
93
+ }
94
+ // if the sidebar item is current page and children is not set
95
+ // use headers of current page as children
96
+ if (childItem.link === route.path) {
97
+ // skip h1 header
98
+ const headers = page.value.headers[0]?.level === 1
99
+ ? page.value.headers[0].children
100
+ : page.value.headers;
101
+ return {
102
+ ...childItem,
103
+ children: headersToSidebarItemChildren(headers, sidebarDepth),
104
+ };
105
+ }
106
+ return childItem;
107
+ };
108
+ return sidebarConfig.map((item) => handleChildItem(item));
109
+ };
110
+ /**
111
+ * Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
112
+ */
113
+ export const resolveMultiSidebarItems = (sidebarConfig, sidebarDepth) => {
114
+ const route = useRoute();
115
+ const sidebarPath = resolveLocalePath(sidebarConfig, route.path);
116
+ const matchedSidebarConfig = sidebarConfig[sidebarPath] ?? [];
117
+ return resolveArraySidebarItems(matchedSidebarConfig, sidebarDepth);
118
+ };
@@ -0,0 +1,4 @@
1
+ import type { ThemeDataRef, ThemeLocaleDataRef } from '@vuepress/plugin-theme-data/client';
2
+ import type { DefaultThemeData } from '../../shared/index.js';
3
+ export declare const useThemeData: () => ThemeDataRef<DefaultThemeData>;
4
+ export declare const useThemeLocaleData: () => ThemeLocaleDataRef<DefaultThemeData>;
@@ -0,0 +1,3 @@
1
+ import { useThemeData as _useThemeData, useThemeLocaleData as _useThemeLocaleData, } from '@vuepress/plugin-theme-data/client';
2
+ export const useThemeData = () => _useThemeData();
3
+ export const useThemeLocaleData = () => _useThemeLocaleData();
@@ -0,0 +1,3 @@
1
+ import './styles/index.scss';
2
+ declare const _default: import("@vuepress/client").ClientConfig;
3
+ export default _default;
@@ -0,0 +1,44 @@
1
+ import { defineClientConfig } from '@vuepress/client';
2
+ import { h } from 'vue';
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
+ });
@@ -0,0 +1,3 @@
1
+ export * from '../shared/index.js';
2
+ export * from './composables/index.js';
3
+ export * from './utils/index.js';
@@ -0,0 +1,3 @@
1
+ export * from '../shared/index.js';
2
+ export * from './composables/index.js';
3
+ export * from './utils/index.js';