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

Commit ebb7332

Browse files
committed
Expand preview handling prop
1 parent eac880d commit ebb7332

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

api/wordpress/_global/getPostTypeById.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ import getMenus from '../menus/getMenus'
1919
* @param {string} postType WP post type.
2020
* @param {number | string} id Post identifier.
2121
* @param {string} idType Type of ID.
22-
* @param {boolean} preview Whether checking if post preview exists.
22+
* @param {string} preview Whether query is for a regular post view (null), a preview check (basic), or full post preview (full).
2323
* @return {object} Object containing Apollo client instance and post data or error object.
2424
*/
2525
export default async function getPostTypeById(
2626
postType,
2727
id,
2828
idType = 'SLUG',
29-
preview = false
29+
preview = null
3030
) {
3131
// Define single post query based on post type.
3232
const postTypeQuery = {
@@ -99,7 +99,7 @@ export default async function getPostTypeById(
9999
slug: id
100100
}
101101

102-
if (preview || !post || !post?.blocksJSON) {
102+
if ('basic' === preview || !post || !post?.blocksJSON) {
103103
return post
104104
}
105105

pages/api/preview.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default async function preview(req, res) {
2727
post_type,
2828
id,
2929
'DATABASE_ID',
30-
true
30+
'basic'
3131
)
3232

3333
// Handle response errors.

0 commit comments

Comments
 (0)