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

Commit c95747f

Browse files
committed
Add handling for search page data
1 parent 7985595 commit c95747f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

api/wordpress/_global/getPostTypeStaticProps.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import getPostTypeArchive from './getPostTypeArchive'
44
import {addApolloState} from '@/api/apolloConfig'
55
import getMenus from '@/api/wordpress/menus/getMenus'
66
import config from '@/functions/config'
7+
import getFrontendPage, {frontendPageSeo} from './getFrontendPage'
78

89
/**
910
* Retrieve static props by post type.
@@ -33,6 +34,19 @@ export default async function getPostTypeStaticProps(
3334
}
3435
}
3536

37+
// Check for Frontend-only routes.
38+
if (Object.keys(frontendPageSeo).includes(postType)) {
39+
const {apolloClient, ...routeData} = await getFrontendPage(postType)
40+
41+
return addApolloState(apolloClient, {
42+
props: {
43+
...routeData,
44+
...sharedProps
45+
},
46+
revalidate
47+
})
48+
}
49+
3650
// Check for dynamic archive display.
3751
if (!Object.keys(params).length) {
3852
const {apolloClient, ...archiveData} = await getPostTypeArchive(postType)

pages/search.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default function Search({post}) {
3636
* @return {object} Post props.
3737
*/
3838
export async function getStaticProps() {
39-
return await getPostTypeStaticProps({slug: '/'}, 'search')
39+
return await getPostTypeStaticProps(null, 'search')
4040
}
4141

4242
Search.propTypes = {

0 commit comments

Comments
 (0)