Skip to content

Commit

Permalink
add default null for cms-datocms post fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
followbl committed Mar 11, 2020
1 parent 9d9f7a5 commit 3f05144
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/cms-datocms/pages/index.js
Expand Up @@ -36,7 +36,7 @@ export default function Index({ allPosts }) {
}

export async function getStaticProps({ preview }) {
const allPosts = await getAllPostsForHome(preview)
const allPosts = await getAllPostsForHome(preview) || []
return {
props: { allPosts },
}
Expand Down
2 changes: 1 addition & 1 deletion examples/cms-datocms/pages/posts/[slug].js
Expand Up @@ -50,7 +50,7 @@ export default function Post({ post, morePosts, preview }) {
)
}

export async function getStaticProps({ params, preview }) {
export async function getStaticProps({ params, preview = null }) {
const data = await getPostAndMorePosts(params.slug, preview)
const content = await markdownToHtml(data?.post?.content || '')

Expand Down

0 comments on commit 3f05144

Please sign in to comment.