Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit f5041ff

Browse files
committed
Add structure of 404 page
1 parent 7dc42d5 commit f5041ff

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

pages/404.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import PropTypes from 'prop-types'
2+
import getPostTypeStaticProps from '@/api/wordpress/_global/getPostTypeStaticProps'
3+
import Layout from '@/components/common/Layout'
4+
import {seoPropTypes} from '@/functions/getPagePropTypes'
5+
import Page from './[...slug]'
6+
7+
/**
8+
* Render the Custom404 component.
9+
*
10+
* @author WebDevStudios
11+
* @param {object} props The component attributes as props.
12+
* @param {object} props.post Post data from WordPress.
13+
* @return {Element} The Search component.
14+
*/
15+
export default function Custom404({post}) {
16+
// Display dynamic page data if 404 page retrieved from WP.
17+
if (post) {
18+
return <Page post={post} />
19+
}
20+
21+
return (
22+
<Layout seo={{...post?.seo}}>
23+
<h1>404 Not Found</h1>
24+
<p>That post could not be found!</p>
25+
</Layout>
26+
)
27+
}
28+
29+
/**
30+
* Get post static props.
31+
*
32+
* @author WebDevStudios
33+
* @return {object} Post props.
34+
*/
35+
export async function getStaticProps() {
36+
return await getPostTypeStaticProps(null, '404')
37+
}
38+
39+
Custom404.propTypes = {
40+
post: PropTypes.shape({
41+
seo: {...seoPropTypes.seo}
42+
})
43+
}

0 commit comments

Comments
 (0)