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
31 lines
727 B
TypeScript
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;
|