diff options
Diffstat (limited to 'docusaurus/src/theme/NotFound')
-rw-r--r-- | docusaurus/src/theme/NotFound/DDoSProtection.tsx | 13 | ||||
-rw-r--r-- | docusaurus/src/theme/NotFound/Redirection.tsx (renamed from docusaurus/src/theme/NotFound/redirectInput.tsx) | 49 | ||||
-rw-r--r-- | docusaurus/src/theme/NotFound/index.tsx | 37 |
3 files changed, 37 insertions, 62 deletions
diff --git a/docusaurus/src/theme/NotFound/DDoSProtection.tsx b/docusaurus/src/theme/NotFound/DDoSProtection.tsx index 6cd8c04..b861669 100644 --- a/docusaurus/src/theme/NotFound/DDoSProtection.tsx +++ b/docusaurus/src/theme/NotFound/DDoSProtection.tsx @@ -1,19 +1,14 @@ -/** - * @license - * SPDX-License-Identifier: AGPL-3.0-or-later - * This file is part of Wolfree. - * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - */ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ import React from "react"; -const DDoSProtection = () => ( +export default (): React.JSX.Element => ( <center style={{ display: "flex", justifyContent: "center", alignItems: "center", - height: 100 + "vh", + height: "99vh", }} > <center> @@ -30,5 +25,3 @@ const DDoSProtection = () => ( </center> </center> ); - -export default DDoSProtection; diff --git a/docusaurus/src/theme/NotFound/redirectInput.tsx b/docusaurus/src/theme/NotFound/Redirection.tsx index 4e29b4a..3fe2d6d 100644 --- a/docusaurus/src/theme/NotFound/redirectInput.tsx +++ b/docusaurus/src/theme/NotFound/Redirection.tsx @@ -1,41 +1,30 @@ -/** - * @license - * SPDX-License-Identifier: AGPL-3.0-or-later - * This file is part of Wolfree. - * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - */ - -import { useEffect } from "react"; +/* SPDX-License-Identifier: AGPL-3.0-or-later */ -const redirectInput = () => { - useEffect(() => { - const redirectToInputPage = () => { - const pathname = window.location.pathname; +import React from "react"; +import typescriptNever from "../../functions/typescriptNever"; - const isExample = pathname.includes("/example"); - if (!isExample) { - window.location.href = "/"; - return; - } +export default (): React.JSX.Element => { + React.useEffect((): void => { + const pathname = window.location.pathname; - const filename = pathname.split("/").pop(); - if (!filename) { - window.location.href = "/"; - return; - } + const isExample = pathname.includes("/example"); - const topic = "topic " + filename.replace(/-/g, " "); + if (isExample === true) { + const topic = "topic " + pathname.split("/").pop().replace(/-/g, " "); const url = new URL("/input/", window.location.href); url.searchParams.set("i", topic); - window.location.href = url.href; - }; - - redirectToInputPage(); - }, []); // The effect runs only once on mount + window.location.replace(url); + } else if (isExample === false) { + window.location.replace("/"); + } else { + window.location.replace("/"); + typescriptNever(isExample); + } + }, []); // Empty dependency array means the effect runs only once after initial render. + + return <></>; }; -export default redirectInput; - /* * test case: * diff --git a/docusaurus/src/theme/NotFound/index.tsx b/docusaurus/src/theme/NotFound/index.tsx index d5e0208..15e9fe6 100644 --- a/docusaurus/src/theme/NotFound/index.tsx +++ b/docusaurus/src/theme/NotFound/index.tsx @@ -1,28 +1,21 @@ -/** - * @license - * SPDX-License-Identifier: AGPL-3.0-or-later - * This file is part of Wolfree. - * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - */ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ -import React from "react"; -import NotFound from "@theme-original/NotFound"; -import redirectInput from "./redirectInput"; import DDoSProtection from "./DDoSProtection"; +import NotFound from "@theme-original/NotFound"; +import React from "react"; +import Redirection from "./Redirection"; -const NotFoundWrapper = (props: React.JSX.IntrinsicAttributes) => { - redirectInput(); - return ( - <> - <DDoSProtection /> - <div style={{ display: "none" }}> - <NotFound {...props} /> - </div> - </> - ); -}; - -export default NotFoundWrapper; +export default ( + props: React.JSX.ElementAttributesProperty +): React.JSX.Element => ( + <> + <Redirection /> + <DDoSProtection /> + <div style={{ display: "none" }}> + <NotFound {...props} /> + </div> + </> +); // How can I customize the 404 page? · facebook/docusaurus · Discussion #6030 // https://github.com/facebook/docusaurus/discussions/6030 |