Jiali9's picture
Publish Affect-Atlas manuscript, figures, and demo source
891fa77 verified
Raw History Blame Contribute Delete
1.54 kB
import { HeadContent, Scripts, createRootRoute } from '@tanstack/react-router'
import { useTranslation } from 'react-i18next'
import { useEffect } from 'react'
import appCss from '@workspace/ui/globals.css?url'
import i18n from '../i18n'
export const Route = createRootRoute({
head: () => ({
meta: [
{ charSet: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ title: i18n.t('common.pageTitle') },
{ name: 'description', content: i18n.t('common.pageDescription') },
{ name: 'robots', content: 'noindex, nofollow' },
],
links: [{ rel: 'stylesheet', href: appCss }],
}),
notFoundComponent: NotFoundPage,
shellComponent: RootDocument,
})
function NotFoundPage() {
const { t } = useTranslation()
return <main className="main-content" style={{ paddingTop: 60 }}><h1>{t('common.error')}</h1><p>{t('common.notFound')}</p><a href="/">{t('common.backHome')}</a></main>
}
function RootDocument({ children }: { children: React.ReactNode }) {
const { t, i18n: instance } = useTranslation()
const lang = instance.resolvedLanguage === 'zh' ? 'zh-CN' : 'en'
const title = t('common.pageTitle')
const description = t('common.pageDescription')
useEffect(() => {
document.title = title
document.querySelector('meta[name="description"]')?.setAttribute('content', description)
}, [title, description])
return <html lang={lang} dir="ltr"><head><HeadContent/></head><body>{children}<Scripts/></body></html>
}