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

Commit 9ae2436

Browse files
committed
Add fallback seo data for custom pages
1 parent 461b778 commit 9ae2436

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

api/wordpress/_global/getSettingsCustomPage.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import processPostTypeQuery from './processPostTypeQuery'
33

44
// Define single page query based on page name.
55
export const customPageQuery = {
6-
404: queryError404Page
6+
404: {
7+
query: queryError404Page,
8+
title: '404 Not Found',
9+
description: ''
10+
}
711
}
812

913
/**
@@ -15,7 +19,20 @@ export const customPageQuery = {
1519
*/
1620
export default async function getSettingsCustomPage(page) {
1721
// Retrieve page query.
18-
const query = customPageQuery?.[page] ?? null
22+
const query = customPageQuery?.[page]?.query ?? null
1923

20-
return processPostTypeQuery('page', page, query)
24+
const data = await processPostTypeQuery('page', page, query)
25+
26+
// Add custom SEO if missing.
27+
if (!data?.post?.seo) {
28+
data.post = {
29+
...data?.post,
30+
seo: {
31+
title: customPageQuery[page]?.title ?? '',
32+
description: customPageQuery[page]?.description ?? ''
33+
}
34+
}
35+
}
36+
37+
return data
2138
}

0 commit comments

Comments
 (0)