Files
dynamicbrain.neuroinf.jp/src/common/XoopsPathRedirect.tsx
T
orrisroot 87c0274bc1 feat: migrate from Create React App to Vite
Rebuild the site on the stack the other converted sites share: Vite 8,
React 19, TypeScript 7, react-router 8, Biome and sanitize.css, with the
site data moved out of the bundle into static-contents/.

- base the database, credits and pico code on cerebellum.neuroinf.jp,
  keeping this site's item types, rankings and menus
- port the MediaWiki pages to function components
- serve all module data from modules/, redirecting the old download and
  /database/file URLs
- tile the plate texture and keep form controls on white
- track page views with GA4
2026-09-14 16:57:14 +09:00

31 lines
727 B
TypeScript

import { Navigate, useLocation } from 'react-router';
import type { MultiLang } from '../config';
import PageNotFound from './lib/PageNotFound';
interface Props {
lang: MultiLang;
}
const getRedirectUrl = (pathname: string): string => {
switch (pathname || '') {
case '/index.php':
return '/';
}
return '';
};
const XoopsPathRedirect = (props: Props) => {
const { lang } = props;
const location = useLocation();
if (location.pathname === '/') {
return null;
}
const url = getRedirectUrl(location.pathname);
if (url === '') {
return <PageNotFound lang={lang} />;
}
return <Navigate to={url} replace />;
};
export default XoopsPathRedirect;