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