Skip to content

Commit 2a22f3c

Browse files
Merge pull request #90 from digipolisantwerp/bugfix/reload-404-fix
Added fix for an unwanted 404 page when the styleguide was reloaded o…
2 parents 2e45026 + a8fd41a commit 2a22f3c

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
66

77
## Unreleased
88

9+
### Fixed
10+
- `core` Fixed an issue where an unwanted 404 was shown when the styleguide was reloaded on GitHub pages.
11+
912

1013
## [1.0.5] - 2018-11-13
1114

angular.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"tsConfig": "styleguide/tsconfig.app.json",
2121
"assets": [
2222
"styleguide/favicon.ico",
23-
"styleguide/assets"
23+
"styleguide/assets",
24+
"styleguide/404.html"
2425
],
2526
"styles": [
2627
"styleguide/styles.scss",
@@ -87,7 +88,8 @@
8788
"scripts": [],
8889
"assets": [
8990
"styleguide/favicon.ico",
90-
"styleguide/assets"
91+
"styleguide/assets",
92+
"styleguide/404.html"
9193
]
9294
}
9395
},

styleguide/404.html

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Acpaas UI | Angular Modules</title>
6+
<script>
7+
// Store the URL the user was trying to access when receiving the 404.
8+
sessionStorage.redirect = location.href;
9+
</script>
10+
11+
<!-- Immediately redirect to the base URL so we can use the SPA routing. -->
12+
<meta http-equiv="refresh" content="0;URL='/'"></meta>
13+
</head>
14+
<body>
15+
<!-- IE required at least 512 bytes of data to show non-default 404. -->
16+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
17+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
18+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
19+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
20+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
21+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
22+
</body>
23+
</html>

styleguide/index.html

+17
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@
1515

1616
</head>
1717
<body class="has-header has-navigation">
18+
<!-- Github Pages hack to allow SPA refresh without receiving 404. -->
19+
<script>
20+
(function () {
21+
// Retrieve the URL the user was trying to access when receiving the 404.
22+
var redirect = sessionStorage.redirect;
23+
24+
// Remove the URL from sessionStorage.
25+
delete sessionStorage.redirect;
26+
27+
// Check if we actually need to redirect.
28+
if (redirect && redirect != location.href) {
29+
// We need to redirect to the URL the user was trying to access.
30+
history.replaceState(null, null, redirect);
31+
}
32+
})();
33+
</script>
34+
<!-- /Github Pages hack. -->
1835
<guide-root></guide-root>
1936
</body>
2037
</html>

0 commit comments

Comments
 (0)