Skip to content

Commit

Permalink
feat: make 404 redirect to game w/ url info
Browse files Browse the repository at this point in the history
  • Loading branch information
Stan-Stani committed Jan 16, 2024
1 parent 49c6fb1 commit 5a71d84
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 27 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + TS</title>
<title>minigames</title>
</head>

<body>
Expand Down
42 changes: 16 additions & 26 deletions public/404.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta
http-equiv="cache-control"
content="no-cache, no-store, must-revalidate"
/>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + TS</title>
</head>

<body>
TEST
<div class="take-up-viewport shelf-flex">
<div id="info" class="flex-grow-and-shrink">
<div id="log"></div>
</div>
<div id="game-wrapper" class="flex-grow-and-shrink">
<canvas id="game" class="flex-end"></canvas>
</div>
</div>

<script type="module" src="/src/main.ts"></script>
</body>
<head>
<title>Loading...</title>
<script type="text/javascript">
// When the 404 page loads
document.addEventListener('DOMContentLoaded', function() {
// Get the current URL
var currentUrl = window.location.href;

// Redirect to the game page and pass the original URL as a query parameter
window.location.href = '/minigames?' + encodeURIComponent(currentUrl.split('/')[currentUrl.length - 1]);
});
</script>
</head>
<body>
<p>Just a moment...</p>
</body>
</html>

0 comments on commit 5a71d84

Please sign in to comment.