Re-add custom page_view event
Some checks are pending
Deploy to GitHub Pages / build (push) Waiting to run
Deploy to GitHub Pages / deploy (push) Blocked by required conditions

This commit is contained in:
Misode
2025-01-04 20:42:04 +01:00
parent e52e6a791c
commit a97c21d9de
4 changed files with 19 additions and 2 deletions

View File

@@ -1,13 +1,22 @@
import type { RouterOnChangeArgs } from 'preact-router'
import { Router } from 'preact-router'
import '../styles/global.css'
import '../styles/nodes.css'
import { Analytics } from './Analytics.js'
import { Header } from './components/index.js'
import { Changelog, Convert, Customized, Generator, Generators, Guide, Guides, Home, LegacyPartners, Partners, Sounds, Transformation, Versions, WhatsNew, Worldgen } from './pages/index.js'
import { cleanUrl } from './Utils.js'
export function App() {
const changeRoute = (e: RouterOnChangeArgs) => {
window.dispatchEvent(new CustomEvent('replacestate'))
// Needs a timeout to ensure the title is set correctly
setTimeout(() => Analytics.pageview(cleanUrl(e.url)))
}
return <>
<Header />
<Router>
<Router onChange={changeRoute}>
<Home path="/" />
<Generators path="/generators" />
<Worldgen path="/worldgen" />