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

Commit d92e679

Browse files
committed
Fix dynamic handling of special wp pages
1 parent 16d4baa commit d92e679

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

pages/404.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ import Page from './[...slug]'
1313
* @return {Element} The Search component.
1414
*/
1515
export default function Custom404({post}) {
16+
const {seo, ...postData} = post
17+
1618
// Display dynamic page data if 404 page retrieved from WP.
17-
if (post) {
19+
if (postData && Object.keys(postData).length > 0) {
1820
return <Page post={post} />
1921
}
2022

2123
return (
22-
<Layout seo={{...post?.seo}}>
24+
<Layout seo={{...seo}}>
2325
<h1>404 Not Found</h1>
24-
<p>That post could not be found!</p>
26+
<p>That page could not be found!</p>
2527
</Layout>
2628
)
2729
}

pages/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ const postType = 'page'
1616
* @return {Element} The HomePage component.
1717
*/
1818
export default function HomePage({post}) {
19+
const {seo, ...postData} = post
20+
1921
// Display dynamic page data if homepage retrieved from WP.
20-
if (post) {
22+
if (postData && Object.keys(postData).length > 0) {
2123
return <Page post={post} />
2224
}
2325

2426
// Display static page content as fallback.
2527
return (
26-
<Layout seo={{...post?.seo}}>
28+
<Layout seo={{...seo}}>
2729
<Hero
2830
background="https://images.unsplash.com/photo-1513106021000-168e5f56609d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2560&q=70"
2931
title="Next.js Starter"

0 commit comments

Comments
 (0)