-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path404.html
54 lines (47 loc) · 1.19 KB
/
404.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
permalink: /404.html
layout: default
---
<style type="text/css" media="screen">
.container {
margin: 10px auto;
max-width: 600px;
text-align: center;
}
h1 {
margin: 30px 0;
font-size: 4em;
line-height: 1;
letter-spacing: -1px;
}
</style>
<div class="container">
<h1>404</h1>
<p><strong>Page not found :(</strong></p>
<p>The requested page could not be found.</p>
</div>
<script>
(function() {
var knownURLs = [
{% for post in site.posts %}
'{{ post.url }}',
{% endfor %}
];
var currentURL = window.location.href;
console.log(knownURLs);
console.log(currentURL);
var domainAndProtocolRemoved = currentURL.replace(/^[^:]+:\/\/[^\/]+/, '');
var modifiedCurrentURL = domainAndProtocolRemoved.replace(/\/\d{1,4}\/\d{1,2}\/\d{1,2}\//g, '');
console.log(modifiedCurrentURL);
var targetURL = null;
for (var i = 0; i < knownURLs.length; i++) {
if (knownURLs[i].endsWith(modifiedCurrentURL)) {
targetURL = knownURLs[i];
break;
}
}
if (targetURL !== null) {
window.location.href = targetURL;
}
})();
</script>