zslabs / gatsby-plugin-mdx-frontmatter

Utility to parse Markdown frontmatter with MDX in Gatsby
MIT License
12 stars 2 forks source link

Handle optional fields #2

Closed zvan closed 3 years ago

zvan commented 3 years ago

I'm working on a project and found your plugin. My MDX fields are optional in Netlify CMS.

I'm changing Gatsbys schema with

...
body: String @mdx
...

that resulted in build error whenever the field was undefined

Error: TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer,
   TypedArray, or DataView. Received undefined

I managed to fix build errors with returning null.

zslabs commented 3 years ago

Thanks!