feat(website): drop hash-based router

This commit is contained in:
Simon
2026-02-27 19:46:44 +08:00
parent 5f74f98a97
commit 68d68182e2
28 changed files with 349 additions and 136 deletions

View File

@@ -1,15 +1,21 @@
import { createRoot } from 'react-dom/client'
import { Router } from 'wouter'
import { useHashLocation } from 'wouter/use-hash-location'
import { LanguageProvider } from './i18n/context'
import { default as PagesRouter } from './router'
import './index.css'
// Redirect legacy hash routes (e.g. /#/docs/foo) to clean paths
const { hash } = window.location
if (hash.length > 1 && hash.includes('/')) {
const path = hash.replace(/^#\/?/, '/')
history.replaceState(null, '', '/page-agent' + path)
}
createRoot(document.getElementById('root')!).render(
<LanguageProvider>
<Router hook={useHashLocation}>
<Router base="/page-agent">
<PagesRouter />
</Router>
</LanguageProvider>