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 pathindex.js
53 lines (47 loc) · 1.41 KB
/
index.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
import Container from '@/components/atoms/Container'
import Layout from '@/components/common/Layout'
import getPagePropTypes from '@/functions/getPagePropTypes'
import getPostTypeStaticProps from '@/functions/wordpress/postTypes/getPostTypeStaticProps'
import Page from './[...slug]'
// Define route post type.
const postType = 'page'
/**
* Render the HomePage component.
*
* @author WebDevStudios
* @param {object} props The component attributes as props.
* @param {object} props.post Post data from WordPress.
* @return {Element} The HomePage component.
*/
export default function HomePage({post}) {
const {seo, ...postData} = post
// Display dynamic page data if homepage retrieved from WP.
if (postData && Object.keys(postData).length > 0) {
return <Page post={post} />
}
// Display static page content as fallback.
return (
<Layout seo={{...seo}}>
<Container>
<article>
<p>
To display your WordPress homepage dynamically, set your homepage to
a static page via the WP dashboard (Settings: Reading Settings).
</p>
</article>
</Container>
</Layout>
)
}
/**
* Get post static props.
*
* @author WebDevStudios
* @return {object} Post props.
*/
export async function getStaticProps() {
return await getPostTypeStaticProps({slug: '/'}, postType)
}
HomePage.propTypes = {
...getPagePropTypes(postType)
}