mirror of
https://github.com/elk-zone/elk
synced 2024-11-27 22:38:11 +09:00
34 lines
967 B
TypeScript
34 lines
967 B
TypeScript
import type { Directions } from 'vue-i18n-routing'
|
|
import type { LocaleObject } from '#i18n'
|
|
|
|
export function setupPageHeader() {
|
|
const { locale, locales, t } = useI18n()
|
|
const buildInfo = useBuildInfo()
|
|
|
|
const localeMap = (locales.value as LocaleObject[]).reduce((acc, l) => {
|
|
acc[l.code!] = l.dir ?? 'auto'
|
|
return acc
|
|
}, {} as Record<string, Directions>)
|
|
|
|
useHeadFixed({
|
|
htmlAttrs: {
|
|
lang: () => locale.value,
|
|
dir: () => localeMap[locale.value] ?? 'auto',
|
|
},
|
|
titleTemplate: (title) => {
|
|
let titleTemplate = title ? `${title} | ` : ''
|
|
titleTemplate += t('app_name')
|
|
if (buildInfo.env !== 'release')
|
|
titleTemplate += ` (${buildInfo.env})`
|
|
return titleTemplate
|
|
},
|
|
link: process.client && useRuntimeConfig().public.pwaEnabled
|
|
? () => [{
|
|
key: 'webmanifest',
|
|
rel: 'manifest',
|
|
href: `/manifest-${locale.value}.webmanifest`,
|
|
}]
|
|
: [],
|
|
})
|
|
}
|