Skip to content

Commit aea8d91

Browse files
fix: enable direct URL navigation on GitHub Pages
Add 404.html redirect trick so deep links resolve correctly in the SPA. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 41d92f3 commit aea8d91

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
5+
<script>
6+
(function () {
7+
var p = new URLSearchParams(window.location.search).get('p');
8+
if (p) window.history.replaceState(null, '', decodeURIComponent(p));
9+
})();
10+
</script>
511
<link rel="icon" type="image/png" href="/images/fav.png" />
612
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
713
<title>const correctness;</title> </head>

public/404.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8" />
5+
<script>
6+
// GitHub Pages SPA redirect: encode the path into the query string and
7+
// redirect to index.html, which will restore it via the script below.
8+
var l = window.location;
9+
l.replace(
10+
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
11+
l.pathname.split('/').slice(0, 1).join('/') +
12+
'/?p=' + encodeURIComponent(l.pathname + l.search) +
13+
(l.hash || '')
14+
);
15+
</script>
16+
</head>
17+
</html>

0 commit comments

Comments
 (0)