-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to reference frontmatter fields inside MDX #21241
Comments
Maybe docs need to be updated?
|
The guide you're referring to refers to pages in However, it looks like you're using a programmatically created page, so you'd need to pass the queried frontmatter directly into MDXRenderer to add it to the scope of MDX. It looks like that step is missing from the docs. Would you be interested in adding it? |
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. Thanks for being a part of the Gatsby community! 💪💜 |
Hey again! It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Thanks again for being part of the Gatsby community! 💪💜 |
this must be definitely mentioned in the documentation, I had same problem as I generate all pages based on md, mdx files :) |
I've run into the same problem - on top of that, passing In my post component: In my
Running
|
Updating gatsby documentation to tell the user to pass frontmatter in MDXRenderer component. As suggested in this issue: gatsbyjs#21241
Updating gatsby documentation to tell the user to pass frontmatter in MDXRenderer component. As suggested in this issue: gatsbyjs#21241
## Description Updating gatsby documentation to tell the user to pass frontmatter in MDXRenderer component. As suggested in this issue: gatsbyjs#21241 ### Documentation docs here: https://www.gatsbyjs.com/docs/mdx/programmatically-creating-pages/ @gatsbyjs/documentation please review ## Related Issues Fixes gatsbyjs#21241
Description
Documentation states https://www.gatsbyjs.org/docs/mdx/writing-pages/
that Frontmatter is also available in props.pageContext.frontmatter and can be accessed in blocks of JSX in your MDX document:
When I try to read my frontmatter inside mdx I get an error:
Cannot read property 'frontmatter' of undefined
System:
OS: macOS 10.15.2
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.14.1 - /usr/local/bin/node
npm: 6.13.4 - /usr/local/bin/npm
Languages:
Python: 2.7.16 - /usr/bin/python
npmPackages:
gatsby: ^2.15.15 => 2.15.15
gatsby-image: ^2.2.19 => 2.2.19
gatsby-plugin-alias-imports: ^1.0.5 => 1.0.5
gatsby-plugin-catch-links: ^2.1.9 => 2.1.9
gatsby-plugin-facebook-pixel: ^1.0.3 => 1.0.3
gatsby-plugin-google-analytics: ^2.1.16 => 2.1.16
gatsby-plugin-google-gtag: ^1.1.8 => 1.1.8
gatsby-plugin-mdx: ^1.0.41 => 1.0.41
gatsby-plugin-react-helmet: ^3.1.7 => 3.1.7
gatsby-plugin-sharp: ^2.2.22 => 2.2.22
gatsby-plugin-sitemap: ^2.2.12 => 2.2.12
gatsby-plugin-styled-components: ^3.1.5 => 3.1.5
gatsby-remark-autolink-headers: ^2.1.10 => 2.1.10
gatsby-remark-copy-linked-files: ^2.1.19 => 2.1.19
gatsby-remark-images: ^3.1.22 => 3.1.22
gatsby-source-filesystem: ^2.1.22 => 2.1.22
gatsby-transformer-json: ^2.2.25 => 2.2.25
gatsby-transformer-remark: ^2.6.22 => 2.6.22
gatsby-transformer-sharp: ^2.2.14 => 2.2.14
npmGlobalPackages:
gatsby-cli: 2.8.29
The text was updated successfully, but these errors were encountered: