Skip to content

Commit

Permalink
docs: mention MDXContent (#7705)
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed Jul 1, 2022
1 parent ffe8a22 commit 1f47151
Showing 1 changed file with 29 additions and 1 deletion.
Expand Up @@ -200,6 +200,33 @@ We use lower-case tag names like `highlight` to "pretend" that they are intrinsi

:::

:::caution

This feature is powered by [a wrapper provider](https://mdx-git-renovate-babel-monorepo-mdx.vercel.app/advanced/components#mdxprovider). If you are importing Markdown in a React page, you have to supply this provider yourself through the `MDXContent` theme component.

```jsx title="src/pages/index.js"
import React from 'react';
import FeatureDisplay from './_featureDisplay.mdx';
// highlight-next-line
import MDXContent from '@theme/MDXContent';

export default function LandingPage() {
return (
<div>
{/* highlight-start */}
<MDXContent>
<FeatureDisplay />
</MDXContent>
{/* highlight-end */}
</div>
);
}
```

If you don't wrap your imported MDX with `MDXContent`, the global scope will not be available.

:::

### Markdown and JSX interoperability {#markdown-and-jsx-interoperability}

Docusaurus v2 is using MDX v1, which has a lot of known cases where the content fails to be correctly parsed as Markdown. Use the **[MDX playground](https://mdx-git-renovate-babel-monorepo-mdx.vercel.app/playground)** to ensure that your syntax is valid MDX.
Expand Down Expand Up @@ -420,9 +447,10 @@ Now I'm actually just text
</div>
</TabItem>
</Tabs>
</details>
```

</details>

## Importing code snippets {#importing-code-snippets}

You can not only import a file containing a component definition, but also import any code file as raw text, and then insert it in a code block, thanks to [Webpack raw-loader](https://webpack.js.org/loaders/raw-loader/). In order to use `raw-loader`, you first need to install it in your project:
Expand Down

0 comments on commit 1f47151

Please sign in to comment.