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

{t('common.error')}

{t('common.notFound')}

{t('common.backHome')}
} 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 {children} }