|
1 | | -import React from "react"; |
| 1 | +import React, {useEffect, useState} from "react"; |
2 | 2 | import {translate} from "@docusaurus/Translate"; |
3 | 3 | import Link from "@docusaurus/Link"; |
4 | 4 | import {PageMetadata} from "@docusaurus/theme-common"; |
| 5 | +import useBaseUrl from "@docusaurus/useBaseUrl"; |
5 | 6 |
|
6 | 7 | export default function NotFound() { |
| 8 | + const [requestedUrl, setRequestedUrl] = useState(""); |
| 9 | + |
| 10 | + useEffect(() => { |
| 11 | + // capture the full URL client-side and trigger a redirect after 2s |
| 12 | + if (typeof window !== "undefined") { |
| 13 | + setRequestedUrl(window.location.href); |
| 14 | + const id = setTimeout(() => { |
| 15 | + window.location.href = "/docs/"; |
| 16 | + }, 2000); |
| 17 | + return () => clearTimeout(id); |
| 18 | + } |
| 19 | + return undefined; |
| 20 | + }, []); |
| 21 | + |
7 | 22 | return ( |
8 | 23 | <> |
9 | 24 | <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 | + <main |
| 26 | + style={{ |
| 27 | + height: "100vh", |
| 28 | + display: "flex", |
| 29 | + alignItems: "center", |
| 30 | + justifyContent: "center", |
| 31 | + overflow: "hidden", |
| 32 | + padding: "20px 0", |
| 33 | + }} |
| 34 | + > |
| 35 | + <div className="container"> |
| 36 | + <div className="row"> |
| 37 | + <div className="col col--6 col--offset-3 text-center"> |
| 38 | + <div |
| 39 | + style={{ |
| 40 | + maxHeight: "100vh", |
| 41 | + display: "flex", |
| 42 | + flexDirection: "column", |
| 43 | + gap: "1rem", |
| 44 | + }} |
| 45 | + > |
| 46 | + <img |
| 47 | + src={require("@site/static/img/error404.png").default} |
| 48 | + alt={translate({message: "404 - Page Not Found"})} |
| 49 | + style={{ |
| 50 | + width: "380px", |
| 51 | + maxWidth: "100%", |
| 52 | + height: "auto", |
| 53 | + display: "block", |
| 54 | + margin: "0 auto", |
| 55 | + }} |
| 56 | + /> |
| 57 | + |
| 58 | + <h1 |
| 59 | + className="hero__title" |
| 60 | + style={{ |
| 61 | + color: "var(--ifm-color-primary)", |
| 62 | + margin: "0.5rem 0", |
| 63 | + fontSize: "2rem", |
| 64 | + }} |
| 65 | + > |
| 66 | + 404: Page Not Found |
| 67 | + </h1> |
| 68 | + |
| 69 | + <p |
| 70 | + style={{ |
| 71 | + color: "var(--ifm-color-emphasis-700)", |
| 72 | + margin: "0.5rem 0", |
| 73 | + }} |
| 74 | + > |
| 75 | + We could not find what you were looking for. |
| 76 | + <br /> |
| 77 | + The page you requested may have been moved or deleted. |
| 78 | + </p> |
| 79 | + |
| 80 | + {requestedUrl && ( |
| 81 | + <p |
| 82 | + style={{ |
| 83 | + color: "var(--ifm-color-emphasis-600)", |
| 84 | + margin: "0.25rem 0", |
| 85 | + fontSize: "0.9rem", |
| 86 | + }} |
| 87 | + > |
| 88 | + Requested URL: <code>{requestedUrl}</code> |
| 89 | + </p> |
| 90 | + )} |
| 91 | + |
| 92 | + <p |
| 93 | + style={{ |
| 94 | + color: "var(--ifm-color-primary)", |
| 95 | + margin: "0.25rem 0", |
| 96 | + fontSize: "0.9rem", |
| 97 | + }} |
| 98 | + > |
| 99 | + Redirecting to documentation... |
| 100 | + </p> |
| 101 | + |
| 102 | + <div style={{marginTop: "0.5rem"}}> |
| 103 | + <Link to="/docs/" className="button button--primary"> |
| 104 | + Go to Documentation |
| 105 | + </Link> |
| 106 | + </div> |
| 107 | + </div> |
25 | 108 | </div> |
26 | 109 | </div> |
27 | 110 | </div> |
|
0 commit comments