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