blob: ed9bb2cb3cae243058214e05a1afbb61b582a702 (
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
|
import { createHashHistory } from "history";
import { h, VNode } from "preact";
import Router, { route, Route } from "preact-router";
import { useEffect } from "preact/hooks";
import { AccountPage, RegistrationPage } from "./home/index.js";
import { PublicHistoriesPage } from "./home/PublicHistoriesPage.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>;
}
|