I am currently importing mdx files using the gatsby-plugin-mdx plugin and rendering them as pages using createPage. In the GraphQL query I have access to the ast tree:
const { mdx } = data
const {
frontmatter: { title, description, excerpt },
body,
mdxAST
} = mdx
However I would like to import the mdx directly for use with @reach/router inclusion as a component instead of having it prewrapped as a page. So I do:
import FAQ, { _frontmatter } from 'components/mdx/faq.mdx'
This gives me the frontmatter and a component containing the transformed markdown. But the AST tree is not available in this export.
How can I either:
- get the ast tree
- make use of a plugin to transform the mdx files but not as a full page. Somehow make them available as components.