Files
pupil.brain.riken.jp/src/common/XoopsPathRedirect.tsx
T
orrisroot c94d272342 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 code on cerebellum.neuroinf.jp and keep the pupil
  platform's table layout, about page and menu
- load the Flickr badge feed as JSONP without extra libraries
- serve the XooNIps data from modules/xoonips/, redirecting the old
  download and /database/file URLs
- restate the column widths as border-box totals and keep form controls
  on white
- track page views with GA4
2026-09-14 17:14:32 +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;