blob: cfc6a4bd89b115ec57a6076d4e9c84ef56a1a9b0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
import { createHashHistory } from "history";
import { h, VNode } from "preact";
import Router, { route, Route } from "preact-router";
import { useEffect } from "preact/hooks";
import {
AccountPage,
PublicHistoriesPage,
RegistrationPage,
} from "./home/index.js";
export function Routing(): VNode {
const history = createHashHistory();
return (
<Router history={history}>
<Route path="/public-accounts" component={PublicHistoriesPage} />
<Route path="/register" component={RegistrationPage} />
<Route path="/account/:id*" component={AccountPage} />
<Route default component={Redirect} to="/account" />
</Router>
);
}
function Redirect({ to }: { to: string }): VNode {
useEffect(() => {
route(to, true);
}, []);
return <div>being redirected to {to}</div>;
}
|