Gray-matter options?
See original GitHub issuemdx-bundler
version: 5.1.2node
version: 14.17.3npm
version: 6.14.13
Relevant code or config
---
title: Test Post
published: 2021-02-13
description: Shows how a post is published via MDX
---
# Test Post
This is a test post
What you did:
I’m using mdx-bundler to build a nextjs static site. My frontmatter contains some date-looking things. I pass the frontmatter returned by bundleMDX
as props for my component.
What happened: Since its a static site, Nextjs tries to serialize the props as part of the component and fails because it isn’t JSON serializable:
Error: Error serializing `.frontmatter.published` returned from `getStaticProps` in "/posts/[slug]".
Reason: `object` ("[object Date]") cannot be serialized as JSON. Please only return JSON serializable data types.
Problem description: There’s no way to configure the default gray-matter engine behavior.
Suggested solution: I guess the most obvious thing is to provide the ability to pass options to gray-matter.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
Parse front-matter from a string or file. Fast, reliable ... - GitHub
Instead of defining the language on the options, gray-matter will automatically detect the language defined after the first delimiter and select the correct ......
Read more >gray-matter - npm
Parses YAML front matter by default, but also has support for YAML, JSON, TOML or Coffee Front-Matter, with options to set custom delimiters ......
Read more >Strategic Partners | GrayMatter
100 Global View Drive Warrendale, PA 15086. Call: 877-741-2410. eFax: 412-202-5053. © 2022 GrayMatter | All Rights Reserved. Privacy policy.
Read more >WHO WE ARE | GrayMatter
We focus on co-innovation and curating the best process and technology to drive industrial companies and utilities through digital transformation. Who does ...
Read more >GrayMatter: Home
GrayMatter is dedicated to transforming operations and empowering people. We help your people and your industrial assets become smarter and more visible.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
FYI - since I ran into the same issue and am a little new to gray-matter/MDX processing, after jumping thru the google-sphere to get answers I felt dropping an example usage of graymatterOptions that solves the original question would be helpful to others:
This returns published as a string, not a date, which is typical for most JSON-parsed results anyway.
If you’re using
matter
elsewhere, use the same thing (hence the whole point of grayMatterOptions):Thanks to @Arcath and @jpaas for the solution and original question 😃
@barrymay You are a legend. Thanks for this tidbit! Got me going again!