Skip to content

Commit

Permalink
[mdx] remove mention of layout frontmatter property (#9474)
Browse files Browse the repository at this point in the history
Co-authored-by: Armand Philippot <[email protected]>
  • Loading branch information
sarah11918 and ArmandPhilippot authored Sep 24, 2024
1 parent 8d932ba commit dad0d33
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/content/docs/en/guides/integrations-guide/mdx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ MDX supports using `export` statements to add variables to your MDX content or t
For example, you can export a `title` field from an MDX page or component to use as a heading with `{JSX expressions}`:
```mdx title="/src/pages/posts/post-1.mdx"
```mdx title="/src/blog/posts/post-1.mdx"
export const title = 'My first MDX post'
# {title}
Expand Down Expand Up @@ -132,13 +132,15 @@ The following properties are available to a `.astro` component when using an `im
The Astro MDX integration includes support for using frontmatter in MDX by default. Add frontmatter properties just as you would in Markdown files, and these variables are available to use in the template, and as named properties when importing the file somewhere else.
```mdx title="/src/pages/posts/post-1.mdx"
```mdx title="/src/blog/posts/post-1.mdx"
---
layout: '../../layouts/BlogPostLayout.astro'
title: 'My first MDX post'
author: 'Houston'
---
# {frontmatter.title}
Written by: {frontmatter.author}
```
### Using Components in MDX
Expand All @@ -149,22 +151,18 @@ Don't forget to include a `client:directive` on your UI framework components, if
See more examples of using import and export statements in the [MDX docs](https://mdxjs.com/docs/what-is-mdx/#esm).
```mdx title="src/pages/about.mdx" {5-6} /<.+\/>/
```mdx title="src/blog/post-1.mdx" {4,9}
---
layout: ../layouts/BaseLayout.astro
title: About me
title: My first post
---
import Button from '../components/Button.astro';
import ReactCounter from '../components/ReactCounter.jsx';
I live on **Mars** but feel free to <Button title="Contact me" />.
I just started my new Astro blog!
Here is my counter component, working in MDX:
<ReactCounter client:load />
```
#### Custom components with imported MDX
When rendering imported MDX content, [custom components](#assigning-custom-components-to-html-elements) can be passed via the `components` prop.
Expand All @@ -188,7 +186,7 @@ With MDX, you can map Markdown syntax to custom components instead of their stan
Import your custom component into your `.mdx` file, then export a `components` object that maps the standard HTML element to your custom component:
```mdx title="src/pages/about.mdx"
```mdx title="src/blog/posts/post-1.mdx"
import Blockquote from '../components/Blockquote.astro';
export const components = {blockquote: Blockquote}
Expand Down

0 comments on commit dad0d33

Please sign in to comment.