Skip to content

feature(404): Added Custom 404 Page#232

Merged
kmesh-bot merged 1 commit intokmesh-net:mainfrom
yashisrani:add/custom-404-page
Sep 10, 2025
Merged

feature(404): Added Custom 404 Page#232
kmesh-bot merged 1 commit intokmesh-net:mainfrom
yashisrani:add/custom-404-page

Conversation

@yashisrani
Copy link
Copy Markdown
Contributor

@yashisrani yashisrani commented Sep 6, 2025

This PR addresses the issue in kmesh-net/kmesh#1412

  • Replaces the stock Docusaurus “Page Not Found” screen with a branded, user-friendly 404 page that guides visitors back to the documentation or home page.

How

  • Swizzled @docusaurus/theme-classic NotFound (--eject)
  • Updated src/theme/NotFound/Content/index.js with new markup and SVG icons
  • Added professional blue-grey styling in src/theme/NotFound/Content/styles.module.css
  • Fully responsive & accessible (WCAG 2.1 AA colours)
Screenshot 2025-09-06 at 1 06 09 PM

Signed-off-by: GitHub Action <action@github.com>
@netlify
Copy link
Copy Markdown

netlify bot commented Sep 6, 2025

Deploy Preview for kmesh-net ready!

Name Link
🔨 Latest commit 8558094
🔍 Latest deploy log https://app.netlify.com/projects/kmesh-net/deploys/68bbea689212620008ee1e8c
😎 Deploy Preview https://deploy-preview-232--kmesh-net.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @yashisrani, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a custom 404 "Page Not Found" experience, replacing the default Docusaurus screen. The goal is to enhance user experience by providing a branded, visually appealing, and helpful page that guides visitors back to relevant sections of the site, improving navigation and reducing frustration for users encountering broken links.

Highlights

  • Custom 404 Page Implementation: Replaces the default Docusaurus 404 page with a custom, branded, and user-friendly version.
  • Docusaurus Theme Swizzling: The @docusaurus/theme-classic NotFound component was swizzled to allow for extensive customization.
  • New UI/UX for 404: Introduces a new React component with custom markup, integrated SVG icons, and clear navigation options (Return Home, View Documentation).
  • Styling and Accessibility: Applies a professional blue-grey color scheme via CSS modules, ensuring full responsiveness and WCAG 2.1 AA color accessibility.
  • Specific Content Message: Includes a specific message indicating that Chinese documentation is currently unavailable and directs users to English documentation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new custom 404 page with a professional design. The implementation is a good start, but there are several areas for improvement to align with best practices and ensure maintainability. My main concerns are the hardcoded, non-translatable text and a confusing message specific to Chinese documentation on a generic error page. I've also pointed out the need to use Docusaurus's useBaseUrl hook for robust linking and some cleanup opportunities in the CSS. Addressing these points will make the new 404 page more robust, maintainable, and provide a better user experience.

Comment on lines +11 to +14
<h1 className={styles.title}>Page Not Found</h1>
<p className={styles.subtitle}>
The requested resource could not be located on this server.
</p>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The title and subtitle are hardcoded in English. To support internationalization (i18n), which is configured for this site, you should use the <Translate> component from @docusaurus/Translate for all user-facing text. You'll also need to add import {Translate} from '@docusaurus/Translate'; at the top of the file.

Suggested change
<h1 className={styles.title}>Page Not Found</h1>
<p className={styles.subtitle}>
The requested resource could not be located on this server.
</p>
<h1 className={styles.title}><Translate id="theme.NotFound.title">Page Not Found</Translate></h1>
<p className={styles.subtitle}>
<Translate id="theme.NotFound.p1">We could not find what you were looking for.</Translate>
</p>

Comment on lines +16 to +43
<div className={styles.messageBox}>
<div className={styles.infoIcon}>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"
fill="currentColor"
/>
</svg>
</div>
<div>
<p className={styles.message}>
Chinese documentation is currently unavailable.
</p>
<p className={styles.message}>
Please refer to our{" "}
<Link to="/docs/welcome" className={styles.link}>
English documentation
</Link>{" "}
for comprehensive project information.
</p>
</div>
</div>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This message box contains a very specific message about Chinese documentation being unavailable. A 404 page is a generic fallback for any broken URL, so this message will be confusing to most users. It should be replaced with a more general message. For example, you could use the standard Docusaurus message which advises users to contact the site owner about the broken link. This text should also be made translatable using the <Translate> component.

            <div className={styles.messageBox}>
              <div className={styles.infoIcon}>
                <svg
                  width="24"
                  height="24"
                  viewBox="0 0 24 24"
                  fill="none"
                  xmlns="http://www.w3.org/2000/svg"
                >
                  <path
                    d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"
                    fill="currentColor"
                  />
                </svg>
              </div>
              <div>
                <p className={styles.message}>
                  <Translate id="theme.NotFound.p2">
                    Please contact the owner of the site that linked you to the original URL and let them know their link is broken.
                  </Translate>
                </p>
              </div>
            </div>

Comment on lines +45 to +76
<div className={styles.actions}>
<Link to="/" className={styles.primaryButton}>
<svg
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"
fill="currentColor"
/>
</svg>
Return Home
</Link>
<Link to="/docs/welcome" className={styles.secondaryButton}>
<svg
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-5 14H7v-2h7v2zm3-4H7v-2h10v2zm0-4H7V7h10v2z"
fill="currentColor"
/>
</svg>
View Documentation
</Link>
</div>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The to props for the Link components have hardcoded paths (/ and /docs/welcome). It's a Docusaurus best practice to use the useBaseUrl hook to prepend the site's baseUrl to paths. This makes the links resilient to changes in the baseUrl configuration.

Example:

import useBaseUrl from '@docusaurus/useBaseUrl';

export default function NotFoundContent({ className }) {
  const homeUrl = useBaseUrl('/');
  const docsUrl = useBaseUrl('/docs/welcome');

  return (
    // ...
    <Link to={homeUrl} className={styles.primaryButton}>
      {/* ... */}
    </Link>
    <Link to={docsUrl} className={styles.secondaryButton}>
      {/* ... */}
    </Link>
    // ...
  );
}

Comment on lines +20 to +39
.errorSection {
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 3rem;
}

.errorCode {
font-size: 5rem;
font-weight: 700;
color: #475569;
line-height: 1;
margin-bottom: 0.5rem;
font-family: "SF Mono", "Monaco", "Inconsolata", "Roboto Mono", monospace;
}

.errorIcon {
color: #64748b;
opacity: 0.7;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These CSS classes (.errorSection, .errorCode, .errorIcon) do not appear to be used in the NotFound/Content/index.js component. Unused code should be removed to improve maintainability.

Comment on lines +95 to +106
.link {
color: #3b82f6 !important;
font-weight: 500;
text-decoration: none;
border-bottom: 1px solid transparent;
transition: border-color 0.2s ease;
}

.link:hover {
border-bottom-color: #3b82f6;
text-decoration: none !important;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The use of !important in .link and .link:hover should be avoided. It breaks the natural CSS cascade and can make future styling changes difficult and unpredictable. Try to achieve the desired styling by increasing selector specificity or re-ordering CSS rules instead.

@LiZhenCheng9527
Copy link
Copy Markdown
Collaborator

q: Will all our 404 pages be replaced with this one?

@yashisrani
Copy link
Copy Markdown
Contributor Author

q: Will all our 404 pages be replaced with this one?

Yes, this new custom 404 page will replace the default 404 error page, so all 404 errors across the site will show this version instead of the standard one.

@kmesh-bot
Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hzxuzhonghu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hzxuzhonghu
Copy link
Copy Markdown
Member

/lgtm

@kmesh-bot kmesh-bot added the lgtm label Sep 10, 2025
@kmesh-bot kmesh-bot merged commit 5486919 into kmesh-net:main Sep 10, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants