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