File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<script setup lang="ts">
2+ import type { Directions , LocaleObject } from ' @nuxtjs/i18n'
23import { useEventListener } from ' @vueuse/core'
34
45const route = useRoute ()
56const router = useRouter ()
7+ const { locale, locales, t } = useI18n ()
68
79// Initialize accent color before hydration to prevent flash
810initAccentOnPrehydrate ()
@@ -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
1936function handleGlobalKeydown(e : KeyboardEvent ) {
2037 const target = e .target as HTMLElement
You can’t perform that action at this time.
0 commit comments