@vuepress/theme-default 2.0.0-rc.3 → 2.0.0-rc.31

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 (54) hide show
  1. package/lib/client/components/HomeHero.vue +2 -2
  2. package/lib/client/components/Navbar.vue +10 -9
  3. package/lib/client/components/NavbarBrand.vue +3 -2
  4. package/lib/client/components/NavbarDropdown.vue +4 -5
  5. package/lib/client/components/NavbarItems.vue +36 -37
  6. package/lib/client/components/PageMeta.vue +123 -27
  7. package/lib/client/components/PageNav.vue +133 -27
  8. package/lib/client/components/SidebarItem.vue +2 -3
  9. package/lib/client/components/SidebarItems.vue +1 -1
  10. package/lib/client/composables/index.d.ts +1 -0
  11. package/lib/client/composables/index.js +1 -0
  12. package/lib/client/composables/useNavigate.d.ts +1 -0
  13. package/lib/client/composables/useNavigate.js +25 -0
  14. package/lib/client/composables/useSidebarItems.d.ts +3 -4
  15. package/lib/client/composables/useSidebarItems.js +10 -12
  16. package/lib/client/composables/useUpdateDeviceStatus.js +5 -4
  17. package/lib/client/config.js +7 -11
  18. package/lib/client/index.d.ts +1 -1
  19. package/lib/client/index.js +0 -1
  20. package/lib/client/layouts/Layout.vue +10 -2
  21. package/lib/client/layouts/NotFound.vue +2 -2
  22. package/lib/client/shim.d.ts +3 -3
  23. package/lib/client/styles/arrow.scss +18 -24
  24. package/lib/client/styles/code.scss +105 -9
  25. package/lib/client/styles/custom-container.scss +4 -8
  26. package/lib/client/styles/external-link-icon.scss +33 -0
  27. package/lib/client/styles/index.scss +1 -0
  28. package/lib/client/styles/layout.scss +4 -0
  29. package/lib/client/styles/navbar-dropdown.scss +2 -2
  30. package/lib/client/styles/navbar.scss +4 -4
  31. package/lib/client/styles/normalize.scss +1 -1
  32. package/lib/client/styles/page.scss +0 -76
  33. package/lib/client/styles/sidebar.scss +1 -1
  34. package/lib/client/styles/vars-dark.scss +7 -0
  35. package/lib/client/styles/vars.scss +69 -14
  36. package/lib/client/utils/getNavLink.d.ts +3 -9
  37. package/lib/client/utils/getNavLink.js +10 -11
  38. package/lib/client/utils/index.d.ts +0 -1
  39. package/lib/client/utils/index.js +0 -1
  40. package/lib/client/utils/isActiveSidebarItem.d.ts +1 -1
  41. package/lib/client/utils/resolveEditLink.d.ts +1 -1
  42. package/lib/node/defaultTheme.js +31 -23
  43. package/lib/node/index.d.ts +2 -1
  44. package/lib/node/index.js +1 -1
  45. package/lib/node/utils/resolveContainerPluginOptions.d.ts +3 -3
  46. package/lib/node/utils/resolveContainerPluginOptions.js +2 -2
  47. package/lib/shared/nav.d.ts +3 -11
  48. package/lib/shared/options.d.ts +27 -5
  49. package/lib/shared/page.d.ts +5 -3
  50. package/package.json +21 -20
  51. package/templates/build.html +13 -10
  52. package/lib/client/components/AutoLink.vue +0 -113
  53. package/lib/client/utils/getResolveRouteWithRedirect.d.ts +0 -5
  54. package/lib/client/utils/getResolveRouteWithRedirect.js +0 -22
@@ -1,8 +1,8 @@
1
1
  <script setup lang="ts">
2
- import AutoLink from '@theme/AutoLink.vue'
3
2
  import type { FunctionalComponent } from 'vue'
4
3
  import { computed, h } from 'vue'
5
4
  import {
5
+ AutoLink,
6
6
  ClientOnly,
7
7
  usePageFrontmatter,
8
8
  useSiteLocaleData,
@@ -90,7 +90,7 @@ const HomeHeroImage: FunctionalComponent = () => {
90
90
  :key="action.text"
91
91
  class="action-button"
92
92
  :class="[action.type]"
93
- :item="action"
93
+ :config="action"
94
94
  />
95
95
  </p>
96
96
  </header>
@@ -32,6 +32,16 @@ const linksWrapperStyle = computed(() => {
32
32
  }
33
33
  })
34
34
 
35
+ const getCssValue = (el: HTMLElement | null, property: string): number => {
36
+ // NOTE: Known bug, will return 'auto' if style value is 'auto'
37
+ const val = el?.ownerDocument?.defaultView?.getComputedStyle(el, null)?.[
38
+ property
39
+ ]
40
+ const num = Number.parseInt(val, 10)
41
+
42
+ return Number.isNaN(num) ? 0 : num
43
+ }
44
+
35
45
  useUpdateDeviceStatus(
36
46
  DeviceType.MOBILE,
37
47
  (mobileDesktopBreakpoint: number): void => {
@@ -49,15 +59,6 @@ useUpdateDeviceStatus(
49
59
  }
50
60
  },
51
61
  )
52
-
53
- function getCssValue(el: HTMLElement | null, property: string): number {
54
- // NOTE: Known bug, will return 'auto' if style value is 'auto'
55
- const val = el?.ownerDocument?.defaultView?.getComputedStyle(el, null)?.[
56
- property
57
- ]
58
- const num = Number.parseInt(val, 10)
59
- return Number.isNaN(num) ? 0 : num
60
- }
61
62
  </script>
62
63
 
63
64
  <template>
@@ -3,6 +3,7 @@ import { computed, h } from 'vue'
3
3
  import type { FunctionalComponent } from 'vue'
4
4
  import {
5
5
  ClientOnly,
6
+ RouteLink,
6
7
  useRouteLocale,
7
8
  useSiteLocaleData,
8
9
  withBase,
@@ -49,7 +50,7 @@ const NavbarBrandLogo: FunctionalComponent = () => {
49
50
  </script>
50
51
 
51
52
  <template>
52
- <RouterLink :to="navbarBrandLink">
53
+ <RouteLink :to="navbarBrandLink">
53
54
  <NavbarBrandLogo />
54
55
 
55
56
  <span
@@ -60,5 +61,5 @@ const NavbarBrandLogo: FunctionalComponent = () => {
60
61
  >
61
62
  {{ navbarBrandTitle }}
62
63
  </span>
63
- </RouterLink>
64
+ </RouteLink>
64
65
  </template>
@@ -1,9 +1,8 @@
1
1
  <script setup lang="ts">
2
- import AutoLink from '@theme/AutoLink.vue'
3
2
  import DropdownTransition from '@theme/DropdownTransition.vue'
4
3
  import { computed, ref, toRefs, watch } from 'vue'
5
4
  import type { PropType } from 'vue'
6
- import { useRoute } from 'vue-router'
5
+ import { AutoLink, useRoute } from 'vuepress/client'
7
6
  import type { NavbarItem, ResolvedNavbarItem } from '../../shared/index.js'
8
7
 
9
8
  const props = defineProps({
@@ -82,7 +81,7 @@ const isLastItemOfArray = (item: unknown, arr: unknown[]): boolean =>
82
81
  <h4 class="navbar-dropdown-subtitle">
83
82
  <AutoLink
84
83
  v-if="child.link"
85
- :item="child"
84
+ :config="child"
86
85
  @focusout="
87
86
  isLastItemOfArray(child, item.children) &&
88
87
  child.children.length === 0 &&
@@ -100,7 +99,7 @@ const isLastItemOfArray = (item: unknown, arr: unknown[]): boolean =>
100
99
  class="navbar-dropdown-subitem"
101
100
  >
102
101
  <AutoLink
103
- :item="grandchild"
102
+ :config="grandchild"
104
103
  @focusout="
105
104
  isLastItemOfArray(grandchild, child.children) &&
106
105
  isLastItemOfArray(child, item.children) &&
@@ -113,7 +112,7 @@ const isLastItemOfArray = (item: unknown, arr: unknown[]): boolean =>
113
112
 
114
113
  <template v-else>
115
114
  <AutoLink
116
- :item="child"
115
+ :config="child"
117
116
  @focusout="
118
117
  isLastItemOfArray(child, item.children) && (open = false)
119
118
  "
@@ -1,11 +1,15 @@
1
1
  <script setup lang="ts">
2
- import AutoLink from '@theme/AutoLink.vue'
3
2
  import NavbarDropdown from '@theme/NavbarDropdown.vue'
3
+ import { useRoutePaths } from '@vuepress/helper/client'
4
4
  import { computed, ref } from 'vue'
5
5
  import type { ComputedRef } from 'vue'
6
- import { useRouter } from 'vue-router'
7
- import type { Router } from 'vue-router'
8
- import { useRouteLocale, useSiteData, useSiteLocaleData } from 'vuepress/client'
6
+ import {
7
+ AutoLink,
8
+ useRoute,
9
+ useRouteLocale,
10
+ useSiteData,
11
+ useSiteLocaleData,
12
+ } from 'vuepress/client'
9
13
  import { isLinkHttp, isString } from 'vuepress/shared'
10
14
  import type {
11
15
  NavbarGroup,
@@ -18,13 +22,14 @@ import {
18
22
  useThemeLocaleData,
19
23
  useUpdateDeviceStatus,
20
24
  } from '../composables/index.js'
21
- import { getNavLink, resolveRepoType } from '../utils/index.js'
25
+ import { getAutoLink, resolveRepoType } from '../utils/index.js'
22
26
 
23
27
  /**
24
28
  * Get navbar config of select language dropdown
25
29
  */
26
30
  const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
27
- const router = useRouter()
31
+ const route = useRoute()
32
+ const routePaths = useRoutePaths()
28
33
  const routeLocale = useRouteLocale()
29
34
  const site = useSiteData()
30
35
  const siteLocale = useSiteLocaleData()
@@ -37,8 +42,8 @@ const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
37
42
  if (localePaths.length < 2) {
38
43
  return []
39
44
  }
40
- const currentPath = router.currentRoute.value.path
41
- const currentFullPath = router.currentRoute.value.fullPath
45
+ const currentPath = route.path
46
+ const currentFullPath = route.fullPath
42
47
 
43
48
  const languageDropdown: ResolvedNavbarItem = {
44
49
  text: `${themeLocale.value.selectLanguageText}`,
@@ -53,33 +58,31 @@ const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
53
58
  const targetLang = `${targetSiteLocale.lang}`
54
59
 
55
60
  const text = targetThemeLocale.selectLanguageName ?? targetLang
56
- let link
57
61
 
62
+ // if the target language is current language
63
+ // stay at current link
58
64
  if (targetLang === siteLocale.value.lang) {
59
- // if the target language is current language
60
- // stay at current link
61
- link = currentFullPath
62
- } else {
63
- // if the target language is not current language
64
- // try to link to the corresponding page of current page
65
- // or fallback to homepage
66
- const targetLocalePage = currentPath.replace(
67
- routeLocale.value,
68
- targetLocalePath,
69
- )
70
- if (
71
- router.getRoutes().some((item) => item.path === targetLocalePage)
72
- ) {
73
- // try to keep current hash and params across languages
74
- link = currentFullPath.replace(currentPath, targetLocalePage)
75
- } else {
76
- link = targetThemeLocale.home ?? targetLocalePath
65
+ return {
66
+ text,
67
+ activeMatch: /./,
68
+ link: route.hash ?? '#',
77
69
  }
78
70
  }
79
71
 
72
+ // if the target language is not current language
73
+ // try to link to the corresponding page of current page
74
+ // or fallback to homepage
75
+ const targetLocalePage = currentPath.replace(
76
+ routeLocale.value,
77
+ targetLocalePath,
78
+ )
79
+
80
80
  return {
81
81
  text,
82
- link,
82
+ // try to keep current hash and params across languages
83
+ link: routePaths.value.some((item) => item === targetLocalePage)
84
+ ? currentFullPath.replace(currentPath, targetLocalePage)
85
+ : targetThemeLocale.home ?? targetLocalePath,
83
86
  }
84
87
  }),
85
88
  }
@@ -129,17 +132,16 @@ const useNavbarRepo = (): ComputedRef<ResolvedNavbarItem[]> => {
129
132
  }
130
133
 
131
134
  const resolveNavbarItem = (
132
- router: Router,
133
135
  item: NavbarItem | NavbarGroup | string,
134
136
  ): ResolvedNavbarItem => {
135
137
  if (isString(item)) {
136
- return getNavLink(router, item)
138
+ return getAutoLink(item)
137
139
  }
138
140
  if ((item as NavbarGroup).children) {
139
141
  return {
140
142
  ...item,
141
143
  children: (item as NavbarGroup).children.map((item) =>
142
- resolveNavbarItem(router, item),
144
+ resolveNavbarItem(item),
143
145
  ),
144
146
  }
145
147
  }
@@ -147,13 +149,10 @@ const resolveNavbarItem = (
147
149
  }
148
150
 
149
151
  const useNavbarConfig = (): ComputedRef<ResolvedNavbarItem[]> => {
150
- const router = useRouter()
151
152
  const themeLocale = useThemeLocaleData()
152
153
 
153
154
  return computed(() =>
154
- (themeLocale.value.navbar || []).map((item) =>
155
- resolveNavbarItem(router, item),
156
- ),
155
+ (themeLocale.value.navbar || []).map((item) => resolveNavbarItem(item)),
157
156
  )
158
157
  }
159
158
 
@@ -189,11 +188,11 @@ const navbarLabel = computed(() => {
189
188
  <nav v-if="navbarLinks.length" class="navbar-items" :aria-label="navbarLabel">
190
189
  <div v-for="item in navbarLinks" :key="item.text" class="navbar-item">
191
190
  <NavbarDropdown
192
- v-if="item.children"
191
+ v-if="'children' in item"
193
192
  :item="item"
194
193
  :class="isMobile ? 'mobile' : ''"
195
194
  />
196
- <AutoLink v-else :item="item" />
195
+ <AutoLink v-else :config="item" />
197
196
  </div>
198
197
  </nav>
199
198
  </template>
@@ -1,17 +1,16 @@
1
1
  <script setup lang="ts">
2
- import AutoLink from '@theme/AutoLink.vue'
3
2
  import { computed } from 'vue'
4
3
  import type { ComputedRef } from 'vue'
5
- import { usePageData, usePageFrontmatter } from 'vuepress/client'
4
+ import { AutoLink, usePageData, usePageFrontmatter } from 'vuepress/client'
5
+ import type { AutoLinkConfig } from 'vuepress/client'
6
6
  import type {
7
7
  DefaultThemeNormalPageFrontmatter,
8
8
  DefaultThemePageData,
9
- NavLink,
10
9
  } from '../../shared/index.js'
11
10
  import { useThemeLocaleData } from '../composables/index.js'
12
11
  import { resolveEditLink } from '../utils/index.js'
13
12
 
14
- const useEditNavLink = (): ComputedRef<null | NavLink> => {
13
+ const useEditNavLink = (): ComputedRef<null | AutoLinkConfig> => {
15
14
  const themeLocale = useThemeLocaleData()
16
15
  const page = usePageData<DefaultThemePageData>()
17
16
  const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
@@ -94,31 +93,128 @@ const contributors = useContributors()
94
93
  </script>
95
94
 
96
95
  <template>
97
- <footer class="page-meta">
98
- <div v-if="editNavLink" class="meta-item edit-link">
99
- <AutoLink class="meta-item-label" :item="editNavLink" />
100
- </div>
101
-
102
- <div v-if="lastUpdated" class="meta-item last-updated">
103
- <span class="meta-item-label">{{ themeLocale.lastUpdatedText }}: </span>
104
- <ClientOnly>
105
- <span class="meta-item-info">{{ lastUpdated }}</span>
106
- </ClientOnly>
96
+ <footer class="vp-page-meta">
97
+ <div v-if="editNavLink" class="vp-meta-item edit-link">
98
+ <AutoLink class="label" :config="editNavLink">
99
+ <template #before>
100
+ <svg class="icon" viewBox="0 0 1024 1024">
101
+ <g fill="currentColor">
102
+ <path
103
+ d="M430.818 653.65a60.46 60.46 0 0 1-50.96-93.281l71.69-114.012 7.773-10.365L816.038 80.138A60.46 60.46 0 0 1 859.225 62a60.46 60.46 0 0 1 43.186 18.138l43.186 43.186a60.46 60.46 0 0 1 0 86.373L588.879 565.55l-8.637 8.637-117.466 68.234a60.46 60.46 0 0 1-31.958 11.229z"
104
+ />
105
+ <path
106
+ d="M728.802 962H252.891A190.883 190.883 0 0 1 62.008 771.98V296.934a190.883 190.883 0 0 1 190.883-192.61h267.754a60.46 60.46 0 0 1 0 120.92H252.891a69.962 69.962 0 0 0-69.098 69.099V771.98a69.962 69.962 0 0 0 69.098 69.098h475.911A69.962 69.962 0 0 0 797.9 771.98V503.363a60.46 60.46 0 1 1 120.922 0V771.98A190.883 190.883 0 0 1 728.802 962z"
107
+ />
108
+ </g>
109
+ </svg>
110
+ </template>
111
+ </AutoLink>
107
112
  </div>
108
113
 
109
- <div
110
- v-if="contributors && contributors.length"
111
- class="meta-item contributors"
112
- >
113
- <span class="meta-item-label">{{ themeLocale.contributorsText }}: </span>
114
- <span class="meta-item-info">
115
- <template v-for="(contributor, index) in contributors" :key="index">
116
- <span class="contributor" :title="`email: ${contributor.email}`">
117
- {{ contributor.name }}
118
- </span>
119
- <template v-if="index !== contributors.length - 1">, </template>
120
- </template>
121
- </span>
114
+ <div class="vp-meta-item git-info">
115
+ <div v-if="lastUpdated" class="vp-meta-item last-updated">
116
+ <span class="meta-item-label">{{ themeLocale.lastUpdatedText }}: </span>
117
+ <ClientOnly>
118
+ <span class="meta-item-info">{{ lastUpdated }}</span>
119
+ </ClientOnly>
120
+ </div>
121
+
122
+ <div
123
+ v-if="contributors && contributors.length"
124
+ class="vp-meta-item contributors"
125
+ >
126
+ <span class="meta-item-label"
127
+ >{{ themeLocale.contributorsText }}:
128
+ </span>
129
+ <span class="meta-item-info">
130
+ <template v-for="(contributor, index) in contributors" :key="index">
131
+ <span class="contributor" :title="`email: ${contributor.email}`">
132
+ {{ contributor.name }}
133
+ </span>
134
+ <template v-if="index !== contributors.length - 1">, </template>
135
+ </template>
136
+ </span>
137
+ </div>
122
138
  </div>
123
139
  </footer>
124
140
  </template>
141
+
142
+ <style lang="scss">
143
+ @use '../styles/mixins';
144
+ @import '../styles/_variables';
145
+
146
+ .vp-page-meta {
147
+ @include mixins.content_wrapper;
148
+
149
+ display: flex;
150
+ flex-wrap: wrap;
151
+ justify-content: space-between;
152
+
153
+ overflow: auto;
154
+
155
+ padding-top: 0.75rem;
156
+ padding-bottom: 0.75rem;
157
+
158
+ @media print {
159
+ margin: 0 !important;
160
+ padding-inline: 0 !important;
161
+ }
162
+
163
+ @media (max-width: $MQMobile) {
164
+ display: block;
165
+ }
166
+
167
+ .vp-meta-item {
168
+ flex-grow: 1;
169
+
170
+ .vp-meta-label {
171
+ font-weight: 500;
172
+
173
+ &:not(a) {
174
+ color: var(--c-text-lighter);
175
+ }
176
+ }
177
+
178
+ .vp-meta-info {
179
+ color: var(--c-text-quote);
180
+ font-weight: 400;
181
+ }
182
+ }
183
+
184
+ .git-info {
185
+ text-align: end;
186
+ }
187
+
188
+ .edit-link {
189
+ margin-top: 0.25rem;
190
+ margin-bottom: 0.25rem;
191
+ margin-inline-end: 0.5rem;
192
+ font-size: 14px;
193
+
194
+ @media print {
195
+ display: none;
196
+ }
197
+
198
+ .icon {
199
+ position: relative;
200
+ bottom: -0.125em;
201
+
202
+ width: 1em;
203
+ height: 1em;
204
+ margin-inline-end: 0.25em;
205
+ }
206
+ }
207
+
208
+ .last-updated,
209
+ .contributors {
210
+ margin-top: 0.25rem;
211
+ margin-bottom: 0.25rem;
212
+ font-size: 14px;
213
+
214
+ @media (max-width: $MQMobile) {
215
+ font-size: 13px;
216
+ text-align: start;
217
+ }
218
+ }
219
+ }
220
+ </style>
@@ -1,35 +1,53 @@
1
1
  <script setup lang="ts">
2
- import AutoLink from '@theme/AutoLink.vue'
2
+ import { useEventListener } from '@vueuse/core'
3
3
  import { computed } from 'vue'
4
- import type { Router } from 'vue-router'
5
- import { useRoute, useRouter } from 'vue-router'
6
- import { usePageFrontmatter } from 'vuepress/client'
4
+ import {
5
+ AutoLink,
6
+ resolveRoute,
7
+ usePageFrontmatter,
8
+ useRoute,
9
+ } from 'vuepress/client'
10
+ import type { AutoLinkConfig } from 'vuepress/client'
7
11
  import { isPlainObject, isString } from 'vuepress/shared'
8
12
  import type {
9
13
  DefaultThemeNormalPageFrontmatter,
10
- NavLink,
11
14
  ResolvedSidebarItem,
12
15
  } from '../../shared/index.js'
13
- import { useSidebarItems, useThemeLocaleData } from '../composables/index.js'
14
- import { getNavLink } from '../utils/index.js'
16
+ import {
17
+ useNavigate,
18
+ useSidebarItems,
19
+ useThemeLocaleData,
20
+ } from '../composables/index.js'
15
21
 
16
22
  /**
17
23
  * Resolve `prev` or `next` config from frontmatter
18
24
  */
19
25
  const resolveFromFrontmatterConfig = (
20
- router: Router,
21
26
  conf: unknown,
22
- ): null | false | NavLink => {
27
+ current: string,
28
+ ): null | false | AutoLinkConfig => {
23
29
  if (conf === false) {
24
30
  return null
25
31
  }
26
32
 
27
33
  if (isString(conf)) {
28
- return getNavLink(router, conf)
34
+ const { notFound, meta, path } = resolveRoute<{
35
+ title?: string
36
+ }>(conf, current)
37
+
38
+ return notFound
39
+ ? { text: path, link: path }
40
+ : {
41
+ text: meta.title || path,
42
+ link: path,
43
+ }
29
44
  }
30
45
 
31
- if (isPlainObject<NavLink>(conf)) {
32
- return conf
46
+ if (isPlainObject<AutoLinkConfig>(conf)) {
47
+ return {
48
+ ...conf,
49
+ link: resolveRoute(conf.link, current).path,
50
+ }
33
51
  }
34
52
 
35
53
  return false
@@ -42,14 +60,14 @@ const resolveFromSidebarItems = (
42
60
  sidebarItems: ResolvedSidebarItem[],
43
61
  currentPath: string,
44
62
  offset: number,
45
- ): null | NavLink => {
63
+ ): null | AutoLinkConfig => {
46
64
  const index = sidebarItems.findIndex((item) => item.link === currentPath)
47
65
  if (index !== -1) {
48
66
  const targetItem = sidebarItems[index + offset]
49
67
  if (!targetItem?.link) {
50
68
  return null
51
69
  }
52
- return targetItem as NavLink
70
+ return targetItem as AutoLinkConfig
53
71
  }
54
72
 
55
73
  for (const item of sidebarItems) {
@@ -70,13 +88,14 @@ const resolveFromSidebarItems = (
70
88
 
71
89
  const frontmatter = usePageFrontmatter<DefaultThemeNormalPageFrontmatter>()
72
90
  const sidebarItems = useSidebarItems()
91
+ const themeLocale = useThemeLocaleData()
73
92
  const route = useRoute()
74
- const router = useRouter()
93
+ const navigate = useNavigate()
75
94
 
76
95
  const prevNavLink = computed(() => {
77
96
  const prevConfig = resolveFromFrontmatterConfig(
78
- router,
79
97
  frontmatter.value.prev,
98
+ route.path,
80
99
  )
81
100
  if (prevConfig !== false) {
82
101
  return prevConfig
@@ -87,8 +106,8 @@ const prevNavLink = computed(() => {
87
106
 
88
107
  const nextNavLink = computed(() => {
89
108
  const nextConfig = resolveFromFrontmatterConfig(
90
- router,
91
109
  frontmatter.value.next,
110
+ route.path,
92
111
  )
93
112
  if (nextConfig !== false) {
94
113
  return nextConfig
@@ -101,22 +120,109 @@ const navbarLabel = computed(() => {
101
120
  const themeLocale = useThemeLocaleData()
102
121
  return themeLocale.value.pageNavbarLabel ?? 'page navigation'
103
122
  })
123
+
124
+ useEventListener('keydown', (event): void => {
125
+ if (event.altKey)
126
+ if (event.key === 'ArrowRight') {
127
+ if (nextNavLink.value) {
128
+ navigate(nextNavLink.value.link)
129
+ event.preventDefault()
130
+ }
131
+ } else if (event.key === 'ArrowLeft') {
132
+ if (prevNavLink.value) {
133
+ navigate(prevNavLink.value.link)
134
+ event.preventDefault()
135
+ }
136
+ }
137
+ })
104
138
  </script>
105
139
 
106
140
  <template>
107
141
  <nav
108
142
  v-if="prevNavLink || nextNavLink"
109
- class="page-nav"
143
+ class="vp-page-nav"
110
144
  :aria-label="navbarLabel"
111
145
  >
112
- <p class="inner">
113
- <span v-if="prevNavLink" class="prev">
114
- <AutoLink :item="prevNavLink" />
115
- </span>
116
-
117
- <span v-if="nextNavLink" class="next">
118
- <AutoLink :item="nextNavLink" />
119
- </span>
120
- </p>
146
+ <AutoLink v-if="prevNavLink" class="prev" :config="prevNavLink">
147
+ <div class="hint">
148
+ <span class="arrow left" />
149
+ {{ themeLocale.prev ?? 'Prev' }}
150
+ </div>
151
+ <div class="link">
152
+ <span>{{ prevNavLink.text }}</span>
153
+ </div>
154
+ </AutoLink>
155
+
156
+ <AutoLink v-if="nextNavLink" class="next" :config="nextNavLink">
157
+ <div class="hint">
158
+ {{ themeLocale.next ?? 'Next' }}
159
+ <span class="arrow right" />
160
+ </div>
161
+ <div class="link">
162
+ <span>{{ nextNavLink.text }}</span>
163
+ </div>
164
+ </AutoLink>
121
165
  </nav>
122
166
  </template>
167
+
168
+ <style lang="scss">
169
+ @import '../styles/variables';
170
+
171
+ .vp-page-nav {
172
+ display: flex;
173
+ flex-wrap: wrap;
174
+
175
+ max-width: var(--content-width, 740px);
176
+ min-height: 2rem;
177
+ margin-inline: auto;
178
+ margin-top: 0;
179
+ padding-block: 0.5rem;
180
+ padding-inline: 2rem;
181
+ border-top: 1px solid var(--c-border);
182
+
183
+ transition: border-top var(--t-color);
184
+
185
+ @media (max-width: $MQNarrow) {
186
+ padding-inline: 1rem;
187
+ }
188
+
189
+ @media print {
190
+ display: none;
191
+ }
192
+
193
+ padding-top: 1rem;
194
+ padding-bottom: 0;
195
+
196
+ @media print {
197
+ display: none;
198
+ }
199
+
200
+ .route-link {
201
+ display: inline-block;
202
+ flex-grow: 1;
203
+
204
+ margin: 0.25rem;
205
+ padding: 0.25rem 0.5rem;
206
+ border: 1px solid var(--c-border);
207
+ border-radius: 0.25rem;
208
+
209
+ &:hover {
210
+ background: var(--c-bg-light);
211
+ }
212
+
213
+ .hint {
214
+ color: var(--c-text-quote);
215
+ font-size: 0.875rem;
216
+ line-height: 2;
217
+ }
218
+ }
219
+
220
+ .prev {
221
+ text-align: start;
222
+ }
223
+
224
+ .next {
225
+ text-align: end;
226
+ }
227
+ }
228
+ </style>
@@ -1,10 +1,9 @@
1
1
  <script setup lang="ts">
2
- import AutoLink from '@theme/AutoLink.vue'
3
2
  import DropdownTransition from '@theme/DropdownTransition.vue'
4
3
  import { useToggle } from '@vueuse/core'
5
4
  import { computed, nextTick, onBeforeUnmount, toRefs } from 'vue'
6
5
  import type { PropType } from 'vue'
7
- import { useRoute, useRouter } from 'vue-router'
6
+ import { AutoLink, useRoute, useRouter } from 'vuepress/client'
8
7
  import type { ResolvedSidebarItem } from '../../shared/index.js'
9
8
  import { isActiveSidebarItem } from '../utils/index.js'
10
9
 
@@ -57,7 +56,7 @@ onBeforeUnmount(() => {
57
56
 
58
57
  <template>
59
58
  <li>
60
- <AutoLink v-if="item.link" :class="itemClass" :item="item" />
59
+ <AutoLink v-if="item.link" :class="itemClass" :config="item" />
61
60
  <p
62
61
  v-else
63
62
  tabindex="0"