Skip to content

Commit a31bdf0

Browse files
fix: 404 page and Redirection
1 parent d032612 commit a31bdf0

File tree

4 files changed

+81
-23
lines changed

4 files changed

+81
-23
lines changed

src/components/NotFoundPage.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import React from "react";
2+
import error from "../../static/img/error404.png";
3+
4+
const NotFoundPage = () => {
5+
return (
6+
<main className="container margin-vert--xl">
7+
<div className="row">
8+
<div className="col col--6 col--offset-3">
9+
<div className="text-center">
10+
<img
11+
src={error}
12+
width={300}
13+
height={300}
14+
alt="404 Error"
15+
style={{ margin: '0 auto' }}
16+
/>
17+
<h1 className="hero__title">🐰 Oops! 🐰</h1>
18+
<p className="hero__subtitle margin-vert--md">404 - Page Not Found</p>
19+
<div className="margin-vert--lg">
20+
<div className="loading-dots">
21+
<span>Redirecting to documentation</span>
22+
<span className="dot">.</span>
23+
<span className="dot">.</span>
24+
<span className="dot">.</span>
25+
</div>
26+
</div>
27+
</div>
28+
</div>
29+
</div>
30+
</main>
31+
);
32+
};
33+
34+
export default NotFoundPage;
Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
1-
import React from "react";
2-
import {translate} from "@docusaurus/Translate";
3-
import Link from "@docusaurus/Link";
1+
import React, { useEffect } from "react";
42
import {PageMetadata} from "@docusaurus/theme-common";
3+
import {useLocation} from '@docusaurus/router';
4+
import NotFoundPage from "../../../components/NotFoundPage";
55

66
export default function NotFound() {
7+
const location = useLocation();
8+
9+
useEffect(() => {
10+
const timer = setTimeout(() => {
11+
// Check if we're already in the /docs path
12+
const newPath = location.pathname.startsWith('/docs')
13+
? '/docs/'
14+
: '/docs' + location.pathname;
15+
window.location.href = newPath;
16+
}, 1000); // Increased to 1 seconds to match animation
17+
18+
return () => clearTimeout(timer);
19+
}, [location]);
20+
721
return (
822
<>
9-
<PageMetadata title="Page Not Found" />
10-
<main className="container margin-vert--xl">
11-
<div className="row">
12-
<div className="col col--6 col--offset-3 text-center">
13-
<h1 className="hero__title">404: Page Not Found</h1>
14-
<p className="padding-vert--md">
15-
We could not find what you were looking for.<br />
16-
The page you requested may have been moved or deleted.
17-
</p>
18-
<div className="margin-vert--lg">
19-
<Link to="/docs/" className="button button--primary margin-right--md">
20-
Back to Homepage
21-
</Link>
22-
<Link to="/docs/search" className="button button--secondary">
23-
Search Documentation
24-
</Link>
25-
</div>
26-
</div>
27-
</div>
28-
</main>
23+
<PageMetadata title="404: Page Not Found" />
24+
<NotFoundPage />
2925
</>
3026
);
3127
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* Loading dots animation */
2+
.loading-dots {
3+
display: flex;
4+
align-items: center;
5+
justify-content: center;
6+
gap: 4px;
7+
font-size: 1.1rem;
8+
color: var(--ifm-color-primary);
9+
}
10+
11+
.dot {
12+
animation: dotPulse 1.5s infinite;
13+
opacity: 0;
14+
}
15+
16+
.dot:nth-child(2) {
17+
animation-delay: 0.5s;
18+
}
19+
20+
.dot:nth-child(3) {
21+
animation-delay: 1s;
22+
}
23+
24+
@keyframes dotPulse {
25+
0% { opacity: 0; }
26+
50% { opacity: 1; }
27+
100% { opacity: 0; }
28+
}

static/img/error404.png

215 KB
Loading

0 commit comments

Comments
 (0)