Skip to content

Commit 8077ae4

Browse files
committed
hardcode 404 page
1 parent 1487926 commit 8077ae4

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

frontend/main/src/pages/404.tsx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { NextSeo } from 'next-seo';
2+
import Link from 'next/link';
3+
import AJ404 from '@/components/global/icons/AJ404';
4+
5+
import { GetStaticPropsContext, InferGetStaticPropsType } from 'next';
6+
import builder from '@builder.io/react';
7+
import Layout from '@/layout/Layout';
8+
9+
export async function getStaticProps({
10+
params,
11+
}: GetStaticPropsContext<{ page: string[] }>) {
12+
console.log(JSON.stringify(params));
13+
const [header, footer] = await Promise.all([
14+
builder.get('header').promise(),
15+
builder.get('footer').promise(),
16+
]);
17+
18+
return {
19+
props: {
20+
header: header || null,
21+
footer: footer || null,
22+
},
23+
revalidate: 5,
24+
};
25+
}
26+
27+
export default function Custom404({
28+
header,
29+
footer,
30+
}: InferGetStaticPropsType<typeof getStaticProps>) {
31+
return (
32+
<>
33+
<NextSeo title="404 | Not Found" noindex={true}></NextSeo>
34+
35+
<Layout header={header} footer={footer}>
36+
<section className="grid content-start grid-cols-1 gap-10 p-4 text-center justify-items-center">
37+
<AJ404 />
38+
<h1 className="text-5xl lg:text-6xl">
39+
Uh oh, that page doesn&apos;t seem to exist.
40+
</h1>
41+
<h2 className="font-sans text-4xl lg:text-5xl">
42+
Were you looking for{' '}
43+
{/* add some logic here to say which route they clicked? */}
44+
<Link href="/courses">
45+
<a className="underline text-secondary-600">Courses</a>
46+
</Link>
47+
</h2>
48+
</section>
49+
</Layout>
50+
</>
51+
);
52+
}

frontend/main/src/pages/[[...page]].tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { UserInfoExtended } from '@/models/user.model';
1717
import PostMediaLocked from '@/components/PostMediaLocked';
1818
import AJ404 from '@/components/global/icons/AJ404';
1919
import Link from 'next/link';
20+
import Error from 'next/error';
2021

2122
function getRecent(type: ModelType, preview?: boolean) {
2223
return getAllBuilder({
@@ -143,6 +144,7 @@ export async function getStaticProps({
143144
courseData: cleanedCourseData(courseData),
144145
},
145146
revalidate: 300,
147+
notFound: modelData ? true : false,
146148
};
147149
}
148150

0 commit comments

Comments
 (0)