import { usePageData, withBase } from '@rspress/runtime'; export function NotFoundLayout() { const { siteData, page } = usePageData(); const defaultLang = siteData.lang; const defaultVersion = siteData.multiVersion.default; // Consider the existing sites include the defaultLang in some links, such as '/zh/guide/quick-start' // We need to redirect them to '/guide/quick-start' // In the meanwhile, we will not show the 404 page for the user experience if ( defaultLang && typeof window !== 'undefined' && location.pathname.includes(`/${defaultLang}/`) ) { const redirectUrl = location.pathname.replace(`/${defaultLang}/`, '/'); window.location.replace(redirectUrl); return <>>; } let root = '/'; if (defaultVersion && page.version !== defaultVersion) { root += `${page.version}/`; } if (defaultLang && page.lang !== defaultLang) { root += `${page.lang}/`; } // The 404 page content return (
); }