Skip to content

Added fix for an unwanted 404 page when the styleguide was reloaded o… #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

## Unreleased

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


## [1.0.5] - 2018-11-13

Expand Down
6 changes: 4 additions & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"tsConfig": "styleguide/tsconfig.app.json",
"assets": [
"styleguide/favicon.ico",
"styleguide/assets"
"styleguide/assets",
"styleguide/404.html"
],
"styles": [
"styleguide/styles.scss",
Expand Down Expand Up @@ -87,7 +88,8 @@
"scripts": [],
"assets": [
"styleguide/favicon.ico",
"styleguide/assets"
"styleguide/assets",
"styleguide/404.html"
]
}
},
Expand Down
23 changes: 23 additions & 0 deletions styleguide/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Acpaas UI | Angular Modules</title>
<script>
// Store the URL the user was trying to access when receiving the 404.
sessionStorage.redirect = location.href;
</script>

<!-- Immediately redirect to the base URL so we can use the SPA routing. -->
<meta http-equiv="refresh" content="0;URL='/'"></meta>
</head>
<body>
<!-- IE required at least 512 bytes of data to show non-default 404. -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😲

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</body>
</html>
17 changes: 17 additions & 0 deletions styleguide/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@

</head>
<body class="has-header has-navigation">
<!-- Github Pages hack to allow SPA refresh without receiving 404. -->
<script>
(function () {
// Retrieve the URL the user was trying to access when receiving the 404.
var redirect = sessionStorage.redirect;

// Remove the URL from sessionStorage.
delete sessionStorage.redirect;

// Check if we actually need to redirect.
if (redirect && redirect != location.href) {
// We need to redirect to the URL the user was trying to access.
history.replaceState(null, null, redirect);
}
})();
</script>
<!-- /Github Pages hack. -->
<guide-root></guide-root>
</body>
</html>