Switched Gatsby blog from .md to .mdx — Now my blog-post.js template doesn't return a post title (from front matter) outside of <MDXRenderer>{post.body}</MDXRenderer> #26523
Unanswered
oliverholms
asked this question in
Help
Replies: 1 comment
-
Did you ever sort this out? I am running into what I believe may be the same issue. I keep getting this error in build:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
#8413 Summary
I converted my Gatsby blog from using
.md
to.mdx
usinggatsby-plugin-mdx
and following the How to convert an existing Gatsby blog to use MDX tutorial by Thomas Wang.When I ran
gatsby develop
I lost the post layout and the generated post title (which came from the frontmatter) for my posts.I was previously using
dangerouslySetInnerHTML
and the same template (apart from the changes specified in the above tutorial) and it worked as expected with.md
files.I think that it is something to do with
<MDXRenderer>{post.body}</MDXRenderer>
ignoring the code outside of it when creating the page with myblog-post.js
template.I have got the layout back by declaring a default layout in the plugin options within my
gatsby-config
but I can't get the title back. I know that I can just write a heading into the.mdx
but I want it generated automatically. Ideally, I would like to access my<Layout />
component from inside theblog-post.js
template, so that I don't have to set it from within thegatsby-config
plugin options too.Relevant information
My
blog-post.js
post templategatsby-node.js
`gatsby-config.js
Example
.mdx
Environment (if relevant)
Beta Was this translation helpful? Give feedback.
All reactions