This repository was archived by the owner on Feb 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 132
/
Copy path500.js
54 lines (48 loc) · 1.51 KB
/
500.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import Code from '@/components/atoms/Code'
import Container from '@/components/atoms/Container'
import RichText from '@/components/atoms/RichText'
import Layout from '@/components/common/Layout'
import getPagePropTypes from '@/functions/getPagePropTypes'
import getPostTypeStaticProps from '@/functions/wordpress/postTypes/getPostTypeStaticProps'
import PropTypes from 'prop-types'
// Define route post type.
const postType = '500'
/**
* Render the Custom500 component.
*
* @author WebDevStudios
* @param {object} props The component attributes as props.
* @param {string} props.errorMessage The 500 error message.
* @param {object} props.post Post data from WordPress.
* @return {Element} The Custom500 component.
*/
export default function Custom500({errorMessage, post}) {
const {seo = {}} = post
// Update robots SEO meta.
seo.metaRobotsNofollow = 'noindex'
seo.metaRobotsNoindex = 'nofollow'
return (
<Layout seo={{...seo}}>
<Container>
<article>
<RichText tag="h1">500 Error</RichText>
<p>A server-side error has occurred.</p>
{errorMessage && <Code content={errorMessage} />}
</article>
</Container>
</Layout>
)
}
/**
* Get post static props.
*
* @author WebDevStudios
* @return {object} Post props.
*/
export async function getStaticProps() {
return await getPostTypeStaticProps(null, postType)
}
Custom500.propTypes = {
...getPagePropTypes(postType),
errorMessage: PropTypes.string
}