Closed jasongerbes closed 1 year ago
I can confirm your findings and I think I found the problem, there is space between the first line of frontmatter "---" and the opening of the template literal, if you change the example to this:
const { content, frontmatter } = await compileMDX({
source: `---
title: RSC Frontmatter Example
---
This is from Server Components!`,
options: { parseFrontmatter: true },
});
then it should work
on top of the readme the example for the pages directory getStaticProps is correct the new ones are not
I got suspicious when I tried to load the content from a file and it actually worked with the same MDX file but when using the template literal it didn't anymore, so I knew it had something to do with its formatting
@chrisweb you're right that it was an issue with whitespace. However, you also need to remove the whitespace before the other lines of the source:
const { content, frontmatter } = await compileMDX({
source: `---
title: RSC Frontmatter Example
---
This is from Server Components!`,
options: { parseFrontmatter: true },
});
Expected behaviour
Using the
compileMDX
method ofnext-mdx-remote/rsc
withparseFrontmatter: true
, the expected behaviour is that any frontmatter should be parsed from the MDX source.Actual behaviour
The
parseFrontmatter
option has no affect on thecontent
returned bycompileMDX
, and thefrontmatter
value is always{}
.Reproduction steps
Minimal reproduction here: https://github.com/jasongerbes/next-mdx-remote-rsc
This reproduction uses the "Access Frontmatter outside of MDX" example from the README with a couple of fixes:
await