fix: doc path (#5393)

This commit is contained in:
Archer
2025-08-05 23:20:39 +08:00
committed by GitHub
parent 254680bfdf
commit e5c91b7fae
36 changed files with 1149 additions and 1664 deletions

View File

@@ -29,16 +29,16 @@ export default function NotFound() {
const router = useRouter();
useEffect(() => {
const tryRedirect = async () => {
(async () => {
if (exactMap[pathname]) {
router.replace(exactMap[pathname]);
window.location.replace(exactMap[pathname]);
return;
}
for (const [oldPrefix, newPrefix] of Object.entries(prefixMap)) {
if (pathname.startsWith(oldPrefix)) {
const rest = pathname.slice(oldPrefix.length);
router.replace(newPrefix + rest);
window.location.replace(newPrefix + rest);
return;
}
}
@@ -54,17 +54,15 @@ export default function NotFound() {
if (validPage) {
console.log('validPage', validPage);
router.replace(validPage);
window.location.replace(validPage);
return;
}
} catch (e) {
console.warn('meta.json fallback failed:', e);
}
router.replace(fallbackRedirect);
};
tryRedirect();
window.location.replace(fallbackRedirect);
})();
}, [pathname, router]);
return null;