Hello world! This is my content I want to reuse across pages.
使用绝对路径或相对路径,将该片段导入目标文件中。
---title: "An example page"description: "This is an example page that imports a snippet."---import MySnippet from "/shared/my-snippet.mdx";The snippet content displays beneath this sentence.<MySnippet />
---title: "An example page"description: "This is an example page that imports a snippet."---import MySnippet from "../shared/my-snippet.mdx";The snippet content displays beneath this sentence.<MySnippet />
import ChildSnippet from "/shared/child-snippet.mdx";此片段会在这句话下方渲染另一个片段。<ChildSnippet />
在目标文件中只导入父级片段。你无需导入嵌套片段。
destination-file.mdx
---title: "An example page"description: "This is an example page that imports a snippet containing a nested snippet."---import ParentSnippet from "/shared/parent-snippet.mdx";<ParentSnippet />