Skip to content

Commit 514b11d

Browse files
committed
restore gh-pages spa workaround
1 parent eb8b977 commit 514b11d

File tree

5 files changed

+126
-5
lines changed

5 files changed

+126
-5
lines changed

docs/404.html

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>RoboCon</title>
6+
<script type="text/javascript">
7+
// Single Page Apps for GitHub Pages
8+
// MIT License
9+
// https://github.com/rafgraph/spa-github-pages
10+
// This script takes the current url and converts the path and query
11+
// string into just a query string, and then redirects the browser
12+
// to the new url with only a query string and hash fragment,
13+
// e.g. https://www.foo.tld/one/two?a=b&c=d#qwe, becomes
14+
// https://www.foo.tld/?/one/two&a=b~and~c=d#qwe
15+
// Note: this 404.html file must be at least 512 bytes for it to work
16+
// with Internet Explorer (it is currently > 512 bytes)
17+
18+
// If you're creating a Project Pages site and NOT using a custom domain,
19+
// then set pathSegmentsToKeep to 1 (enterprise users may need to set it to > 1).
20+
// This way the code will only replace the route part of the path, and not
21+
// the real directory in which the app resides, for example:
22+
// https://username.github.io/repo-name/one/two?a=b&c=d#qwe becomes
23+
// https://username.github.io/repo-name/?/one/two&a=b~and~c=d#qwe
24+
// Otherwise, leave pathSegmentsToKeep as 0.
25+
var pathSegmentsToKeep = 0;
26+
27+
var l = window.location;
28+
l.replace(
29+
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
30+
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
31+
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
32+
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
33+
l.hash
34+
);
35+
36+
</script>
37+
</head>
38+
<body>
39+
</body>
40+
</html>

docs/CNAME

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/index.html

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
66
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
77
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
8-
<title>RoboCon</title>
8+
<title>RoboCon - The Robot Framework Conference</title>
99
<meta
1010
name="description"
1111
content="Automation testing community event - Online and IRL!"
@@ -54,7 +54,28 @@
5454
};
5555
</script>
5656

57-
<title>RoboCon 2025</title>
57+
<script type="text/javascript">
58+
// Single Page Apps for GitHub Pages
59+
// MIT License
60+
// https://github.com/rafgraph/spa-github-pages
61+
// This script checks to see if a redirect is present in the query string,
62+
// converts it back into the correct url and adds it to the
63+
// browser's history using window.history.replaceState(...),
64+
// which won't cause the browser to attempt to load the new url.
65+
// When the single page app is loaded further down in this file,
66+
// the correct url will be waiting in the browser's history for
67+
// the single page app to route accordingly.
68+
(function(l) {
69+
if (l.search[1] === '/' ) {
70+
var decoded = l.search.slice(1).split('&').map(function(s) {
71+
return s.replace(/~and~/g, '&')
72+
}).join('?');
73+
window.history.replaceState(null, null,
74+
l.pathname.slice(0, -1) + decoded + l.hash
75+
);
76+
}
77+
}(window.location))
78+
</script>
5879
<script type="module" crossorigin src="/assets/index-DD2Afd_L.js"></script>
5980
<link rel="stylesheet" crossorigin href="/assets/index-18GR-2-1.css">
6081
</head>

index.html

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
66
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
77
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
8-
<title>RoboCon</title>
8+
<title>RoboCon - The Robot Framework Conference</title>
99
<meta
1010
name="description"
1111
content="Automation testing community event - Online and IRL!"
@@ -54,7 +54,28 @@
5454
};
5555
</script>
5656

57-
<title>RoboCon 2025</title>
57+
<script type="text/javascript">
58+
// Single Page Apps for GitHub Pages
59+
// MIT License
60+
// https://github.com/rafgraph/spa-github-pages
61+
// This script checks to see if a redirect is present in the query string,
62+
// converts it back into the correct url and adds it to the
63+
// browser's history using window.history.replaceState(...),
64+
// which won't cause the browser to attempt to load the new url.
65+
// When the single page app is loaded further down in this file,
66+
// the correct url will be waiting in the browser's history for
67+
// the single page app to route accordingly.
68+
(function(l) {
69+
if (l.search[1] === '/' ) {
70+
var decoded = l.search.slice(1).split('&').map(function(s) {
71+
return s.replace(/~and~/g, '&')
72+
}).join('?');
73+
window.history.replaceState(null, null,
74+
l.pathname.slice(0, -1) + decoded + l.hash
75+
);
76+
}
77+
}(window.location))
78+
</script>
5879
</head>
5980
<body>
6081
<div id="app"></div>

public/404.html

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>RoboCon</title>
6+
<script type="text/javascript">
7+
// Single Page Apps for GitHub Pages
8+
// MIT License
9+
// https://github.com/rafgraph/spa-github-pages
10+
// This script takes the current url and converts the path and query
11+
// string into just a query string, and then redirects the browser
12+
// to the new url with only a query string and hash fragment,
13+
// e.g. https://www.foo.tld/one/two?a=b&c=d#qwe, becomes
14+
// https://www.foo.tld/?/one/two&a=b~and~c=d#qwe
15+
// Note: this 404.html file must be at least 512 bytes for it to work
16+
// with Internet Explorer (it is currently > 512 bytes)
17+
18+
// If you're creating a Project Pages site and NOT using a custom domain,
19+
// then set pathSegmentsToKeep to 1 (enterprise users may need to set it to > 1).
20+
// This way the code will only replace the route part of the path, and not
21+
// the real directory in which the app resides, for example:
22+
// https://username.github.io/repo-name/one/two?a=b&c=d#qwe becomes
23+
// https://username.github.io/repo-name/?/one/two&a=b~and~c=d#qwe
24+
// Otherwise, leave pathSegmentsToKeep as 0.
25+
var pathSegmentsToKeep = 0;
26+
27+
var l = window.location;
28+
l.replace(
29+
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
30+
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
31+
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
32+
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
33+
l.hash
34+
);
35+
36+
</script>
37+
</head>
38+
<body>
39+
</body>
40+
</html>

0 commit comments

Comments
 (0)