This repository was archived by the owner on Feb 27, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-15
lines changed Expand file tree Collapse file tree 2 files changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -45,13 +45,22 @@ export default async function getPostTypeStaticProps(
45
45
slug
46
46
)
47
47
48
+ const props = {
49
+ post,
50
+ error,
51
+ errorMessage
52
+ }
53
+
54
+ // Custom handling for homepage.
55
+ if ( error ) {
56
+ // Fallback to empty props if homepage not set in WP.
57
+ props . post = null
58
+ props . error = false
59
+ }
60
+
48
61
// Merge in query results as Apollo state.
49
62
return addApolloState ( apolloClient , {
50
- props : {
51
- post,
52
- error,
53
- errorMessage
54
- } ,
63
+ props,
55
64
revalidate : 60 * 5
56
65
} )
57
66
}
Original file line number Diff line number Diff line change @@ -48,16 +48,7 @@ export default function HomePage({post}) {
48
48
* @return {Object } Post props.
49
49
*/
50
50
export async function getStaticProps ( ) {
51
- const props = await getPostTypeStaticProps ( { slug : '/' } , postType )
52
-
53
- return ! props . props . error
54
- ? props
55
- : // Fallback to empty props if homepage not set in WP.
56
- {
57
- props : {
58
- post : null
59
- }
60
- }
51
+ return await getPostTypeStaticProps ( { slug : '/' } , postType )
61
52
}
62
53
63
54
HomePage . propTypes = {
You can’t perform that action at this time.
0 commit comments