2022-12-26 18:12:04 +03:00
|
|
|
import type { Directions } from 'vue-i18n-routing'
|
|
|
|
import type { LocaleObject } from '#i18n'
|
2022-11-28 12:01:14 +03:00
|
|
|
|
2022-11-30 03:22:35 +03:00
|
|
|
export function setupPageHeader() {
|
2023-01-04 16:57:12 +03:00
|
|
|
const { locale, locales, t } = useI18n()
|
2023-01-10 23:35:34 +03:00
|
|
|
const colorMode = useColorMode()
|
2023-01-08 14:17:09 +03:00
|
|
|
const buildInfo = useBuildInfo()
|
2022-11-30 03:22:35 +03:00
|
|
|
|
2023-01-04 16:57:12 +03:00
|
|
|
const localeMap = (locales.value as LocaleObject[]).reduce((acc, l) => {
|
2022-12-28 00:04:52 +03:00
|
|
|
acc[l.code!] = l.dir ?? 'auto'
|
2022-12-26 18:12:04 +03:00
|
|
|
return acc
|
|
|
|
}, {} as Record<string, Directions>)
|
|
|
|
|
2022-11-30 01:49:25 +03:00
|
|
|
useHeadFixed({
|
2022-11-30 00:13:43 +03:00
|
|
|
htmlAttrs: {
|
2023-01-04 16:57:12 +03:00
|
|
|
lang: () => locale.value,
|
|
|
|
dir: () => localeMap[locale.value] ?? 'auto',
|
2022-11-30 00:13:43 +03:00
|
|
|
},
|
2023-01-04 16:26:30 +03:00
|
|
|
titleTemplate: (title) => {
|
|
|
|
let titleTemplate = title ? `${title} | ` : ''
|
2023-01-04 16:57:12 +03:00
|
|
|
titleTemplate += t('app_name')
|
2023-01-04 16:26:30 +03:00
|
|
|
if (buildInfo.env !== 'release')
|
|
|
|
titleTemplate += ` (${buildInfo.env})`
|
|
|
|
return titleTemplate
|
|
|
|
},
|
2023-01-06 15:48:43 +03:00
|
|
|
link: process.client && useRuntimeConfig().public.pwaEnabled
|
|
|
|
? () => [{
|
|
|
|
key: 'webmanifest',
|
|
|
|
rel: 'manifest',
|
2023-01-10 23:35:34 +03:00
|
|
|
href: `/manifest-${locale.value}${colorMode.value === 'dark' ? '-dark' : ''}.webmanifest`,
|
2023-01-06 15:48:43 +03:00
|
|
|
}]
|
|
|
|
: [],
|
2022-11-28 12:01:14 +03:00
|
|
|
})
|
|
|
|
}
|