【发布时间】:2021-03-02 20:35:38
【问题描述】:
我收到了这个错误
Error: Error serializing `.remarkBody` returned from `getStaticProps` in "/blog/[slug]".
Reason: `undefined` cannot be serialized as JSON. Please use `null` or omit this value.
尝试运行时:
const body = blogPostCollection ? blogPostCollection?.items[0]?.body : ''
const remarkBody = remark().use(strip).process(body, (err, file) => {
if (err) throw err
String(file)
})
return {
props: {
remarkBody: remarkBody,
},
revalidate: 1
}
有人可以帮我解决这个问题吗?
【问题讨论】:
标签: javascript reactjs next.js markdown remarkjs