|
1 | 1 | import React from "react";
|
2 | 2 | import { translate } from "@docusaurus/Translate";
|
3 | 3 | import Layout from "@theme/Layout";
|
| 4 | +import { useMount } from "ahooks"; |
| 5 | +import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment"; |
4 | 6 | import Content from "./Content";
|
5 | 7 |
|
6 | 8 | export default function NotFound404() {
|
| 9 | + const pathname = ExecutionEnvironment.canUseDOM ? window?.location?.href : ""; |
| 10 | + const redirectsMap = { |
| 11 | + "/doc/sql-reference": "/sql/sql-reference", |
| 12 | + "/doc/sql-commands": "/sql/sql-commands", |
| 13 | + "/doc/sql-functions": "/sql/sql-functions", |
| 14 | + "/doc/develop": "/developer/drivers", |
| 15 | + "/doc/deploy": "/guides/deploy", |
| 16 | + "/doc/cloud": "/guides/cloud", |
| 17 | + "/cloud/develop": "/developer/drivers", |
| 18 | + "/doc/sql-clients": "/guides/sql-clients", |
| 19 | + "/doc/load-data": "/guides/load-data", |
| 20 | + "/doc/visualize": "/guides/visualize", |
| 21 | + "/doc/monitor": "/guides/monitor", |
| 22 | + "/doc/overview": "/guides/overview", |
| 23 | + "/cloud/getting-started/new-account": "/guides/cloud/new-account", |
| 24 | + }; |
| 25 | + useMount(() => { |
| 26 | + for (const [oldPath, newPath] of Object.entries(redirectsMap)) { |
| 27 | + if (pathname?.includes(oldPath)) { |
| 28 | + window.open(pathname.replace(oldPath, newPath), "_self"); |
| 29 | + } |
| 30 | + } |
| 31 | + }); |
7 | 32 | return (
|
8 | 33 | <Layout
|
9 | 34 | title={translate({
|
|
0 commit comments