Skip to content

[DOCS] auto 404 redirect to home 5 sec #7748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions docs/src/theme/NotFound/Content/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React, { useEffect } from 'react';
import clsx from 'clsx';
import Translate from '@docusaurus/Translate';
import Heading from '@theme/Heading';

export default function NotFoundContent({ className }) {
useEffect(() => {
// Auto-redirect to home page after 3 seconds
const timer = setTimeout(() => {
window.location.href = '/';
}, 5000);

return () => clearTimeout(timer);
}, []);

return (
<main className={clsx('container margin-vert--xl', className)}>
<div className="row">
<div className="col col--6 col--offset-3">
<Heading as="h1" className="hero__title">
<Translate
id="theme.NotFound.title"
description="The title of the 404 page">
Oops!

The page you were looking for has moved.
</Translate>
</Heading>
<br /><br />

<img src='/img/404.svg' class='centered' />
<br />
<p>
<Translate
id="theme.NotFound.p1"
description="The first paragraph of the 404 page">
Don't worry! It looks like you've wandered off the beaten path.
We'll redirect you back to the home page in just a moment.
</Translate>
</p>
<p>
<Translate
id="theme.NotFound.p2"
description="The 2nd paragraph of the 404 page">
If you'd like to explore our documentation, you can start from the
</Translate>
{' '}
<a href="/" style={{ color: 'var(--ifm-color-primary)', textDecoration: 'underline' }}>
home page
</a>
{' '}
<Translate
id="theme.NotFound.p2_continued"
description="The continuation of the 2nd paragraph of the 404 page">
or use the navigation menu above.
</Translate>
</p>
<p style={{ fontSize: '0.9em', color: 'var(--ifm-color-emphasis-600)', fontStyle: 'italic' }}>
Redirecting automatically in 5 seconds...
</p>
</div>
</div>
</main>
);
}
19 changes: 19 additions & 0 deletions docs/src/theme/NotFound/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import {translate} from '@docusaurus/Translate';
import {PageMetadata} from '@docusaurus/theme-common';
import Layout from '@theme/Layout';
import NotFoundContent from '@theme/NotFound/Content';
export default function Index() {
const title = translate({
id: 'theme.NotFound.title',
message: 'Page Not Found',
});
return (
<>
<PageMetadata title={title} />
<Layout>
<NotFoundContent />
</Layout>
</>
);
}
392 changes: 392 additions & 0 deletions docs/static/img/404.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.