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 ( + <> +
+ +
+
+
Loading...
+
+
+