Skip to content

Commit 6efb023

Browse files
committed
Fix demo build
1 parent 0d061d1 commit 6efb023

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

.github/workflows/deploy-demo.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ jobs:
3232
- name: Build application demo version 💪
3333
run: |
3434
ng build --configuration=demo --localize
35-
mv dist-demo/browser/en/* dist-demo/browser
36-
rm -r dist-demo/browser/en
35+
# create an index.html file for the demo redirecting to the english version
36+
echo '<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=/en/index.html"></head></html>' > dist-demo/browser/index.html
37+
# copy 404 error page
38+
cp src/404.demo.html dist-demo/browser/404.html
3739
3840
- name: Deploy demo application 🚀
3941
uses: JamesIves/[email protected]

src/404.demo.html

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8" />
6+
<title>Argus</title>
7+
<link rel="icon" type="image/x-icon" href="assets/images/argus-eye-16.png">
8+
<base href="/">
9+
10+
<script>
11+
// Store the URL the user was trying to access when receiving the 404.
12+
sessionStorage.redirect = location.href;
13+
14+
const pathParser = new RegExp('^(?/(?<language>[a-z]{2})/(?<path>.*)$');
15+
const matches = pathParser.exec(window.location.pathname);
16+
if (matches) {
17+
const newPath = [matches.groups.language].join('/');
18+
if (newPath !== location.pathname) {
19+
// Immediately redirect to the base URL so we can use the SPA routing.
20+
console.log('Redirect to ' + newPath);
21+
location.pathname = newPath;
22+
}
23+
else {
24+
console.log('No need to redirect');
25+
}
26+
}
27+
else if (location.pathname == "/"){
28+
location.pathname = "/en/";
29+
}
30+
else {
31+
console.error('Path does not match', location.pathname);
32+
}
33+
</script>
34+
</head>
35+
36+
<body>
37+
<!-- IE required at least 512 bytes of data to show non-default 404. -->
38+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
39+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
40+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
41+
</body>
42+
43+
</html>

0 commit comments

Comments
 (0)