Skip to content

Commit 759d7ba

Browse files
committed
Fix 404 and maybe pdf
1 parent 46e3556 commit 759d7ba

File tree

6 files changed

+94
-0
lines changed

6 files changed

+94
-0
lines changed

docs/404.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Single Page Apps for GitHub Pages</title>
6+
<script type="text/javascript">
7+
// Single Page Apps for GitHub Pages
8+
// MIT License - https://github.com/rafgraph/spa-github-pages
9+
// This script takes the current url and converts the path and query
10+
// string into just a query string, and then redirects the browser
11+
// to the new url with only a query string and hash fragment.
12+
var pathSegmentsToKeep = 0;
13+
14+
var l = window.location;
15+
l.replace(
16+
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
17+
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
18+
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
19+
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
20+
l.hash
21+
);
22+
</script>
23+
</head>
24+
<body>
25+
</body>
26+
</html>
File renamed without changes.

docs/index.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,26 @@
1111
</head>
1212
<body>
1313
<div id="app"></div>
14+
<script type="text/javascript">
15+
// Single Page Apps for GitHub Pages
16+
// MIT License - https://github.com/rafgraph/spa-github-pages
17+
// This script checks to see if a redirect is present in the query string,
18+
// converts it back into the correct url and adds it to the
19+
// browser's history using window.history.replaceState(...),
20+
// which won't cause the browser to attempt to load the new url.
21+
// When the single page app is loaded further down in this file,
22+
// the correct url will be waiting in the browser's history for
23+
// the single page app to route accordingly.
24+
(function(l) {
25+
if (l.search[1] === '/' ) {
26+
var decoded = l.search.slice(1).split('&').map(function(s) {
27+
return s.replace(/~and~/g, '&')
28+
}).join('?');
29+
window.history.replaceState(null, null,
30+
l.pathname.slice(0, -1) + decoded + l.hash
31+
);
32+
}
33+
}(window.location))
34+
</script>
1435
</body>
1536
</html>

index.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,26 @@
1010
<body>
1111
<div id="app"></div>
1212
<script type="module" src="/src/main.ts"></script>
13+
<script type="text/javascript">
14+
// Single Page Apps for GitHub Pages
15+
// MIT License - https://github.com/rafgraph/spa-github-pages
16+
// This script checks to see if a redirect is present in the query string,
17+
// converts it back into the correct url and adds it to the
18+
// browser's history using window.history.replaceState(...),
19+
// which won't cause the browser to attempt to load the new url.
20+
// When the single page app is loaded further down in this file,
21+
// the correct url will be waiting in the browser's history for
22+
// the single page app to route accordingly.
23+
(function(l) {
24+
if (l.search[1] === '/' ) {
25+
var decoded = l.search.slice(1).split('&').map(function(s) {
26+
return s.replace(/~and~/g, '&')
27+
}).join('?');
28+
window.history.replaceState(null, null,
29+
l.pathname.slice(0, -1) + decoded + l.hash
30+
);
31+
}
32+
}(window.location))
33+
</script>
1334
</body>
1435
</html>

public/404.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Single Page Apps for GitHub Pages</title>
6+
<script type="text/javascript">
7+
// Single Page Apps for GitHub Pages
8+
// MIT License - https://github.com/rafgraph/spa-github-pages
9+
// This script takes the current url and converts the path and query
10+
// string into just a query string, and then redirects the browser
11+
// to the new url with only a query string and hash fragment.
12+
var pathSegmentsToKeep = 0;
13+
14+
var l = window.location;
15+
l.replace(
16+
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
17+
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
18+
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
19+
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
20+
l.hash
21+
);
22+
</script>
23+
</head>
24+
<body>
25+
</body>
26+
</html>
323 KB
Binary file not shown.

0 commit comments

Comments
 (0)