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

Commit 6915bbb

Browse files
committed
Add custom page handling to static props
1 parent f69beb2 commit 6915bbb

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

api/wordpress/_global/getPostTypeStaticProps.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import getPostTypeById from './getPostTypeById'
33
import getPostTypeArchive from './getPostTypeArchive'
44
import {addApolloState} from '@/api/apolloConfig'
55
import getFrontendPage, {frontendPageSeo} from './getFrontendPage'
6+
import getSettingsCustomPage, {customPageQuery} from './getSettingsCustomPage'
67

78
/**
89
* Retrieve static props by post type.
@@ -77,6 +78,22 @@ export default async function getPostTypeStaticProps(
7778
// Handle catch-all routes.
7879
const slug = Array.isArray(params.slug) ? params.slug.join('/') : params.slug
7980

81+
/* -- Handle pages set via Additional Settings. -- */
82+
if (Object.keys(customPageQuery).includes(slug)) {
83+
const {apolloClient, error, ...pageData} = await getSettingsCustomPage(slug)
84+
85+
return addApolloState(apolloClient, {
86+
props: {
87+
...pageData,
88+
...sharedProps,
89+
error
90+
},
91+
revalidate
92+
})
93+
}
94+
95+
/* -- Handle dynamic posts. -- */
96+
8097
// Get post identifier (ID or slug).
8198
const postId = Number.isInteger(Number(slug)) ? Number(slug) : slug
8299

0 commit comments

Comments
 (0)