From 455382af8a51b82e84b10fc125a3e7fc2e98bd41 Mon Sep 17 00:00:00 2001 From: Stanisław Zagórowski Date: Thu, 17 Aug 2023 14:12:03 +0200 Subject: use hash routing --- src/app.tsx | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'src/app.tsx') diff --git a/src/app.tsx b/src/app.tsx index 771b84a..5ba8e6f 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -3,21 +3,32 @@ import { Navbar } from './components/navbar' import Contact from './pages/contact'; import Games from './pages/games'; import Home from './pages/home' -import { Router, Route } from 'preact-router'; +import { Router, Route, CustomHistory } from 'preact-router'; import Projects from './pages/projects'; +import { HashHistory, createHashHistory } from 'history'; +const hashHistoryAdapter = (hashHistory: HashHistory): CustomHistory => { + return { + listen: (callback) => hashHistory.listen(({ location }) => callback(location)), + location: hashHistory.location, + push: hashHistory.push, + replace: hashHistory.replace + }; +}; export function App() { - return ( - <> - -
- - - - - - -
- - ) + const history = hashHistoryAdapter(createHashHistory()); + + return ( + <> + +
+ + + + + + +
+ + ) } -- cgit v1.3.1