Skip to content

Commit 4b5dc76

Browse files
committed
redirect page in 404
1 parent 370f08e commit 4b5dc76

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

layouts/404.html

+36-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
11
{{ define "main" }}
2-
<div class="bg-white">
2+
<script>
3+
function redirectPage() {
4+
const pageRedirects = {};
5+
6+
const path = window.location.pathname;
7+
8+
if (pageRedirects[path]) {
9+
document.getElementById("404-content").style.display = "none";
10+
document.getElementById("redirect-content").style.display = "block";
11+
const newUrl = pageRedirects[path];
12+
document.getElementById("redirect-link").href = newUrl;
13+
window.location.replace(newUrl);
14+
}
15+
}
16+
17+
window.onload = function () {
18+
redirectPage();
19+
};
20+
</script>
21+
<div class="isolate">
322
<main class="mx-auto w-full max-w-7xl px-6 lg:px-8">
423
<div class="mx-auto max-w-xl py-16 sm:py-24">
5-
<div class="text-center">
24+
<div id="404-content" class="text-center">
625
<p class="text-base font-semibold text-indigo-600">404</p>
726
<h1
827
class="mt-2 text-4xl font-bold tracking-tight text-gray-900 sm:text-5xl">
@@ -12,6 +31,21 @@
1231
The page you are looking for could not be found.
1332
</p>
1433
</div>
34+
<div id="redirect-content" style="display: none;" class="text-center">
35+
<h1
36+
class="mt-2 text-4xl font-bold tracking-tight text-gray-900 sm:text-5xl">
37+
Redirecting...
38+
</h1>
39+
<p class="mt-2 text-lg text-gray-500">
40+
If you're not redirected automatically,
41+
<a
42+
id="redirect-link"
43+
class="text-base font-semibold text-indigo-600"
44+
href="#">
45+
click here
46+
</a>
47+
</p>
48+
</div>
1549
</div>
1650
</main>
1751
</div>

0 commit comments

Comments
 (0)