@vuepress/theme-default 2.0.0-beta.23 → 2.0.0-beta.27

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 (50) hide show
  1. package/lib/client/clientAppEnhance.js +1 -1
  2. package/lib/client/clientAppSetup.js +4 -9
  3. package/lib/client/components/DropdownLink.vue +83 -98
  4. package/lib/client/components/DropdownTransition.vue +8 -21
  5. package/lib/client/components/Home.vue +52 -75
  6. package/lib/client/components/NavLink.vue +71 -83
  7. package/lib/client/components/Navbar.vue +18 -9
  8. package/lib/client/components/NavbarLinks.vue +13 -29
  9. package/lib/client/components/Page.vue +1 -11
  10. package/lib/client/components/PageMeta.vue +10 -26
  11. package/lib/client/components/PageNav.vue +19 -34
  12. package/lib/client/components/Sidebar.vue +2 -17
  13. package/lib/client/components/ToggleDarkModeButton.vue +2 -9
  14. package/lib/client/components/ToggleSidebarButton.vue +17 -19
  15. package/lib/client/components/global/Badge.vue +16 -22
  16. package/lib/client/components/global/CodeGroup.js +8 -3
  17. package/lib/client/components/global/CodeGroupItem.vue +13 -11
  18. package/lib/client/components/global/OutboundLink.vue +4 -19
  19. package/lib/client/composables/index.d.ts +0 -2
  20. package/lib/client/composables/index.js +0 -2
  21. package/lib/client/composables/useDarkMode.d.ts +12 -2
  22. package/lib/client/composables/useDarkMode.js +57 -3
  23. package/lib/client/composables/useResolveRouteWithRedirect.js +1 -1
  24. package/lib/client/composables/useSidebarItems.d.ts +6 -2
  25. package/lib/client/composables/useSidebarItems.js +13 -4
  26. package/lib/client/index.d.ts +1 -1
  27. package/lib/client/layouts/404.vue +8 -21
  28. package/lib/client/layouts/Layout.vue +76 -106
  29. package/lib/client/styles/badge.scss +1 -3
  30. package/lib/client/styles/code.scss +1 -0
  31. package/lib/client/styles/custom-container.scss +2 -4
  32. package/lib/client/styles/home.scss +10 -7
  33. package/lib/client/styles/layout.scss +24 -3
  34. package/lib/client/styles/navbar.scss +18 -2
  35. package/lib/client/styles/normalize.scss +3 -3
  36. package/lib/client/styles/page.scss +1 -1
  37. package/lib/client/styles/sidebar.scss +1 -1
  38. package/lib/client/styles/vars.scss +4 -0
  39. package/lib/client/utils/resolveEditLink.js +1 -1
  40. package/lib/node/defaultTheme.js +10 -10
  41. package/lib/node/utils/assignDefaultLocaleOptions.js +1 -0
  42. package/lib/node/utils/resolveContainerPluginOptions.d.ts +1 -1
  43. package/lib/node/utils/resolveGitPluginOptions.d.ts +1 -1
  44. package/lib/shared/options.d.ts +11 -1
  45. package/lib/shared/page.d.ts +1 -0
  46. package/package.json +20 -19
  47. package/lib/client/composables/useHtmlDarkClass.d.ts +0 -2
  48. package/lib/client/composables/useHtmlDarkClass.js +0 -14
  49. package/lib/client/composables/usePrefersColorScheme.d.ts +0 -2
  50. package/lib/client/composables/usePrefersColorScheme.js +0 -18
@@ -8,13 +8,13 @@
8
8
  </nav>
9
9
  </template>
10
10
 
11
- <script lang="ts">
12
- import { computed, defineComponent } from 'vue'
13
- import type { ComputedRef } from 'vue'
14
- import { useRouter } from 'vue-router'
11
+ <script setup lang="ts">
15
12
  import { useRouteLocale, useSiteLocaleData } from '@vuepress/client'
16
13
  import { isLinkHttp, isString } from '@vuepress/shared'
17
- import type { NavbarItem, NavbarGroup, ResolvedNavbarItem } from '../../shared'
14
+ import { computed } from 'vue'
15
+ import type { ComputedRef } from 'vue'
16
+ import { useRouter } from 'vue-router'
17
+ import type { NavbarGroup, NavbarItem, ResolvedNavbarItem } from '../../shared'
18
18
  import { useNavLink, useThemeLocaleData } from '../composables'
19
19
  import { resolveRepoType } from '../utils'
20
20
  import DropdownLink from './DropdownLink.vue'
@@ -144,28 +144,12 @@ const useNavbarConfig = (): ComputedRef<ResolvedNavbarItem[]> => {
144
144
  return computed(() => (themeLocale.value.navbar || []).map(resolveNavbarItem))
145
145
  }
146
146
 
147
- export default defineComponent({
148
- name: 'NavbarLinks',
149
-
150
- components: {
151
- NavLink,
152
- DropdownLink,
153
- },
154
-
155
- setup() {
156
- const navbarConfig = useNavbarConfig()
157
- const navbarSelectLanguage = useNavbarSelectLanguage()
158
- const navbarRepo = useNavbarRepo()
159
-
160
- const navbarLinks = computed(() => [
161
- ...navbarConfig.value,
162
- ...navbarSelectLanguage.value,
163
- ...navbarRepo.value,
164
- ])
165
-
166
- return {
167
- navbarLinks,
168
- }
169
- },
170
- })
147
+ const navbarConfig = useNavbarConfig()
148
+ const navbarSelectLanguage = useNavbarSelectLanguage()
149
+ const navbarRepo = useNavbarRepo()
150
+ const navbarLinks = computed(() => [
151
+ ...navbarConfig.value,
152
+ ...navbarSelectLanguage.value,
153
+ ...navbarRepo.value,
154
+ ])
171
155
  </script>
@@ -14,17 +14,7 @@
14
14
  </main>
15
15
  </template>
16
16
 
17
- <script>
18
- import { defineComponent } from 'vue'
17
+ <script setup lang="ts">
19
18
  import PageMeta from './PageMeta.vue'
20
19
  import PageNav from './PageNav.vue'
21
-
22
- export default defineComponent({
23
- name: 'Page',
24
-
25
- components: {
26
- PageMeta,
27
- PageNav,
28
- },
29
- })
30
20
  </script>
@@ -26,17 +26,17 @@
26
26
  </footer>
27
27
  </template>
28
28
 
29
- <script lang="ts">
30
- import { computed, defineComponent } from 'vue'
31
- import type { ComputedRef } from 'vue'
29
+ <script setup lang="ts">
32
30
  import {
33
31
  usePageData,
34
32
  usePageFrontmatter,
35
33
  useSiteLocaleData,
36
34
  } from '@vuepress/client'
35
+ import { computed } from 'vue'
36
+ import type { ComputedRef } from 'vue'
37
37
  import type {
38
- DefaultThemePageData,
39
38
  DefaultThemeNormalPageFrontmatter,
39
+ DefaultThemePageData,
40
40
  NavLink as NavLinkType,
41
41
  } from '../../shared'
42
42
  import { useThemeLocaleData } from '../composables'
@@ -70,7 +70,8 @@ const useEditNavLink = (): ComputedRef<null | NavLinkType> => {
70
70
  docsBranch,
71
71
  docsDir,
72
72
  filePathRelative: page.value.filePathRelative,
73
- editLinkPattern: themeLocale.value.editLinkPattern,
73
+ editLinkPattern:
74
+ frontmatter.value.editLinkPattern ?? themeLocale.value.editLinkPattern,
74
75
  })
75
76
 
76
77
  if (!editLink) return null
@@ -119,25 +120,8 @@ const useContributors = (): ComputedRef<
119
120
  })
120
121
  }
121
122
 
122
- export default defineComponent({
123
- name: 'PageMeta',
124
-
125
- components: {
126
- NavLink,
127
- },
128
-
129
- setup() {
130
- const themeLocale = useThemeLocaleData()
131
- const editNavLink = useEditNavLink()
132
- const lastUpdated = useLastUpdated()
133
- const contributors = useContributors()
134
-
135
- return {
136
- themeLocale,
137
- editNavLink,
138
- lastUpdated,
139
- contributors,
140
- }
141
- },
142
- })
123
+ const themeLocale = useThemeLocaleData()
124
+ const editNavLink = useEditNavLink()
125
+ const lastUpdated = useLastUpdated()
126
+ const contributors = useContributors()
143
127
  </script>
@@ -14,11 +14,11 @@
14
14
  </nav>
15
15
  </template>
16
16
 
17
- <script lang="ts">
18
- import { computed, defineComponent } from 'vue'
19
- import { useRoute } from 'vue-router'
17
+ <script setup lang="ts">
20
18
  import { usePageFrontmatter } from '@vuepress/client'
21
19
  import { isPlainObject, isString } from '@vuepress/shared'
20
+ import { computed } from 'vue'
21
+ import { useRoute } from 'vue-router'
22
22
  import type {
23
23
  DefaultThemeNormalPageFrontmatter,
24
24
  NavLink as NavLinkType,
@@ -81,40 +81,25 @@ const resolveFromSidebarItems = (
81
81
  return null
82
82
  }
83
83
 
84
- export default defineComponent({
85
- name: 'PageNav',
86
-
87
- components: {
88
- NavLink,
89
- },
90
-
91
- setup() {
92
- const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
93
- const sidebarItems = useSidebarItems()
94
- const route = useRoute()
95
-
96
- const prevNavLink = computed(() => {
97
- const prevConfig = resolveFromFrontmatterConfig(frontmatter.value.prev)
98
- if (prevConfig !== false) {
99
- return prevConfig
100
- }
84
+ const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
85
+ const sidebarItems = useSidebarItems()
86
+ const route = useRoute()
101
87
 
102
- return resolveFromSidebarItems(sidebarItems.value, route.path, -1)
103
- })
88
+ const prevNavLink = computed(() => {
89
+ const prevConfig = resolveFromFrontmatterConfig(frontmatter.value.prev)
90
+ if (prevConfig !== false) {
91
+ return prevConfig
92
+ }
104
93
 
105
- const nextNavLink = computed(() => {
106
- const nextConfig = resolveFromFrontmatterConfig(frontmatter.value.next)
107
- if (nextConfig !== false) {
108
- return nextConfig
109
- }
94
+ return resolveFromSidebarItems(sidebarItems.value, route.path, -1)
95
+ })
110
96
 
111
- return resolveFromSidebarItems(sidebarItems.value, route.path, 1)
112
- })
97
+ const nextNavLink = computed(() => {
98
+ const nextConfig = resolveFromFrontmatterConfig(frontmatter.value.next)
99
+ if (nextConfig !== false) {
100
+ return nextConfig
101
+ }
113
102
 
114
- return {
115
- prevNavLink,
116
- nextNavLink,
117
- }
118
- },
103
+ return resolveFromSidebarItems(sidebarItems.value, route.path, 1)
119
104
  })
120
105
  </script>
@@ -16,25 +16,10 @@
16
16
  </aside>
17
17
  </template>
18
18
 
19
- <script lang="ts">
20
- import { defineComponent } from 'vue'
19
+ <script setup lang="ts">
21
20
  import { useSidebarItems } from '../composables'
22
21
  import NavbarLinks from './NavbarLinks.vue'
23
22
  import { SidebarChild } from './SidebarChild'
24
23
 
25
- export default defineComponent({
26
- name: 'Sidebar',
27
-
28
- components: {
29
- NavbarLinks,
30
- SidebarChild,
31
- },
32
-
33
- setup() {
34
- const sidebarItems = useSidebarItems()
35
- return {
36
- sidebarItems,
37
- }
38
- },
39
- })
24
+ const sidebarItems = useSidebarItems()
40
25
  </script>
@@ -46,19 +46,12 @@
46
46
  </template>
47
47
 
48
48
  <script setup lang="ts">
49
- import {
50
- useDarkMode,
51
- useHtmlDarkClass,
52
- usePrefersColorScheme,
53
- useThemeLocaleData,
54
- } from '../composables'
49
+ import { useDarkMode, useThemeLocaleData } from '../composables'
55
50
 
56
51
  const themeLocale = useThemeLocaleData()
57
-
58
52
  const isDarkMode = useDarkMode()
53
+
59
54
  const toggleDarkMode = (): void => {
60
55
  isDarkMode.value = !isDarkMode.value
61
56
  }
62
- useHtmlDarkClass(isDarkMode)
63
- usePrefersColorScheme(isDarkMode)
64
57
  </script>
@@ -1,26 +1,24 @@
1
1
  <template>
2
- <div class="toggle-sidebar-button" @click="$emit('toggle')">
3
- <svg
4
- class="icon"
5
- xmlns="http://www.w3.org/2000/svg"
6
- aria-hidden="true"
7
- role="img"
8
- viewBox="0 0 448 512"
9
- >
10
- <path
11
- fill="currentColor"
12
- d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"
13
- />
14
- </svg>
2
+ <div
3
+ class="toggle-sidebar-button"
4
+ :title="themeLocale.toggleSidebar"
5
+ aria-expanded="false"
6
+ role="button"
7
+ tabindex="0"
8
+ @click="$emit('toggle')"
9
+ >
10
+ <div class="icon" aria-hidden="true">
11
+ <span></span>
12
+ <span></span>
13
+ <span></span>
14
+ </div>
15
15
  </div>
16
16
  </template>
17
17
 
18
- <script lang="ts">
19
- import { defineComponent } from 'vue'
18
+ <script setup lang="ts">
19
+ import { useThemeLocaleData } from '../composables'
20
20
 
21
- export default defineComponent({
22
- name: 'ToggleSidebarButton',
21
+ defineEmits(['toggle'])
23
22
 
24
- emits: ['toggle'],
25
- })
23
+ const themeLocale = useThemeLocaleData()
26
24
  </script>
@@ -10,28 +10,22 @@
10
10
  </span>
11
11
  </template>
12
12
 
13
- <script>
14
- import { defineComponent } from 'vue'
15
-
16
- export default defineComponent({
17
- name: 'Badge',
18
-
19
- props: {
20
- type: {
21
- type: String,
22
- required: false,
23
- default: 'tip',
24
- },
25
- text: {
26
- type: String,
27
- required: false,
28
- default: '',
29
- },
30
- vertical: {
31
- type: String,
32
- required: false,
33
- default: undefined,
34
- },
13
+ <script setup lang="ts">
14
+ defineProps({
15
+ type: {
16
+ type: String,
17
+ required: false,
18
+ default: 'tip',
19
+ },
20
+ text: {
21
+ type: String,
22
+ required: false,
23
+ default: '',
24
+ },
25
+ vertical: {
26
+ type: String,
27
+ required: false,
28
+ default: undefined,
35
29
  },
36
30
  })
37
31
  </script>
@@ -1,4 +1,4 @@
1
- import { defineComponent, h, ref } from 'vue';
1
+ import { defineComponent, h, onBeforeUpdate, ref } from 'vue';
2
2
  export default defineComponent({
3
3
  name: 'CodeGroup',
4
4
  setup(_, { slots }) {
@@ -6,6 +6,13 @@ export default defineComponent({
6
6
  const activeIndex = ref(-1);
7
7
  // refs of the tab buttons
8
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
+ }
9
16
  // activate next tab
10
17
  const activateNext = (i = activeIndex.value) => {
11
18
  if (i < tabRefs.value.length - 1) {
@@ -55,8 +62,6 @@ export default defineComponent({
55
62
  }
56
63
  return vnode;
57
64
  });
58
- // clear tabRefs for HMR
59
- tabRefs.value = [];
60
65
  // do not render anything if there is no code-group-item
61
66
  if (items.length === 0) {
62
67
  return null;
@@ -8,22 +8,24 @@
8
8
  </div>
9
9
  </template>
10
10
 
11
- <script>
11
+ <script lang="ts">
12
12
  import { defineComponent } from 'vue'
13
13
 
14
14
  export default defineComponent({
15
15
  name: 'CodeGroupItem',
16
+ })
17
+ </script>
16
18
 
17
- props: {
18
- title: {
19
- type: String,
20
- required: true,
21
- },
22
- active: {
23
- type: Boolean,
24
- required: false,
25
- default: false,
26
- },
19
+ <script setup lang="ts">
20
+ defineProps({
21
+ title: {
22
+ type: String,
23
+ required: true,
24
+ },
25
+ active: {
26
+ type: Boolean,
27
+ required: false,
28
+ default: false,
27
29
  },
28
30
  })
29
31
  </script>
@@ -4,27 +4,12 @@
4
4
  </RawOutboundLink>
5
5
  </template>
6
6
 
7
- <script>
8
- import { defineComponent } from 'vue'
9
- import { OutboundLink } from '@vuepress/client'
10
- import { useThemeLocaleData } from '../../composables'
11
-
7
+ <script setup lang="ts">
12
8
  /**
13
9
  * Override the built-in `<OutboundLink>` for a11y
14
10
  */
15
- export default defineComponent({
16
- name: 'OutboundLink',
17
-
18
- components: {
19
- RawOutboundLink: OutboundLink,
20
- },
21
-
22
- setup() {
23
- const themeLocale = useThemeLocaleData()
11
+ import { OutboundLink as RawOutboundLink } from '@vuepress/client'
12
+ import { useThemeLocaleData } from '../../composables'
24
13
 
25
- return {
26
- themeLocale,
27
- }
28
- },
29
- })
14
+ const themeLocale = useThemeLocaleData()
30
15
  </script>
@@ -1,7 +1,5 @@
1
1
  export * from './useDarkMode';
2
- export * from './useHtmlDarkClass';
3
2
  export * from './useNavLink';
4
- export * from './usePrefersColorScheme';
5
3
  export * from './useResolveRouteWithRedirect';
6
4
  export * from './useScrollPromise';
7
5
  export * from './useSidebarItems';
@@ -1,7 +1,5 @@
1
1
  export * from './useDarkMode';
2
- export * from './useHtmlDarkClass';
3
2
  export * from './useNavLink';
4
- export * from './usePrefersColorScheme';
5
3
  export * from './useResolveRouteWithRedirect';
6
4
  export * from './useScrollPromise';
7
5
  export * from './useSidebarItems';
@@ -1,2 +1,12 @@
1
- import type { Ref } from 'vue';
2
- export declare const useDarkMode: () => Ref<boolean>;
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;
@@ -1,3 +1,57 @@
1
- import { ref } from 'vue';
2
- const isDarkMode = ref(false);
3
- export const useDarkMode = () => isDarkMode;
1
+ import { usePreferredDark, useStorage } from '@vueuse/core';
2
+ import { computed, inject, onMounted, onUnmounted, provide, watch } from 'vue';
3
+ import { useThemeLocaleData } from '.';
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', 'auto');
22
+ const isDarkMode = computed({
23
+ get() {
24
+ // disable dark mode
25
+ if (!themeLocale.value.darkMode) {
26
+ return false;
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 === null || window === void 0 ? void 0 : window.document.querySelector('html');
51
+ htmlEl === null || htmlEl === void 0 ? void 0 : htmlEl.classList.toggle('dark', value);
52
+ };
53
+ onMounted(() => {
54
+ watch(isDarkMode, update, { immediate: true });
55
+ });
56
+ onUnmounted(() => update());
57
+ };
@@ -1,5 +1,5 @@
1
- import { useRouter } from 'vue-router';
2
1
  import { isFunction, isString } from '@vuepress/shared';
2
+ import { useRouter } from 'vue-router';
3
3
  /**
4
4
  * Resolve a route with redirection
5
5
  */
@@ -1,12 +1,16 @@
1
- import type { ComputedRef, InjectionKey } from 'vue';
2
1
  import type { PageHeader } from '@vuepress/client';
3
- import type { DefaultThemeData, DefaultThemeNormalPageFrontmatter, SidebarConfigArray, SidebarConfigObject, ResolvedSidebarItem } from '../../shared';
2
+ import type { ComputedRef, InjectionKey } from 'vue';
3
+ import type { DefaultThemeData, DefaultThemeNormalPageFrontmatter, ResolvedSidebarItem, SidebarConfigArray, SidebarConfigObject } from '../../shared';
4
4
  export declare type SidebarItemsRef = ComputedRef<ResolvedSidebarItem[]>;
5
5
  export declare const sidebarItemsSymbol: InjectionKey<SidebarItemsRef>;
6
6
  /**
7
7
  * Inject sidebar items global computed
8
8
  */
9
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;
10
14
  /**
11
15
  * Resolve sidebar items global computed
12
16
  *
@@ -1,8 +1,8 @@
1
- import { inject } from 'vue';
2
- import { useRoute } from 'vue-router';
3
- import { usePageData } from '@vuepress/client';
1
+ import { usePageData, usePageFrontmatter } from '@vuepress/client';
4
2
  import { isArray, isPlainObject, isString, resolveLocalePath, } from '@vuepress/shared';
5
- import { useNavLink } from './useNavLink';
3
+ import { computed, inject, provide } from 'vue';
4
+ import { useRoute } from 'vue-router';
5
+ import { useNavLink, useThemeLocaleData } from '.';
6
6
  export const sidebarItemsSymbol = Symbol('sidebarItems');
7
7
  /**
8
8
  * Inject sidebar items global computed
@@ -14,6 +14,15 @@ export const useSidebarItems = () => {
14
14
  }
15
15
  return sidebarItems;
16
16
  };
17
+ /**
18
+ * Create sidebar items ref and provide as global computed in setup
19
+ */
20
+ export const setupSidebarItems = () => {
21
+ const themeLocale = useThemeLocaleData();
22
+ const frontmatter = usePageFrontmatter();
23
+ const sidebarItems = computed(() => resolveSidebarItems(frontmatter.value, themeLocale.value));
24
+ provide(sidebarItemsSymbol, sidebarItems);
25
+ };
17
26
  /**
18
27
  * Resolve sidebar items global computed
19
28
  *
@@ -1,4 +1,4 @@
1
- import type { NavItem, NavGroup, NavLink, NavbarItem, NavbarGroup, NavbarConfig, ResolvedNavbarItem, SidebarItem, SidebarConfigArray, SidebarConfigObject, SidebarConfig, ResolvedSidebarItem, DefaultThemePluginsOptions, DefaultThemeLocaleOptions, DefaultThemeData, DefaultThemeLocaleData, DefaultThemePageData, DefaultThemePageFrontmatter, DefaultThemeHomePageFrontmatter, DefaultThemeNormalPageFrontmatter } from '../shared';
1
+ import type { DefaultThemeData, DefaultThemeHomePageFrontmatter, DefaultThemeLocaleData, DefaultThemeLocaleOptions, DefaultThemeNormalPageFrontmatter, DefaultThemePageData, DefaultThemePageFrontmatter, DefaultThemePluginsOptions, NavbarConfig, NavbarGroup, NavbarItem, NavGroup, NavItem, NavLink, ResolvedNavbarItem, ResolvedSidebarItem, SidebarConfig, SidebarConfigArray, SidebarConfigObject, SidebarItem } from '../shared';
2
2
  export type { NavItem, NavGroup, NavLink, NavbarItem, NavbarGroup, NavbarConfig, ResolvedNavbarItem, SidebarItem, SidebarConfigArray, SidebarConfigObject, SidebarConfig, ResolvedSidebarItem, DefaultThemePluginsOptions, DefaultThemeLocaleOptions, DefaultThemeData, DefaultThemeLocaleData, DefaultThemePageData, DefaultThemePageFrontmatter, DefaultThemeHomePageFrontmatter, DefaultThemeNormalPageFrontmatter, };
3
3
  export * from './composables';
4
4
  export * from './utils';
@@ -10,29 +10,16 @@
10
10
  </div>
11
11
  </template>
12
12
 
13
- <script lang="ts">
14
- import { defineComponent } from 'vue'
13
+ <script setup lang="ts">
15
14
  import { useRouteLocale } from '@vuepress/client'
16
15
  import { useThemeLocaleData } from '../composables'
17
16
 
18
- export default defineComponent({
19
- name: '404',
17
+ const routeLocale = useRouteLocale()
18
+ const themeLocale = useThemeLocaleData()
20
19
 
21
- setup() {
22
- const routeLocale = useRouteLocale()
23
- const themeLocale = useThemeLocaleData()
24
-
25
- const messages = themeLocale.value.notFound ?? ['Not Found']
26
- const getMsg = (): string =>
27
- messages[Math.floor(Math.random() * messages.length)]
28
- const homeLink = themeLocale.value.home ?? routeLocale.value
29
- const homeText = themeLocale.value.backToHome ?? 'Back to home'
30
-
31
- return {
32
- getMsg,
33
- homeLink,
34
- homeText,
35
- }
36
- },
37
- })
20
+ const messages = themeLocale.value.notFound ?? ['Not Found']
21
+ const getMsg = (): string =>
22
+ messages[Math.floor(Math.random() * messages.length)]
23
+ const homeLink = themeLocale.value.home ?? routeLocale.value
24
+ const homeText = themeLocale.value.backToHome ?? 'Back to home'
38
25
  </script>