Skip to content

Commit 115d7d6

Browse files
committed
Enhance 404 page with metadata and improved layout; update build process to verify 404.html existence
1 parent 8a16347 commit 115d7d6

File tree

3 files changed

+67
-35
lines changed

3 files changed

+67
-35
lines changed

.github/workflows/website-deploy.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ jobs:
1717
- name: Install dependencies
1818
run: yarn install --frozen-lockfile
1919
- name: Test Build
20-
run: yarn build
20+
run: |
21+
yarn build
22+
# Verify 404.html exists
23+
ls -la build/ | grep 404.html || echo "404.html not found!"
2124
gh-release:
2225
if: github.event_name != 'pull_request'
2326
runs-on: ubuntu-latest

docusaurus.config.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,23 @@ const config = {
88
url: 'https://mcodex.dev',
99
baseUrl: '/react-native-rooster/',
1010
onBrokenLinks: 'throw',
11+
onBrokenMarkdownLinks: 'warn',
1112
favicon: 'img/favicon.ico',
1213
organizationName: 'mcodex',
1314
projectName: 'react-native-rooster',
1415

1516
// Performance and SEO optimization
16-
trailingSlash: true,
17+
trailingSlash: false,
1718
noIndex: false, // Allow search engine indexing
1819

1920
// Improved build settings
2021
staticDirectories: ['static'],
2122

23+
// Configure 404 handling explicitly
24+
customFields: {
25+
errorPagePath: '404.html',
26+
},
27+
2228
// Webpack configuration for better performance
2329
webpack: {
2430
jsLoader: (isServer) => ({
@@ -78,7 +84,7 @@ const config = {
7884
},
7985
footer: {
8086
style: 'dark',
81-
copyright: `Copyright © ${new Date().getFullYear()} Made with ❤️ by mCodex`,
87+
copyright: `Copyright © 2020 - ${new Date().getFullYear()} Made with ❤️ by mCodex`,
8288
},
8389
// Add image zoom
8490
zoom: {
@@ -112,7 +118,7 @@ const config = {
112118
theme: {
113119
customCss: require.resolve('./src/css/custom.css'),
114120
},
115-
googleAnalytics: {
121+
gtag: {
116122
trackingID: 'UA-79205996-7',
117123
anonymizeIP: true,
118124
},
@@ -130,6 +136,13 @@ const config = {
130136
'@docusaurus/plugin-client-redirects',
131137
{
132138
fromExtensions: ['html'],
139+
redirects: [
140+
// Ensure proper redirects for common patterns
141+
{
142+
from: '/404.html',
143+
to: '/404',
144+
},
145+
],
133146
createRedirects: function (existingPath) {
134147
// Redirect old paths to new paths if any
135148
return undefined;

src/pages/404.js

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,58 @@ import clsx from 'clsx';
33
import Layout from '@theme/Layout';
44
import Link from '@docusaurus/Link';
55
import useBaseUrl from '@docusaurus/useBaseUrl';
6+
import { PageMetadata } from '@docusaurus/theme-common';
7+
import { translate } from '@docusaurus/Translate';
68
import styles from './styles.module.css';
79

810
export default function NotFound() {
911
return (
10-
<Layout title="Page Not Found">
11-
<div className={clsx('container', styles.notFoundContainer)}>
12-
<div className={styles.notFoundContent}>
13-
<h1 className={styles.notFoundTitle}>Page Not Found</h1>
14-
<p className={styles.notFoundText}>
15-
We couldn't find what you were looking for. The page might have been moved or renamed.
16-
</p>
17-
<div className={styles.buttons}>
18-
<Link
19-
className={clsx(
20-
'button button--primary button--lg',
21-
styles.getStarted,
22-
)}
23-
to={useBaseUrl('/')}
24-
>
25-
Go to Homepage
26-
</Link>
27-
<Link
28-
className={clsx(
29-
'button button--outline button--secondary button--lg',
30-
styles.getStarted,
31-
)}
32-
to={useBaseUrl('/docs/overview')}
33-
>
34-
Check Documentation
35-
</Link>
12+
<>
13+
<PageMetadata
14+
title={translate({
15+
id: 'theme.NotFound.title',
16+
message: 'Page Not Found',
17+
})}
18+
/>
19+
<Layout>
20+
<div className={clsx('container', styles.notFoundContainer)}>
21+
<div className={styles.notFoundContent}>
22+
<h1 className={styles.notFoundTitle}>Page Not Found</h1>
23+
<p className={styles.notFoundText}>
24+
We couldn't find what you were looking for. The page might have been moved or renamed.
25+
</p>
26+
<div className={styles.buttons}>
27+
<Link
28+
className={clsx(
29+
'button button--primary button--lg',
30+
styles.getStarted,
31+
)}
32+
to={useBaseUrl('/')}
33+
>
34+
Go to Homepage
35+
</Link>
36+
<Link
37+
className={clsx(
38+
'button button--outline button--secondary button--lg',
39+
styles.getStarted,
40+
)}
41+
to={useBaseUrl('/docs/overview')}
42+
>
43+
Check Documentation
44+
</Link>
45+
</div>
46+
</div>
47+
<div className={styles.notFoundImage}>
48+
<img
49+
src={useBaseUrl('img/undraw_mobile.svg')}
50+
alt="Page not found"
51+
loading="lazy"
52+
width="400"
53+
height="300"
54+
/>
3655
</div>
3756
</div>
38-
<div className={styles.notFoundImage}>
39-
<img src={useBaseUrl('img/undraw_mobile.svg')} alt="Page not found" />
40-
</div>
41-
</div>
42-
</Layout>
57+
</Layout>
58+
</>
4359
);
4460
}

0 commit comments

Comments
 (0)