aboutsummaryrefslogtreecommitdiff
path: root/src/app.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.tsx')
-rw-r--r--src/app.tsx39
1 files changed, 25 insertions, 14 deletions
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 (
- <>
- <Navbar />
- <div id="app-main">
- <Router>
- <Route path="/" component={Home} />
- <Route path="/contact" component={Contact} />
- <Route path="/games" component={Games} />
- <Route path="/projects" component={Projects} />
- </Router>
- </div>
- </>
- )
+ const history = hashHistoryAdapter(createHashHistory());
+
+ return (
+ <>
+ <Navbar />
+ <div id="app-main">
+ <Router history={history}>
+ <Route path="/" component={Home} />
+ <Route path="/contact" component={Contact} />
+ <Route path="/games" component={Games} />
+ <Route path="/projects" component={Projects} />
+ </Router>
+ </div>
+ </>
+ )
}