Skip to content

Commit de5ceb0

Browse files
committed
chore: add land and dir to html element
1 parent 0b7010c commit de5ceb0

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

app/app.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<script setup lang="ts">
2+
import type { Directions, LocaleObject } from '@nuxtjs/i18n'
23
import { useEventListener } from '@vueuse/core'
34
45
const route = useRoute()
56
const router = useRouter()
7+
const { locale, locales, t } = useI18n()
68
79
// Initialize accent color before hydration to prevent flash
810
initAccentOnPrehydrate()
@@ -15,6 +17,21 @@ useHead({
1517
},
1618
})
1719
20+
const localeMap = (locales.value as LocaleObject[]).reduce(
21+
(acc, l) => {
22+
acc[l.code!] = l.dir ?? 'ltr'
23+
return acc
24+
},
25+
{} as Record<string, Directions>,
26+
)
27+
28+
useHydratedHead({
29+
htmlAttrs: {
30+
lang: () => locale.value,
31+
dir: () => localeMap[locale.value] ?? 'ltr',
32+
},
33+
})
34+
1835
// Global keyboard shortcut: "/" focuses search or navigates to search page
1936
function handleGlobalKeydown(e: KeyboardEvent) {
2037
const target = e.target as HTMLElement

0 commit comments

Comments
 (0)