Skip to content

Commit

Permalink
refactor: switch from hash to browser routing
Browse files Browse the repository at this point in the history
- Remove hash-based routing in favor of cleaner URLs
- Add 404.html redirect for GitHub Pages client-side routing support
  • Loading branch information
ligsnf committed Dec 23, 2024
1 parent bc65b20 commit f7731d4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
19 changes: 19 additions & 0 deletions public/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Redirecting...</title>
<script>
// Get the current path excluding the base path
const path = window.location.pathname.replace('/monash-grades-calculator', '');
// Redirect to the base URL while preserving the path after it
window.location.href = '/monash-grades-calculator/' +
(path.startsWith('/') ? path.slice(1) : path) +
window.location.search +
window.location.hash;
</script>
</head>
<body>
Redirecting...
</body>
</html>
6 changes: 5 additions & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { StrictMode } from 'react'
import ReactDOM from 'react-dom/client'
import './index.css'
import { RouterProvider, createRouter } from '@tanstack/react-router'
import { RouterProvider, createRouter, createBrowserHistory } from '@tanstack/react-router'
import { ThemeProvider } from "@/components/theme/theme-provider"

// Import the generated route tree
import { routeTree } from './routeTree.gen'

// Create browser history
const browserHistory = createBrowserHistory()

// Create a new router instance
const router = createRouter({
routeTree,
basepath: "/monash-grades-calculator/",
history: browserHistory,
})

// Register the router instance for type safety
Expand Down

0 comments on commit f7731d4

Please sign in to comment.