"}),"): use regular link syntax instead (",(0,r.jsx)(n.code,{children:"[http://localhost:3000](http://localhost:3000)"}),")"]}),"\n",(0,r.jsxs)(n.li,{children:["HTML syntax (",(0,r.jsx)(n.code,{children:''}),"): use JSX instead (",(0,r.jsx)(n.code,{children:"
"}),")"]}),"\n",(0,r.jsxs)(n.li,{children:["Unescaped ",(0,r.jsx)(n.code,{children:"{"})," and ",(0,r.jsx)(n.code,{children:"<"}),": escape them with ",(0,r.jsx)(n.code,{children:"\\"})," instead (",(0,r.jsx)(n.code,{children:"\\{"})," and ",(0,r.jsx)(n.code,{children:"\\<"}),")"]}),"\n"]}),"\n",(0,r.jsxs)(n.admonition,{title:"Experimental CommonMark support",type:"danger",children:[(0,r.jsxs)(n.p,{children:["Docusaurus v3 makes it possible to opt-in for a less strict, standard ",(0,r.jsx)(n.a,{href:"https://commonmark.org/",children:"CommonMark"})," support with the following options:"]}),(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["The ",(0,r.jsx)(n.code,{children:"format: md"})," front matter"]}),"\n",(0,r.jsxs)(n.li,{children:["The ",(0,r.jsx)(n.code,{children:".md"})," file extension combined with the ",(0,r.jsx)(n.code,{children:'siteConfig.markdown.format: "detect"'})," configuration"]}),"\n"]}),(0,r.jsxs)(n.p,{children:["This feature is ",(0,r.jsx)(n.strong,{children:"experimental"})," and currently has a few ",(0,r.jsx)(n.a,{href:"https://github.com/facebook/docusaurus/issues/9092",children:"limitations"}),"."]})]}),"\n",(0,r.jsx)(n.h2,{id:"importing-code-snippets",children:"Importing code snippets"}),"\n",(0,r.jsxs)(n.p,{children:["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 ",(0,r.jsx)(n.a,{href:"https://webpack.js.org/loaders/raw-loader/",children:"Webpack raw-loader"}),". In order to use ",(0,r.jsx)(n.code,{children:"raw-loader"}),", you first need to install it in your project:"]}),"\n",(0,r.jsxs)(i.Z,{groupId:"npm2yarn",children:[(0,r.jsx)(c.Z,{value:"npm",children:(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"npm install --save raw-loader\n"})})}),(0,r.jsx)(c.Z,{value:"yarn",label:"Yarn",children:(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"yarn add raw-loader\n"})})}),(0,r.jsx)(c.Z,{value:"pnpm",label:"pnpm",children:(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"pnpm add raw-loader\n"})})})]}),"\n",(0,r.jsx)(n.p,{children:"Now you can import code snippets from another file as it is:"}),"\n","\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-jsx",metastring:'title="myMarkdownFile.mdx"',children:"import CodeBlock from '@theme/CodeBlock';\nimport MyComponentSource from '!!raw-loader!./myComponent';\n\n{MyComponentSource}\n"})}),"\n","\n",(0,r.jsx)(s.Z,{children:(0,r.jsx)(a.Z,{language:"jsx",children:l.Z})}),"\n",(0,r.jsxs)(n.p,{children:["See ",(0,r.jsx)(n.a,{href:"/docs/markdown-features/code-blocks#usage-in-jsx",children:"using code blocks in JSX"})," for more details of the ",(0,r.jsx)(n.code,{children:""})," component."]}),"\n",(0,r.jsx)(n.admonition,{type:"note",children:(0,r.jsxs)(n.p,{children:["You have to use ",(0,r.jsx)(n.code,{children:""})," rather than the Markdown triple-backtick ",(0,r.jsx)(n.code,{children:"```"}),", because the latter will ship out any of its content as-is, but you want to interpolate the imported text here."]})}),"\n",(0,r.jsx)(n.admonition,{type:"warning",children:(0,r.jsx)(n.p,{children:"This feature is experimental and might be subject to breaking API changes in the future."})}),"\n",(0,r.jsx)(n.h2,{id:"importing-markdown",children:"Importing Markdown"}),"\n",(0,r.jsx)(n.p,{children:"You can use Markdown files as components and import them elsewhere, either in Markdown files or in React pages."}),"\n",(0,r.jsxs)(n.p,{children:["By convention, using the ",(0,r.jsxs)(n.strong,{children:[(0,r.jsx)(n.code,{children:"_"})," filename prefix"]})," will not create any doc page and means the Markdown file is a ",(0,r.jsx)(n.strong,{children:'"partial"'}),", to be imported by other files."]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-md",metastring:'title="_markdown-partial-example.mdx"',children:"Hello {props.name}\n\nThis is text some content from `_markdown-partial-example.mdx`.\n"})}),"\n","\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-jsx",metastring:'title="someOtherDoc.mdx"',children:"import PartialExample from './_markdown-partial-example.mdx';\n\n\n"})}),"\n","\n",(0,r.jsx)(s.Z,{children:(0,r.jsx)(d,{name:"Sebastien"})}),"\n",(0,r.jsx)(n.p,{children:"This way, you can reuse content among multiple pages and avoid duplicating materials."}),"\n",(0,r.jsx)(n.admonition,{type:"warning",children:(0,r.jsxs)(n.p,{children:["Currently, the table of contents does not contain the imported Markdown headings. This is a technical limitation that we are trying to solve (",(0,r.jsx)(n.a,{href:"https://github.com/facebook/docusaurus/issues/3915",children:"issue"}),")."]})}),"\n",(0,r.jsx)(n.h2,{id:"available-exports",children:"Available exports"}),"\n",(0,r.jsx)(n.p,{children:"Within the MDX page, the following variables are available as globals:"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"frontMatter"}),": the front matter as a record of string keys and values;"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"toc"}),": the table of contents, as a tree of headings. See also ",(0,r.jsx)(n.a,{href:"/docs/markdown-features/toc#inline-table-of-contents",children:"Inline TOC"})," for a more concrete use-case."]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"contentTitle"}),": the Markdown title, which is the first ",(0,r.jsx)(n.code,{children:"h1"})," heading in the Markdown text. It's ",(0,r.jsx)(n.code,{children:"undefined"})," if there isn't one (e.g. title specified in the front matter)."]}),"\n"]}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-jsx",children:"import TOCInline from '@theme/TOCInline';\nimport CodeBlock from '@theme/CodeBlock';\n\nThe table of contents for this page, serialized:\n\n{JSON.stringify(toc, null, 2)}\n\nThe front matter of this page:\n\n\n {Object.entries(frontMatter).map(([key, value]) => - {key}: {value}
)}\n
\n\nThe title of this page is: {contentTitle}
\n"})}),"\n","\n",(0,r.jsxs)(s.Z,{children:[(0,r.jsx)(n.p,{children:"The table of contents for this page, serialized:"}),(0,r.jsx)(a.Z,{className:"language-json",children:JSON.stringify(g,null,2)}),(0,r.jsx)(n.p,{children:"The front matter of this page:"}),(0,r.jsx)("ul",{children:Object.entries(p).map((([e,t])=>(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.b,{children:e}),": ",t]},e)))}),(0,r.jsxs)("p",{children:["The title of this page is: ",(0,r.jsx)("b",{children:h})]})]})]})}function y(e={}){const{wrapper:n}={...(0,o.a)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(j,{...e})}):j(e)}}}]);