`)的数组,类型为:`{ depth: number; slug: string; text: string }[]`。每个标题的 `slug` 都对应了给定标题生成的 ID,可用于锚链接。
+- **``** - 返回文件完整渲染内容的组件。
+- **(任意的 `export` 值)** - MDX 文件还可以使用 `export` 语句以导出数据。
+
+### 在 MDX 中使用 Frontmatter 变量
+
+Astro MDX 集成默认支持在 MDX 中使用 frontmatter。在 Markdown 文件中添加 frontmatter 属性,这些变量可在模板中以及在导入文件时以命名属性的形式访问。
+
+```mdx title="/src/pages/posts/post-1.mdx"
+---
+layout: '../../layouts/BlogPostLayout.astro'
+title: '我的第一篇 MDX 文章'
+---
+
+# {frontmatter.title}
+```
+
+### 在 MDX 中使用组件
+
+安装 MDX 集成后,你可以在 MDX (`.mdx`) 文件中导入并使用 [Astro 组件](/zh-cn/basics/astro-components/)和 [UI 框架组件](/zh-cn/guides/framework-components/#使用框架组件)。就像在任何其他 Astro 组件中使用它们一样。
+
+别忘了在你的 UI 框架组件上添加 `client:directive`,如果需要的话!
+
+在 [MDX 文档](https://mdxjs.com/docs/what-is-mdx/#esm)中查看有关使用导入和导出语句的更多示例。
+
+```mdx title="src/pages/about.mdx" {5-6} /<.+\/>/
+---
+layout: ../layouts/BaseLayout.astro
+title: 关于我
+---
+import Button from '../components/Button.astro';
+import ReactCounter from '../components/ReactCounter.jsx';
+
+我住在 **火星** 上,但是随时可以 。
+
+这是我的计数器组件,它在 MDX 中工作:
+
+
+```
+
+#### 使用导入的 MDX 自定义组件
+
+渲染导入的 MDX 内容时,可以通过 `components` 属性传递 [自定义组件](#将自定义组件分配给-HTML-元素)。
+
+```astro title="src/pages/page.astro" "components={{...components, h1: Heading }}"
+---
+import { Content, components } from '../content.mdx';
+import Heading from '../Heading.astro';
+---
+
+
+```
+
+:::note
+Custom components defined and exported in an MDX file must be imported and then passed back to the `` component via the `components` property.
+:::
+
+#### Assigning Custom Components to HTML elements
+
+With MDX, you can map Markdown syntax to custom components instead of their standard HTML elements. This allows you to write in standard Markdown syntax, but apply special component styling to selected elements.
+
+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"
+import Blockquote from '../components/Blockquote.astro';
+export const components = {blockquote: Blockquote}
+
+> This quote will be a custom Blockquote
+```
+
+```astro title="src/components/Blockquote.astro"
+---
+const props = Astro.props;
+---
+
+ “
+
+
+```
+Visit the [MDX website](https://mdxjs.com/table-of-components/) for a full list of HTML elements that can be overwritten as custom components.
## 配置
From 1b41d9ddc704dc2bf92c40b49e478e48f5992035 Mon Sep 17 00:00:00 2001
From: Nin3 <30520689+Nin3lee@users.noreply.github.com>
Date: Wed, 11 Sep 2024 14:24:48 +0800
Subject: [PATCH 2/8] i18n(zh-cn): Update `mdx.mdx`
---
.../docs/zh-cn/guides/integrations-guide/mdx.mdx | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/content/docs/zh-cn/guides/integrations-guide/mdx.mdx b/src/content/docs/zh-cn/guides/integrations-guide/mdx.mdx
index da24b7a8663b0..352012f3d8584 100644
--- a/src/content/docs/zh-cn/guides/integrations-guide/mdx.mdx
+++ b/src/content/docs/zh-cn/guides/integrations-guide/mdx.mdx
@@ -172,25 +172,25 @@ import ReactCounter from '../components/ReactCounter.jsx';
import { Content, components } from '../content.mdx';
import Heading from '../Heading.astro';
---
-
+
```
:::note
-Custom components defined and exported in an MDX file must be imported and then passed back to the `` component via the `components` property.
+在 MDX 文件中定义并导出的自定义组件必须通过 `components` 属性导入并传递回 `` 组件。
:::
-#### Assigning Custom Components to HTML elements
+#### 将自定义组件分配给 HTML 元素
-With MDX, you can map Markdown syntax to custom components instead of their standard HTML elements. This allows you to write in standard Markdown syntax, but apply special component styling to selected elements.
+使用 MDX,你可以将 Markdown 语法映射到自定义组件,而不是它们的标准 HTML 元素。这允许你以标准的 Markdown 语法编写,但是将特殊的组件样式应用于所选的元素。
-Import your custom component into your `.mdx` file, then export a `components` object that maps the standard HTML element to your custom component:
+将自定义组件导入 `.mdx`文件,然后将标准 HTML 元素映射到自定义组件的 `components` 对象以导出:
```mdx title="src/pages/about.mdx"
import Blockquote from '../components/Blockquote.astro';
export const components = {blockquote: Blockquote}
-> This quote will be a custom Blockquote
+> 这个引用将是自定义引用块组件。
```
```astro title="src/components/Blockquote.astro"
@@ -199,10 +199,10 @@ const props = Astro.props;
---
“
-
+
```
-Visit the [MDX website](https://mdxjs.com/table-of-components/) for a full list of HTML elements that can be overwritten as custom components.
+访问 [MDX 网站](https://mdxjs.com/table-of-components/),了解可以覆盖为自定义组件的 HTML 元素的完整列表。
## 配置
From 74c4c0d4739a2dea78b387ceeb024bf3c2e2b91a Mon Sep 17 00:00:00 2001
From: Nin3 <30520689+Nin3lee@users.noreply.github.com>
Date: Wed, 11 Sep 2024 14:29:13 +0800
Subject: [PATCH 3/8] Update mdx.mdx
---
src/content/docs/zh-cn/guides/integrations-guide/mdx.mdx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/content/docs/zh-cn/guides/integrations-guide/mdx.mdx b/src/content/docs/zh-cn/guides/integrations-guide/mdx.mdx
index 352012f3d8584..3be448963a14e 100644
--- a/src/content/docs/zh-cn/guides/integrations-guide/mdx.mdx
+++ b/src/content/docs/zh-cn/guides/integrations-guide/mdx.mdx
@@ -336,7 +336,7 @@ export default defineConfig({