@@ -3,7 +3,7 @@ import AutoLink from '@theme/AutoLink.vue'
3
3
import NavbarDropdown from ' @theme/NavbarDropdown.vue'
4
4
import { useRouteLocale , useSiteLocaleData } from ' @vuepress/client'
5
5
import { isLinkHttp , isString } from ' @vuepress/shared'
6
- import { computed } from ' vue'
6
+ import { computed , onMounted , ref } from ' vue'
7
7
import type { ComputedRef } from ' vue'
8
8
import { useRouter } from ' vue-router'
9
9
import type {
@@ -143,6 +143,7 @@ const useNavbarConfig = (): ComputedRef<ResolvedNavbarItem[]> => {
143
143
return computed (() => (themeLocale .value .navbar || []).map (resolveNavbarItem ))
144
144
}
145
145
146
+ const isMobile = ref (false )
146
147
const navbarConfig = useNavbarConfig ()
147
148
const navbarSelectLanguage = useNavbarSelectLanguage ()
148
149
const navbarRepo = useNavbarRepo ()
@@ -151,12 +152,34 @@ const navbarLinks = computed(() => [
151
152
... navbarSelectLanguage .value ,
152
153
... navbarRepo .value ,
153
154
])
155
+
156
+ // avoid overlapping of long title and long navbar links
157
+ onMounted (() => {
158
+ // TODO: migrate to css var
159
+ // refer to _variables.scss
160
+ const MOBILE_DESKTOP_BREAKPOINT = 719
161
+
162
+ const handleMobile = (): void => {
163
+ if (window .innerWidth < MOBILE_DESKTOP_BREAKPOINT ) {
164
+ isMobile .value = true
165
+ } else {
166
+ isMobile .value = false
167
+ }
168
+ }
169
+ handleMobile ()
170
+ window .addEventListener (' resize' , handleMobile , false )
171
+ window .addEventListener (' orientationchange' , handleMobile , false )
172
+ })
154
173
</script >
155
174
156
175
<template >
157
176
<nav v-if =" navbarLinks.length" class =" navbar-items" >
158
177
<div v-for =" item in navbarLinks" :key =" item.text" class =" navbar-item" >
159
- <NavbarDropdown v-if =" item.children" :item =" item" />
178
+ <NavbarDropdown
179
+ v-if =" item.children"
180
+ :item =" item"
181
+ :class =" isMobile ? 'mobile' : ''"
182
+ />
160
183
<AutoLink v-else :item =" item" />
161
184
</div >
162
185
</nav >
0 commit comments