2022-11-30 03:22:35 +03:00
|
|
|
import { APP_NAME, STORAGE_KEY_LANG } from '~/constants'
|
2022-11-28 12:01:14 +03:00
|
|
|
|
|
|
|
const isDev = process.dev
|
|
|
|
const isPreview = window.location.hostname.includes('deploy-preview')
|
|
|
|
|
2022-11-30 03:22:35 +03:00
|
|
|
export function setupPageHeader() {
|
2022-11-30 00:13:43 +03:00
|
|
|
const i18n = useI18n()
|
2022-11-30 03:22:35 +03:00
|
|
|
|
2022-11-30 01:49:25 +03:00
|
|
|
useHeadFixed({
|
2022-11-30 00:13:43 +03:00
|
|
|
htmlAttrs: {
|
|
|
|
lang: () => i18n.locale.value,
|
|
|
|
},
|
2022-11-28 12:01:14 +03:00
|
|
|
titleTemplate: title => `${title ? `${title} | ` : ''}${APP_NAME}${isDev ? ' (dev)' : isPreview ? ' (preview)' : ''}`,
|
2022-11-29 16:38:01 +03:00
|
|
|
bodyAttrs: {
|
|
|
|
class: 'overflow-x-hidden',
|
|
|
|
},
|
2022-11-28 12:01:14 +03:00
|
|
|
link: [
|
|
|
|
{ rel: 'icon', type: 'image/svg+png', href: isDev || isPreview ? '/favicon-dev.png' : '/favicon.png' },
|
|
|
|
],
|
|
|
|
})
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-unused-expressions
|
|
|
|
isDark.value
|
|
|
|
}
|
2022-11-30 03:22:35 +03:00
|
|
|
|
|
|
|
export async function setupI18n() {
|
|
|
|
// TODO: guess user language
|
|
|
|
|
|
|
|
const { locale, setLocale } = useI18n()
|
|
|
|
const localeStorage = useLocalStorage(STORAGE_KEY_LANG, locale.value)
|
|
|
|
|
|
|
|
if (localeStorage.value !== locale.value)
|
|
|
|
await setLocale(localeStorage.value)
|
|
|
|
|
|
|
|
watchEffect(() => {
|
|
|
|
localeStorage.value = locale.value
|
|
|
|
})
|
|
|
|
}
|