diff --git a/examples/next/getting-started/src/pages/posts/[postSlug].tsx b/examples/next/getting-started/src/pages/posts/[postSlug].tsx
index ef94986d0..81b5ed62b 100644
--- a/examples/next/getting-started/src/pages/posts/[postSlug].tsx
+++ b/examples/next/getting-started/src/pages/posts/[postSlug].tsx
@@ -2,11 +2,36 @@ import { getNextStaticProps, client, is404 } from '@wpengine/headless-next';
import { Footer, Header, Hero } from 'components';
import { GetStaticPropsContext } from 'next';
import Head from 'next/head';
+import type { Post } from '@wpengine/headless-core';
+import styles from 'scss/pages/post.module.scss';
-export default function Page() {
- const { usePost, useGeneralSettings } = client();
+export interface PostProps {
+ post: Post | Post['preview']['node'] | null | undefined;
+ preview?: boolean;
+}
+
+export function PostComponent({ post, preview }: PostProps) {
+ const { useGeneralSettings, useQuery } = client();
const generalSettings = useGeneralSettings();
- const post = usePost();
+ const { isLoading } = useQuery().$state;
+
+ if (preview && (typeof window === 'undefined' || isLoading)) {
+ return (
+ <>
+
- Learn more in the{' '} - - Headless Framework GitHub repository - - . -
-( prop: P, -): (params: ParsedUrlQuery) => params is Record
{ +): (params: HasObject) => params is Record
{ return (params): params is Record
=> { return isObject(params) && isString(params[prop]); }; @@ -14,7 +15,7 @@ function hasPropString
( function hasPropStringArray
( prop: P, -): (params: ParsedUrlQuery) => params is Record
{ +): (params: HasObject) => params is Record
{ return (params): params is Record
=> { return ( isObject(params) && isArray(params[prop]) && isString(params[prop]?.[0]) @@ -25,11 +26,9 @@ function hasPropStringArray
( export const hasPostId = hasPropString('postId'); export const hasPostSlug = hasPropString('postSlug'); export const hasPostUri = hasPropStringArray('postUri'); -export const hasPostPreviewUri = hasPropStringArray('postPreviewUri'); export const hasPageId = hasPropString('pageId'); export const hasPageUri = hasPropStringArray('pageUri'); -export const hasPagePreviewUri = hasPropStringArray('pagePreviewUri'); export const hasCategoryId = hasPropString('categoryId'); export const hasCategorySlug = hasPropString('categorySlug');