Unverified Commit b41f9baa authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

Fix up CMS examples (#12840)

parent f1423518
......@@ -59,8 +59,8 @@ export async function getStaticProps({ params, preview = false }) {
return {
props: {
preview,
post: data?.post,
morePosts: data?.morePosts,
post: data?.post ?? null,
morePosts: data?.morePosts ?? null,
},
}
}
......@@ -68,7 +68,7 @@ export async function getStaticProps({ params, preview = false }) {
export async function getStaticPaths() {
const allPosts = await getAllPostsWithSlug()
return {
paths: allPosts?.map(({ slug }) => `/posts/${slug}`) || [],
paths: allPosts?.map(({ slug }) => `/posts/${slug}`) ?? [],
fallback: true,
}
}
......@@ -35,7 +35,7 @@ export default function Index({ allPosts }) {
)
}
export async function getStaticProps({ preview }) {
export async function getStaticProps({ preview = false }) {
const allPosts = (await getAllPostsForHome(preview)) || []
return {
props: { allPosts },
......
......@@ -50,7 +50,7 @@ export default function Post({ post, morePosts, preview }) {
)
}
export async function getStaticProps({ params, preview = null }) {
export async function getStaticProps({ params, preview = false }) {
const data = await getPostAndMorePosts(params.slug, preview)
const content = await markdownToHtml(data?.post?.content || '')
......@@ -61,7 +61,7 @@ export async function getStaticProps({ params, preview = null }) {
...data?.post,
content,
},
morePosts: data?.morePosts,
morePosts: data?.morePosts ?? [],
},
}
}
......
......@@ -35,7 +35,7 @@ export default function Index({ preview, allPosts }) {
)
}
export async function getStaticProps({ preview, previewData }) {
export async function getStaticProps({ preview = false, previewData }) {
const allPosts = await getAllPostsForHome(previewData)
return {
props: { preview, allPosts },
......
......@@ -52,14 +52,14 @@ export default function Post({ post, morePosts, preview }) {
)
}
export async function getStaticProps({ params, preview, previewData }) {
export async function getStaticProps({ params, preview = false, previewData }) {
const data = await getPostAndMorePosts(params.slug, previewData)
return {
props: {
preview,
post: data?.post,
morePosts: data?.morePosts,
post: data?.post ?? null,
morePosts: data?.morePosts ?? [],
},
}
}
......
......@@ -54,8 +54,8 @@ export async function getStaticProps({ params, preview = false }) {
return {
props: {
preview,
post: data.post || null,
morePosts: data.morePosts || null,
post: data?.post || null,
morePosts: data?.morePosts || null,
},
}
}
......
......@@ -35,7 +35,7 @@ export default function Index({ allPosts, preview }) {
)
}
export async function getStaticProps({ preview = null }) {
export async function getStaticProps({ preview = false }) {
const allPosts = await getAllPostsForHome(preview)
return {
props: { allPosts, preview },
......
......@@ -59,7 +59,7 @@ export default function Post({ post, morePosts, preview }) {
)
}
export async function getStaticProps({ params, preview = null }) {
export async function getStaticProps({ params, preview = false }) {
const data = await getPostAndMorePosts(params.slug, preview)
const content = await markdownToHtml(
(data?.post?.items || [])[0]?.content || ''
......@@ -72,7 +72,7 @@ export async function getStaticProps({ params, preview = null }) {
...(data?.post?.items || [])[0],
content,
},
morePosts: data?.morePosts.items,
morePosts: data?.morePosts.items ?? [],
},
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment