mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-08 06:37:18 +02:00
1 line
No EOL
42 KiB
JavaScript
1 line
No EOL
42 KiB
JavaScript
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([["59172"],{41918:function(e,n,t){t.d(n,{Z:function(){return r}});let r="/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport React, {useState} from 'react';\n\nexport default function MyComponent() {\n const [bool, setBool] = useState(false);\n return (\n <div>\n <p>MyComponent rendered !</p>\n <p>bool={bool ? 'true' : 'false'}</p>\n <p>\n <button onClick={() => setBool((b) => !b)}>toggle bool</button>\n </p>\n </div>\n );\n}\n"},2242:function(e,n,t){t.r(n),t.d(n,{Highlight:()=>f,metadata:()=>r,contentTitle:()=>p,default:()=>b,assets:()=>x,toc:()=>g,frontMatter:()=>m});var r=JSON.parse('{"id":"guides/markdown-features/react","title":"MDX and React","description":"Using the power of React in Docusaurus Markdown documents, thanks to MDX","source":"@site/docs/guides/markdown-features/markdown-features-react.mdx","sourceDirName":"guides/markdown-features","slug":"/markdown-features/react","permalink":"/docs/markdown-features/react","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/edit/main/website/docs/guides/markdown-features/markdown-features-react.mdx","tags":[],"version":"current","lastUpdatedBy":"Zen","lastUpdatedAt":1734100074000,"frontMatter":{"id":"react","description":"Using the power of React in Docusaurus Markdown documents, thanks to MDX","slug":"/markdown-features/react"},"sidebar":"docs","previous":{"title":"Markdown Features","permalink":"/docs/markdown-features"},"next":{"title":"Tabs","permalink":"/docs/markdown-features/tabs"}}'),o=t("24246"),s=t("80980"),i=t("11678"),a=t("46291"),l=t("67860"),c=t("45960"),d=t("41918");function u(e){let n={code:"code",p:"p",...(0,s.a)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("span",{children:["Hello ",e.name]}),"\n",(0,o.jsxs)(n.p,{children:["This is text some content from ",(0,o.jsx)(n.code,{children:"_markdown-partial-example.md"}),"."]})]})}function h(e={}){let{wrapper:n}={...(0,s.a)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(u,{...e})}):u(e)}t("86411");let m={id:"react",description:"Using the power of React in Docusaurus Markdown documents, thanks to MDX",slug:"/markdown-features/react"},p="MDX and React",x={},f=({children:e,color:n})=>(0,o.jsx)("span",{style:{backgroundColor:n,borderRadius:"2px",color:"#fff",padding:"0.2rem"},children:e}),g=[{value:"Exporting components",id:"exporting-components",level:3},{value:"Importing components",id:"importing-components",level:3},{value:"MDX component scope",id:"mdx-component-scope",level:3},{value:"Markdown and JSX interoperability",id:"markdown-and-jsx-interoperability",level:3},{value:"Importing code snippets",id:"importing-code-snippets",level:2},{value:"Importing Markdown",id:"importing-markdown",level:2},{value:"Available exports",id:"available-exports",level:2}];function j(e){let n={a:"a",admonition:"admonition",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,s.a)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.header,{children:(0,o.jsx)(n.h1,{id:"mdx-and-react",children:"MDX and React"})}),"\n","\n",(0,o.jsxs)(n.p,{children:["Docusaurus has built-in support for ",(0,o.jsx)(n.a,{href:"https://mdxjs.com/",children:"MDX"}),", which allows you to write JSX within your Markdown files and render them as React components."]}),"\n",(0,o.jsxs)(n.p,{children:["Check out the ",(0,o.jsx)(n.a,{href:"https://mdxjs.com/",children:"MDX docs"})," to see what fancy stuff you can do with MDX."]}),"\n",(0,o.jsxs)(n.admonition,{title:"Debugging MDX",type:"tip",children:[(0,o.jsx)(n.p,{children:"The MDX format is quite strict, and you may get compilation errors."}),(0,o.jsxs)(n.p,{children:["Use the ",(0,o.jsx)(n.strong,{children:(0,o.jsx)(n.a,{href:"https://mdxjs.com/playground/",children:"MDX playground"})})," to debug them and make sure your syntax is valid."]})]}),"\n",(0,o.jsx)(n.admonition,{type:"info",children:(0,o.jsxs)(n.p,{children:["Prettier, the most popular formatter, ",(0,o.jsx)(n.a,{href:"https://github.com/prettier/prettier/issues/12209",children:"supports only the legacy MDX v1"}),". If you get an unintentional formatting result, you may want to add ",(0,o.jsx)(n.code,{children:"{/* prettier-ignore */}"})," before the problematic area, or add ",(0,o.jsx)(n.code,{children:"*.mdx"})," to your ",(0,o.jsx)(n.code,{children:".prettierignore"}),", until Prettier has proper support for MDX v3. ",(0,o.jsxs)(n.a,{href:"https://github.com/orgs/mdx-js/discussions/2067",children:["One of the main authors of MDX recommends ",(0,o.jsx)(n.code,{children:"remark-cli"})," with ",(0,o.jsx)(n.code,{children:"remark-mdx"})]}),"."]})}),"\n",(0,o.jsx)(n.h3,{id:"exporting-components",children:"Exporting components"}),"\n",(0,o.jsxs)(n.p,{children:["To define any custom component within an MDX file, you have to export it: only paragraphs that start with ",(0,o.jsx)(n.code,{children:"export"})," will be parsed as components instead of prose."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-jsx",children:"export const Highlight = ({children, color}) => (\n <span\n style={{\n backgroundColor: color,\n borderRadius: '2px',\n color: '#fff',\n padding: '0.2rem',\n }}>\n {children}\n </span>\n);\n\n<Highlight color=\"#25c2a0\">Docusaurus green</Highlight> and <Highlight color=\"#1877F2\">Facebook blue</Highlight> are my favorite colors.\n\nI can write **Markdown** alongside my _JSX_!\n"})}),"\n",(0,o.jsx)(n.p,{children:"Notice how it renders both the markup from your React component and the Markdown syntax:"}),"\n","\n",(0,o.jsxs)(i.Z,{minHeight:240,children:[(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(f,{color:"#25c2a0",children:"Docusaurus green"}),"\n"," ","and ",(0,o.jsx)(f,{color:"#1877F2",children:"Facebook blue"})," are my favorite colors."]}),(0,o.jsxs)(n.p,{children:["I can write ",(0,o.jsx)(n.strong,{children:"Markdown"})," alongside my ",(0,o.jsx)(n.em,{children:"JSX"}),"!"]})]}),"\n",(0,o.jsxs)(n.admonition,{title:"MDX is JSX",type:"warning",children:[(0,o.jsx)(n.p,{children:"Since all doc files are parsed using MDX, anything that looks like HTML is actually JSX. Therefore, if you need to inline-style a component, follow JSX flavor and provide style objects."}),(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-jsx",children:"/* Instead of this: */\n<span style=\"background-color: red\">Foo</span>\n/* Use this: */\n<span style={{backgroundColor: 'red'}}>Foo</span>\n"})})]}),"\n",(0,o.jsx)(n.h3,{id:"importing-components",children:"Importing components"}),"\n",(0,o.jsx)(n.p,{children:"You can also import your own components defined in other files or third-party components installed via npm."}),"\n","\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-md",children:"\x3c!-- Docusaurus theme component --\x3e\nimport TOCInline from '@theme/TOCInline';\n\x3c!-- External component --\x3e\nimport Button from '@mui/material/Button';\n\x3c!-- Custom component --\x3e\nimport BrowserWindow from '@site/src/components/BrowserWindow';\n"})}),"\n",(0,o.jsx)(n.admonition,{type:"tip",children:(0,o.jsxs)(n.p,{children:["The ",(0,o.jsx)(n.code,{children:"@site"})," alias points to your website's directory, usually where the ",(0,o.jsx)(n.code,{children:"docusaurus.config.js"})," file is. Using an alias instead of relative paths (",(0,o.jsx)(n.code,{children:"'../../src/components/BrowserWindow'"}),") saves you from updating import paths when moving files around, or when ",(0,o.jsx)(n.a,{href:"/docs/versioning",children:"versioning docs"})," and ",(0,o.jsx)(n.a,{href:"/docs/i18n/tutorial",children:"translating"}),"."]})}),"\n",(0,o.jsxs)(n.p,{children:["While declaring components within Markdown is very convenient for simple cases, it becomes hard to maintain because of limited editor support, risks of parsing errors, and low reusability. Use a separate ",(0,o.jsx)(n.code,{children:".js"})," file when your component involves complex JS logic:"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-jsx",metastring:'title="src/components/Highlight.js"',children:"import React from 'react';\n\nexport default function Highlight({children, color}) {\n return (\n <span\n style={{\n backgroundColor: color,\n borderRadius: '2px',\n color: '#fff',\n padding: '0.2rem',\n }}>\n {children}\n </span>\n );\n}\n"})}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-md",metastring:'title="markdown-file.mdx"',children:"import Highlight from '@site/src/components/Highlight';\n\n<Highlight color=\"#25c2a0\">Docusaurus green</Highlight>\n"})}),"\n",(0,o.jsx)(n.admonition,{type:"tip",children:(0,o.jsxs)(n.p,{children:["If you use the same component across a lot of files, you don't need to import it everywhere\u2014consider adding it to the global scope. ",(0,o.jsx)(n.a,{href:"#mdx-component-scope",children:"See below"})]})}),"\n",(0,o.jsx)(n.h3,{id:"mdx-component-scope",children:"MDX component scope"}),"\n",(0,o.jsxs)(n.p,{children:["Apart from ",(0,o.jsx)(n.a,{href:"#importing-components",children:"importing a component"})," and ",(0,o.jsx)(n.a,{href:"#exporting-components",children:"exporting a component"}),", a third way to use a component in MDX is to ",(0,o.jsx)(n.strong,{children:"register it to the global scope"}),", which will make it automatically available in every MDX file, without any import statements."]}),"\n",(0,o.jsx)(n.p,{children:"For example, given this MDX file:"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-md",children:"- a\n- list!\n\nAnd some <Highlight>custom markup</Highlight>...\n"})}),"\n",(0,o.jsxs)(n.p,{children:["It will be compiled to a React component containing ",(0,o.jsx)(n.code,{children:"ul"}),", ",(0,o.jsx)(n.code,{children:"li"}),", ",(0,o.jsx)(n.code,{children:"p"}),", and ",(0,o.jsx)(n.code,{children:"Highlight"})," elements. ",(0,o.jsx)(n.code,{children:"Highlight"})," is not a native html element: you need to provide your own React component implementation for it."]}),"\n",(0,o.jsxs)(n.p,{children:["In Docusaurus, the MDX component scope is provided by the ",(0,o.jsx)(n.code,{children:"@theme/MDXComponents"})," file. It's not a React component, ",(0,o.jsx)(n.em,{children:"per se"}),", unlike most other exports under the ",(0,o.jsx)(n.code,{children:"@theme/"})," alias: it is a record from tag names like ",(0,o.jsx)(n.code,{children:"Highlight"})," to their React component implementations."]}),"\n",(0,o.jsxs)(n.p,{children:["If you ",(0,o.jsx)(n.a,{href:"/docs/swizzling",children:"swizzle"})," this component, you will find all tags that have been implemented, and you can further customize our implementation by swizzling the respective sub-component, like ",(0,o.jsx)(n.code,{children:"@theme/MDXComponents/Code"})," (which is used to render ",(0,o.jsx)(n.a,{href:"/docs/markdown-features/code-blocks",children:"Markdown code blocks"}),")."]}),"\n",(0,o.jsxs)(n.p,{children:["If you want to register extra tag names (like the ",(0,o.jsx)(n.code,{children:"<Highlight>"})," tag above), you should consider ",(0,o.jsxs)(n.a,{href:"/docs/swizzling#wrapping",children:["wrapping ",(0,o.jsx)(n.code,{children:"@theme/MDXComponents"})]}),", so you don't have to maintain all the existing mappings. Since the swizzle CLI doesn't allow wrapping non-component files yet, you should manually create the wrapper:"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-js",metastring:'title="src/theme/MDXComponents.js"',children:"import React from 'react';\n// Import the original mapper\nimport MDXComponents from '@theme-original/MDXComponents';\n// highlight-next-line\nimport Highlight from '@site/src/components/Highlight';\n\nexport default {\n // Re-use the default mapping\n ...MDXComponents,\n // Map the \"<Highlight>\" tag to our Highlight component\n // `Highlight` will receive all props that were passed to `<Highlight>` in MDX\n // highlight-next-line\n Highlight,\n};\n"})}),"\n",(0,o.jsxs)(n.p,{children:["And now, you can freely use ",(0,o.jsx)(n.code,{children:"<Highlight>"})," in every page, without writing the import statement:"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-md",children:'I can conveniently use <Highlight color="#25c2a0">Docusaurus green</Highlight> everywhere!\n'})}),"\n",(0,o.jsx)(i.Z,{children:(0,o.jsxs)(n.p,{children:["I can conveniently use ",(0,o.jsx)(f,{color:"#25c2a0",children:"Docusaurus green"})," everywhere!"]})}),"\n",(0,o.jsxs)(n.admonition,{type:"warning",children:[(0,o.jsxs)(n.p,{children:["We use ",(0,o.jsx)(n.strong,{children:"upper-case"})," tag names like ",(0,o.jsx)(n.code,{children:"Highlight"})," on purpose."]}),(0,o.jsx)(n.p,{children:"From MDX v3+ onward (Docusaurus v3+), lower-case tag names are always rendered as native html elements, and will not use any component mapping you provide."})]}),"\n",(0,o.jsxs)(n.admonition,{type:"warning",children:[(0,o.jsxs)(n.p,{children:["This feature is powered by ",(0,o.jsxs)(n.a,{href:"https://mdxjs.com/docs/using-mdx/#mdx-provider",children:["an ",(0,o.jsx)(n.code,{children:"MDXProvider"})]}),". If you are importing Markdown in a React page, you have to supply this provider yourself through the ",(0,o.jsx)(n.code,{children:"MDXContent"})," theme component."]}),(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-jsx",metastring:'title="src/pages/index.js"',children:"import React from 'react';\nimport FeatureDisplay from './_featureDisplay.mdx';\n// highlight-next-line\nimport MDXContent from '@theme/MDXContent';\n\nexport default function LandingPage() {\n return (\n <div>\n {/* highlight-start */}\n <MDXContent>\n <FeatureDisplay />\n </MDXContent>\n {/* highlight-end */}\n </div>\n );\n}\n"})}),(0,o.jsxs)(n.p,{children:["If you don't wrap your imported MDX with ",(0,o.jsx)(n.code,{children:"MDXContent"}),", the global scope will not be available."]})]}),"\n",(0,o.jsx)(n.h3,{id:"markdown-and-jsx-interoperability",children:"Markdown and JSX interoperability"}),"\n",(0,o.jsxs)(n.p,{children:["Docusaurus v3 is using ",(0,o.jsx)(n.a,{href:"https://mdxjs.com/blog/v3/",children:"MDX v3"}),"."]}),"\n",(0,o.jsxs)(n.p,{children:["The ",(0,o.jsx)(n.a,{href:"https://mdxjs.com/docs/what-is-mdx/#mdx-syntax",children:"MDX syntax"})," is mostly compatible with ",(0,o.jsx)(n.a,{href:"https://commonmark.org/",children:"CommonMark"}),", but is much stricter because your ",(0,o.jsx)(n.code,{children:".mdx"})," files can use JSX and are compiled into real React components (check the ",(0,o.jsx)(n.a,{href:"https://mdxjs.com/playground/",children:"playground"}),")."]}),"\n",(0,o.jsxs)(n.p,{children:["Some valid CommonMark features won't work with MDX (",(0,o.jsx)(n.a,{href:"https://mdxjs.com/docs/what-is-mdx/#markdown",children:"more info"}),"), notably:"]}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:"Indented code blocks: use triple backticks instead"}),"\n",(0,o.jsxs)(n.li,{children:["Autolinks (",(0,o.jsx)(n.code,{children:"<http://localhost:3000>"}),"): use regular link syntax instead (",(0,o.jsx)(n.code,{children:"[http://localhost:3000](http://localhost:3000)"}),")"]}),"\n",(0,o.jsxs)(n.li,{children:["HTML syntax (",(0,o.jsx)(n.code,{children:'<p style="color: red;">'}),"): use JSX instead (",(0,o.jsx)(n.code,{children:"<p style={{color: 'red'}}>"}),")"]}),"\n",(0,o.jsxs)(n.li,{children:["Unescaped ",(0,o.jsx)(n.code,{children:"{"})," and ",(0,o.jsx)(n.code,{children:"<"}),": escape them with ",(0,o.jsx)(n.code,{children:"\\"})," instead (",(0,o.jsx)(n.code,{children:"\\{"})," and ",(0,o.jsx)(n.code,{children:"\\<"}),")"]}),"\n"]}),"\n",(0,o.jsxs)(n.admonition,{title:"Experimental CommonMark support",type:"danger",children:[(0,o.jsxs)(n.p,{children:["Docusaurus v3 makes it possible to opt-in for a less strict, standard ",(0,o.jsx)(n.a,{href:"https://commonmark.org/",children:"CommonMark"})," support with the following options:"]}),(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:["The ",(0,o.jsx)(n.code,{children:"mdx.format: md"})," front matter"]}),"\n",(0,o.jsxs)(n.li,{children:["The ",(0,o.jsx)(n.code,{children:".md"})," file extension combined with the ",(0,o.jsx)(n.code,{children:'siteConfig.markdown.format: "detect"'})," configuration"]}),"\n"]}),(0,o.jsxs)(n.p,{children:["This feature is ",(0,o.jsx)(n.strong,{children:"experimental"})," and currently has a few ",(0,o.jsx)(n.a,{href:"https://github.com/facebook/docusaurus/issues/9092",children:"limitations"}),"."]})]}),"\n",(0,o.jsx)(n.h2,{id:"importing-code-snippets",children:"Importing code snippets"}),"\n",(0,o.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,o.jsx)(n.a,{href:"https://webpack.js.org/loaders/raw-loader/",children:"Webpack raw-loader"}),". In order to use ",(0,o.jsx)(n.code,{children:"raw-loader"}),", you first need to install it in your project:"]}),"\n",(0,o.jsxs)(a.Z,{groupId:"npm2yarn",children:[(0,o.jsx)(l.Z,{value:"npm",children:(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-bash",children:"npm install --save raw-loader\n"})})}),(0,o.jsx)(l.Z,{value:"yarn",label:"Yarn",children:(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-bash",children:"yarn add raw-loader\n"})})}),(0,o.jsx)(l.Z,{value:"pnpm",label:"pnpm",children:(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-bash",children:"pnpm add raw-loader\n"})})})]}),"\n",(0,o.jsx)(n.p,{children:"Now you can import code snippets from another file as it is:"}),"\n","\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-jsx",metastring:'title="myMarkdownFile.mdx"',children:"import CodeBlock from '@theme/CodeBlock';\nimport MyComponentSource from '!!raw-loader!./myComponent';\n\n<CodeBlock language=\"jsx\">{MyComponentSource}</CodeBlock>\n"})}),"\n","\n",(0,o.jsx)(i.Z,{children:(0,o.jsx)(c.Z,{language:"jsx",children:d.Z})}),"\n",(0,o.jsxs)(n.p,{children:["See ",(0,o.jsx)(n.a,{href:"/docs/markdown-features/code-blocks#usage-in-jsx",children:"using code blocks in JSX"})," for more details of the ",(0,o.jsx)(n.code,{children:"<CodeBlock>"})," component."]}),"\n",(0,o.jsx)(n.admonition,{type:"note",children:(0,o.jsxs)(n.p,{children:["You have to use ",(0,o.jsx)(n.code,{children:"<CodeBlock>"})," rather than the Markdown triple-backtick ",(0,o.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,o.jsx)(n.admonition,{type:"warning",children:(0,o.jsx)(n.p,{children:"This feature is experimental and might be subject to breaking API changes in the future."})}),"\n",(0,o.jsx)(n.h2,{id:"importing-markdown",children:"Importing Markdown"}),"\n",(0,o.jsxs)(n.p,{children:["You can use Markdown files as components and import them elsewhere, either in Markdown files or in React pages. Each MDX file default-exports its page content as a React component. In the ",(0,o.jsx)(n.code,{children:"import"})," statement, you can default-import this component with any name, but it must be capitalized following React's naming rules."]}),"\n",(0,o.jsxs)(n.p,{children:["By convention, using the ",(0,o.jsxs)(n.strong,{children:[(0,o.jsx)(n.code,{children:"_"})," filename prefix"]})," will not create any doc page and means the Markdown file is a ",(0,o.jsx)(n.strong,{children:'"partial"'}),", to be imported by other files."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-md",metastring:'title="_markdown-partial-example.mdx"',children:"<span>Hello {props.name}</span>\n\nThis is text some content from `_markdown-partial-example.mdx`.\n"})}),"\n","\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-jsx",metastring:'title="someOtherDoc.mdx"',children:"import PartialExample from './_markdown-partial-example.mdx';\n\n<PartialExample name=\"Sebastien\" />\n"})}),"\n","\n",(0,o.jsx)(i.Z,{children:(0,o.jsx)(h,{name:"Sebastien"})}),"\n",(0,o.jsx)(n.p,{children:"This way, you can reuse content among multiple pages and avoid duplicating materials."}),"\n",(0,o.jsx)(n.h2,{id:"available-exports",children:"Available exports"}),"\n",(0,o.jsx)(n.p,{children:"Within the MDX page, the following variables are available as globals:"}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.code,{children:"frontMatter"}),": the front matter as a record of string keys and values;"]}),"\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.code,{children:"toc"}),": the table of contents, as a tree of headings. See also ",(0,o.jsx)(n.a,{href:"/docs/markdown-features/toc#inline-table-of-contents",children:"Inline TOC"})," for a more concrete use-case."]}),"\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.code,{children:"contentTitle"}),": the Markdown title, which is the first ",(0,o.jsx)(n.code,{children:"h1"})," heading in the Markdown text. It's ",(0,o.jsx)(n.code,{children:"undefined"})," if there isn't one (e.g. title specified in the front matter)."]}),"\n"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.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<CodeBlock className=\"language-json\">{JSON.stringify(toc, null, 2)}</CodeBlock>\n\nThe front matter of this page:\n\n<ul>\n {Object.entries(frontMatter).map(([key, value]) => <li key={key}><b>{key}</b>: {value}</li>)}\n</ul>\n\n<p>The title of this page is: <b>{contentTitle}</b></p>\n"})}),"\n","\n",(0,o.jsxs)(i.Z,{children:[(0,o.jsx)(n.p,{children:"The table of contents for this page, serialized:"}),(0,o.jsx)(c.Z,{className:"language-json",children:JSON.stringify(g,null,2)}),(0,o.jsx)(n.p,{children:"The front matter of this page:"}),(0,o.jsx)("ul",{children:Object.entries(m).map(([e,n])=>(0,o.jsxs)("li",{children:[(0,o.jsx)("b",{children:e}),": ",n]},e))}),(0,o.jsxs)("p",{children:["The title of this page is: ",(0,o.jsx)("b",{children:p})]})]})]})}function b(e={}){let{wrapper:n}={...(0,s.a)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(j,{...e})}):j(e)}},86411:function(e,n,t){t.d(n,{Z:()=>i});var r=t("24246");t("27378");var o=t("9763");let s="tableOfContentsInline_2sru";function i(e){let{toc:n,minHeadingLevel:t,maxHeadingLevel:i}=e;return(0,r.jsx)("div",{className:s,children:(0,r.jsx)(o.Z,{toc:n,minHeadingLevel:t,maxHeadingLevel:i,className:"table-of-contents",linkClassName:null})})}},9763:function(e,n,t){t.d(n,{Z:()=>c});var r=t("24246"),o=t("27378"),s=t("70341");function i(e){let n=e.getBoundingClientRect();return n.top===n.bottom?i(e.parentNode):n}var a=t("64152");let l=o.memo(function e(n){let{toc:t,className:o,linkClassName:s,isChild:i}=n;return t.length?(0,r.jsx)("ul",{className:i?void 0:o,children:t.map(n=>(0,r.jsxs)("li",{children:[(0,r.jsx)(a.Z,{to:`#${n.id}`,className:s??void 0,dangerouslySetInnerHTML:{__html:n.value}}),(0,r.jsx)(e,{isChild:!0,toc:n.children,className:o,linkClassName:s})]},n.id))}):null});function c(e){let{toc:n,className:t="table-of-contents table-of-contents__left-border",linkClassName:a="table-of-contents__link",linkActiveClassName:c,minHeadingLevel:d,maxHeadingLevel:u,...h}=e,m=(0,s.L)(),p=d??m.tableOfContents.minHeadingLevel,x=u??m.tableOfContents.maxHeadingLevel,f=function(e){let{toc:n,minHeadingLevel:t,maxHeadingLevel:r}=e;return(0,o.useMemo)(()=>(function e(n){let{toc:t,minHeadingLevel:r,maxHeadingLevel:o}=n;return t.flatMap(n=>{var t;let s=e({toc:n.children,minHeadingLevel:r,maxHeadingLevel:o});return(t=n).level>=r&&t.level<=o?[{...n,children:s}]:s})})({toc:function(e){let n=e.map(e=>({...e,parentIndex:-1,children:[]})),t=Array(7).fill(-1);n.forEach((e,n)=>{let r=t.slice(2,e.level);e.parentIndex=Math.max(...r),t[e.level]=n});let r=[];return n.forEach(e=>{let{parentIndex:t,...o}=e;t>=0?n[t].children.push(o):r.push(o)}),r}(n),minHeadingLevel:t,maxHeadingLevel:r}),[n,t,r])}({toc:n,minHeadingLevel:p,maxHeadingLevel:x});return!function(e){let n=(0,o.useRef)(void 0),t=function(){let e=(0,o.useRef)(0),{navbar:{hideOnScroll:n}}=(0,s.L)();return(0,o.useEffect)(()=>{e.current=n?0:document.querySelector(".navbar").clientHeight},[n]),e}();(0,o.useEffect)(()=>{if(!e)return()=>{};let{linkClassName:r,linkActiveClassName:o,minHeadingLevel:s,maxHeadingLevel:a}=e;function l(){var e;let l=(e=r,Array.from(document.getElementsByClassName(e))),c=function(e,n){let{anchorTopOffset:t}=n,r=e.find(e=>i(e).top>=t);if(r){var o;return(o=i(r)).top>0&&o.bottom<window.innerHeight/2?r:e[e.indexOf(r)-1]??null}return e[e.length-1]??null}(function(e){let{minHeadingLevel:n,maxHeadingLevel:t}=e,r=[];for(let e=n;e<=t;e+=1)r.push(`h${e}.anchor`);return Array.from(document.querySelectorAll(r.join()))}({minHeadingLevel:s,maxHeadingLevel:a}),{anchorTopOffset:t.current}),d=l.find(e=>{var n;return c&&c.id===decodeURIComponent((n=e).href.substring(n.href.indexOf("#")+1))});l.forEach(e=>{var t;t=e,e===d?(n.current&&n.current!==t&&n.current.classList.remove(o),t.classList.add(o),n.current=t):t.classList.remove(o)})}return document.addEventListener("scroll",l),document.addEventListener("resize",l),l(),()=>{document.removeEventListener("scroll",l),document.removeEventListener("resize",l)}},[e,t])}((0,o.useMemo)(()=>{if(a&&c)return{linkClassName:a,linkActiveClassName:c,minHeadingLevel:p,maxHeadingLevel:x}},[a,c,p,x])),(0,r.jsx)(l,{toc:f,className:t,linkClassName:a,...h})}},67860:function(e,n,t){t.d(n,{Z:()=>i});var r=t("24246");t("27378");var o=t("90496");let s="tabItem_pnkT";function i(e){let{children:n,hidden:t,className:i}=e;return(0,r.jsx)("div",{role:"tabpanel",className:(0,o.Z)(s,i),hidden:t,children:n})}},46291:function(e,n,t){t.d(n,{Z:()=>v});var r=t("24246"),o=t("27378"),s=t("90496"),i=t("12451"),a=t("3620"),l=t("89637"),c=t("74417"),d=t("46918"),u=t("58247");function h(e){return o.Children.toArray(e).filter(e=>"\n"!==e).map(e=>{if(!e||o.isValidElement(e)&&function(e){let{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return e;throw Error(`Docusaurus error: Bad <Tabs> child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.`)})?.filter(Boolean)??[]}function m(e){let{value:n,tabValues:t}=e;return t.some(e=>e.value===n)}var p=t("8903");let x="tabList_Qoir",f="tabItem_AQgk";function g(e){let{className:n,block:t,selectedValue:o,selectValue:a,tabValues:l}=e,c=[],{blockElementScrollPositionUntilNextRender:d}=(0,i.o5)(),u=e=>{let n=e.currentTarget,t=l[c.indexOf(n)].value;t!==o&&(d(n),a(t))},h=e=>{let n=null;switch(e.key){case"Enter":u(e);break;case"ArrowRight":{let t=c.indexOf(e.currentTarget)+1;n=c[t]??c[0];break}case"ArrowLeft":{let t=c.indexOf(e.currentTarget)-1;n=c[t]??c[c.length-1]}}n?.focus()};return(0,r.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,s.Z)("tabs",{"tabs--block":t},n),children:l.map(e=>{let{value:n,label:t,attributes:i}=e;return(0,r.jsx)("li",{role:"tab",tabIndex:o===n?0:-1,"aria-selected":o===n,ref:e=>{c.push(e)},onKeyDown:h,onClick:u,...i,className:(0,s.Z)("tabs__item",f,i?.className,{"tabs__item--active":o===n}),children:t??n},n)})})}function j(e){let{lazy:n,children:t,selectedValue:i}=e,a=(Array.isArray(t)?t:[t]).filter(Boolean);if(n){let e=a.find(e=>e.props.value===i);return e?(0,o.cloneElement)(e,{className:(0,s.Z)("margin-top--md",e.props.className)}):null}return(0,r.jsx)("div",{className:"margin-top--md",children:a.map((e,n)=>(0,o.cloneElement)(e,{key:n,hidden:e.props.value!==i}))})}function b(e){let n=function(e){let{defaultValue:n,queryString:t=!1,groupId:r}=e,s=function(e){let{values:n,children:t}=e;return(0,o.useMemo)(()=>{let e=n??h(t).map(e=>{let{props:{value:n,label:t,attributes:r,default:o}}=e;return{value:n,label:t,attributes:r,default:o}});return!function(e){let n=(0,d.lx)(e,(e,n)=>e.value===n.value);if(n.length>0)throw Error(`Docusaurus error: Duplicate values "${n.map(e=>e.value).join(", ")}" found in <Tabs>. Every value needs to be unique.`)}(e),e},[n,t])}(e),[i,p]=(0,o.useState)(()=>(function(e){let{defaultValue:n,tabValues:t}=e;if(0===t.length)throw Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(n){if(!m({value:n,tabValues:t}))throw Error(`Docusaurus error: The <Tabs> has a defaultValue "${n}" but none of its children has the corresponding value. Available values are: ${t.map(e=>e.value).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return n}let r=t.find(e=>e.default)??t[0];if(!r)throw Error("Unexpected error: 0 tabValues");return r.value})({defaultValue:n,tabValues:s})),[x,f]=function(e){let{queryString:n=!1,groupId:t}=e,r=(0,a.k6)(),s=function(e){let{queryString:n=!1,groupId:t}=e;if("string"==typeof n)return n;if(!1===n)return null;if(!0===n&&!t)throw Error('Docusaurus error: The <Tabs> component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return t??null}({queryString:n,groupId:t}),i=(0,c._X)(s);return[i,(0,o.useCallback)(e=>{if(!s)return;let n=new URLSearchParams(r.location.search);n.set(s,e),r.replace({...r.location,search:n.toString()})},[s,r])]}({queryString:t,groupId:r}),[g,j]=function(e){var n;let{groupId:t}=e;let r=(n=t)?`docusaurus.tab.${n}`:null,[s,i]=(0,u.Nk)(r);return[s,(0,o.useCallback)(e=>{if(!!r)i.set(e)},[r,i])]}({groupId:r}),b=(()=>{let e=x??g;return m({value:e,tabValues:s})?e:null})();return(0,l.Z)(()=>{b&&p(b)},[b]),{selectedValue:i,selectValue:(0,o.useCallback)(e=>{if(!m({value:e,tabValues:s}))throw Error(`Can't select invalid tab value=${e}`);p(e),f(e),j(e)},[f,j,s]),tabValues:s}}(e);return(0,r.jsxs)("div",{className:(0,s.Z)("tabs-container",x),children:[(0,r.jsx)(g,{...n,...e}),(0,r.jsx)(j,{...n,...e})]})}function v(e){let n=(0,p.Z)();return(0,r.jsx)(b,{...e,children:h(e.children)},String(n))}},82234:function(e,n,t){t.d(n,{Z:function(){return s}});var r=t(24246);t(27378);var o=t(8903);function s(e){let{children:n,fallback:t}=e;return(0,o.Z)()?(0,r.jsx)(r.Fragment,{children:n?.()}):t??null}},11678:function(e,n,t){t.d(n,{Z:()=>m});var r=t("24246");t("27378");var o=t("90496");let s="browserWindow_my1Q",i="browserWindowHeader_jXSR",a="buttons_uHc7",l="browserWindowAddressBar_Pd8y",c="dot_giz1",d="browserWindowMenuIcon_Vhuh",u="bar_rrRL",h="browserWindowBody_Idgs";function m(e){let{children:n,minHeight:t,url:m="http://localhost:3000",style:p,bodyStyle:x}=e;return(0,r.jsxs)("div",{className:s,style:{...p,minHeight:t},children:[(0,r.jsxs)("div",{className:i,children:[(0,r.jsxs)("div",{className:a,children:[(0,r.jsx)("span",{className:c,style:{background:"#f25f58"}}),(0,r.jsx)("span",{className:c,style:{background:"#fbbe3c"}}),(0,r.jsx)("span",{className:c,style:{background:"#58cb42"}})]}),(0,r.jsx)("div",{className:(0,o.Z)(l,"text--truncate"),children:m}),(0,r.jsx)("div",{className:d,children:(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:u}),(0,r.jsx)("span",{className:u}),(0,r.jsx)("span",{className:u})]})})]}),(0,r.jsx)("div",{className:h,style:x,children:n})]})}},45960:function(e,n,t){t.d(n,{Z:()=>ei});var r,o={};t.r(o),t.d(o,{ButtonExample:()=>T});var s=t("24246"),i=t("27378"),a=t("90496"),l=t("8903"),c=t("10075"),d=t("80661"),u=t("30056"),h=t("82234"),m=t("22687"),p=t("31058"),x=t("70341");function f(){let{prism:e}=(0,x.L)(),{colorMode:n}=(0,p.I)(),t=e.theme,r=e.darkTheme||t;return"dark"===n?r:t}var g=t("18605");let j="playgroundContainer_6Ior",b="playgroundHeader_Tvsk",v="playgroundEditor_TySg",y="playgroundPreview_mApW";function w(e){let{children:n}=e;return(0,s.jsx)("div",{className:(0,a.Z)(b),children:n})}function k(){return(0,s.jsx)("div",{children:"Loading..."})}function C(){return(0,s.jsx)(h.Z,{fallback:(0,s.jsx)(k,{}),children:()=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(g.Z,{fallback:e=>(0,s.jsx)(m.Ac,{...e}),children:(0,s.jsx)(c.i5,{})}),(0,s.jsx)(c.IF,{})]})})}function M(){return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(w,{children:(0,s.jsx)(d.Z,{id:"theme.Playground.result",description:"The result label of the live codeblocks",children:"Result"})}),(0,s.jsx)("div",{className:y,children:(0,s.jsx)(C,{})})]})}function N(){let e=(0,l.Z)();return(0,s.jsx)(c.uz,{className:v},String(e))}function B(){return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(w,{children:(0,s.jsx)(d.Z,{id:"theme.Playground.liveEditor",description:"The live editor label of the live codeblocks",children:"Live Editor"})}),(0,s.jsx)(N,{})]})}let D=e=>`${e};`;function I(e){let{children:n,transformCode:t,...r}=e,{siteConfig:{themeConfig:o}}=(0,u.Z)(),{liveCodeBlock:{playgroundPosition:i}}=o,a=f(),l=r.metastring?.includes("noInline")??!1;return(0,s.jsx)("div",{className:j,children:(0,s.jsx)(c.nu,{code:n?.replace(/\n$/,""),noInline:l,transformCode:t??D,theme:a,...r,children:"top"===i?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(M,{}),(0,s.jsx)(B,{})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(B,{}),(0,s.jsx)(M,{})]})})})}function T(e){return(0,s.jsx)("button",{type:"button",...e,style:{backgroundColor:"white",color:"black",border:"solid red",borderRadius:20,padding:10,cursor:"pointer",...e.style}})}let X={React:i,...i,...o};var E=t("2235"),L=t("6324"),H=t.n(L);let S=/title=(?<quote>["'])(?<title>.*?)\1/,_=/\{(?<range>[\d,-]+)\}/,Z={js:{start:"\\/\\/",end:""},jsBlock:{start:"\\/\\*",end:"\\*\\/"},jsx:{start:"\\{\\s*\\/\\*",end:"\\*\\/\\s*\\}"},bash:{start:"#",end:""},html:{start:"\x3c!--",end:"--\x3e"}},R={...Z,lua:{start:"--",end:""},wasm:{start:"\\;\\;",end:""},tex:{start:"%",end:""},vb:{start:"['\u2018\u2019]",end:""},vbnet:{start:"(?:_\\s*)?['\u2018\u2019]",end:""},rem:{start:"[Rr][Ee][Mm]\\b",end:""},f90:{start:"!",end:""},ml:{start:"\\(\\*",end:"\\*\\)"},cobol:{start:"\\*>",end:""}},A=Object.keys(Z);function O(e,n){let t=e.map(e=>{let{start:t,end:r}=R[e];return`(?:${t}\\s*(${n.flatMap(e=>[e.line,e.block?.start,e.block?.end].filter(Boolean)).join("|")})\\s*${r})`}).join("|");return RegExp(`^\\s*(?:${t})\\s*$`)}let F="codeBlockContainer_jDV4";function z(e){let{as:n,...t}=e,r=function(e){let n={color:"--prism-color",backgroundColor:"--prism-background-color"},t={};return Object.entries(e.plain).forEach(e=>{let[r,o]=e,s=n[r];s&&"string"==typeof o&&(t[s]=o)}),t}(f());return(0,s.jsx)(n,{...t,style:r,className:(0,a.Z)(t.className,F,E.k.common.codeBlock)})}let W={codeBlockContent:"codeBlockContent_vx7S",codeBlockTitle:"codeBlockTitle_bdru",codeBlock:"codeBlock_Gebt",codeBlockStandalone:"codeBlockStandalone_i_cY",codeBlockLines:"codeBlockLines_FJaf",codeBlockLinesWithNumbering:"codeBlockLinesWithNumbering_FU9Q",buttonGroup:"buttonGroup_cUGO"};function $(e){let{children:n,className:t}=e;return(0,s.jsx)(z,{as:"pre",tabIndex:0,className:(0,a.Z)(W.codeBlockStandalone,"thin-scrollbar",t),children:(0,s.jsx)("code",{className:W.codeBlockLines,children:n})})}var J=t("31008");let U={attributes:!0,characterData:!0,childList:!0,subtree:!0};var q=t("7316");let P={codeLine:"codeLine_qRmp",codeLineNumber:"codeLineNumber_dS_J",codeLineContent:"codeLineContent_XF5l"};function V(e){let{line:n,classNames:t,showLineNumbers:r,getLineProps:o,getTokenProps:i}=e;1===n.length&&"\n"===n[0].content&&(n[0].content="");let l=o({line:n,className:(0,a.Z)(t,r&&P.codeLine)}),c=n.map((e,n)=>(0,s.jsx)("span",{...i({token:e})},n));return(0,s.jsxs)("span",{...l,children:[r?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:P.codeLineNumber}),(0,s.jsx)("span",{className:P.codeLineContent,children:c})]}):c,(0,s.jsx)("br",{})]})}var Q=t("84171");function Y(e){return(0,s.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,s.jsx)("path",{fill:"currentColor",d:"M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"})})}function G(e){return(0,s.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,s.jsx)("path",{fill:"currentColor",d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})})}let K={copyButtonCopied:"copyButtonCopied_OkN_",copyButtonIcons:"copyButtonIcons_OqsO",copyButtonIcon:"copyButtonIcon_PgCn",copyButtonSuccessIcon:"copyButtonSuccessIcon_bsQG"};function ee(e){let{code:n,className:t}=e,[r,o]=(0,i.useState)(!1),l=(0,i.useRef)(void 0),c=(0,i.useCallback)(()=>{(0,Q.Z)(n),o(!0),l.current=window.setTimeout(()=>{o(!1)},1e3)},[n]);return(0,i.useEffect)(()=>()=>window.clearTimeout(l.current),[]),(0,s.jsx)("button",{type:"button","aria-label":r?(0,d.I)({id:"theme.CodeBlock.copied",message:"Copied",description:"The copied button label on code blocks"}):(0,d.I)({id:"theme.CodeBlock.copyButtonAriaLabel",message:"Copy code to clipboard",description:"The ARIA label for copy code blocks button"}),title:(0,d.I)({id:"theme.CodeBlock.copy",message:"Copy",description:"The copy button label on code blocks"}),className:(0,a.Z)("clean-btn",t,K.copyButton,r&&K.copyButtonCopied),onClick:c,children:(0,s.jsxs)("span",{className:K.copyButtonIcons,"aria-hidden":"true",children:[(0,s.jsx)(Y,{className:K.copyButtonIcon}),(0,s.jsx)(G,{className:K.copyButtonSuccessIcon})]})})}function en(e){return(0,s.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,s.jsx)("path",{fill:"currentColor",d:"M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3l3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"})})}let et={wordWrapButtonIcon:"wordWrapButtonIcon_MQXS",wordWrapButtonEnabled:"wordWrapButtonEnabled_TBIH"};function er(e){let{className:n,onClick:t,isEnabled:r}=e,o=(0,d.I)({id:"theme.CodeBlock.wordWrapToggle",message:"Toggle word wrap",description:"The title attribute for toggle word wrapping button of code block lines"});return(0,s.jsx)("button",{type:"button",onClick:t,className:(0,a.Z)("clean-btn",n,r&&et.wordWrapButtonEnabled),"aria-label":o,title:o,children:(0,s.jsx)(en,{className:et.wordWrapButtonIcon,"aria-hidden":"true"})})}function eo(e){var n,t,r;let{children:o,className:l="",metastring:c,title:d,showLineNumbers:u,language:h}=e,{prism:{defaultLanguage:m,magicComments:p}}=(0,x.L)();let g=(n=h??function(e){let n=e.split(" ").find(e=>e.startsWith("language-"));return n?.replace(/language-/,"")}(l)??m,n?.toLowerCase()),j=f(),b=function(){let[e,n]=(0,i.useState)(!1),[t,r]=(0,i.useState)(!1),o=(0,i.useRef)(null),s=(0,i.useCallback)(()=>{let t=o.current.querySelector("code");e?t.removeAttribute("style"):(t.style.whiteSpace="pre-wrap",t.style.overflowWrap="anywhere"),n(e=>!e)},[o,e]),a=(0,i.useCallback)(()=>{let{scrollWidth:e,clientWidth:n}=o.current;r(e>n||o.current.querySelector("code").hasAttribute("style"))},[o]);return!function(e,n){let[t,r]=(0,i.useState)(),o=(0,i.useCallback)(()=>{r(e.current?.closest("[role=tabpanel][hidden]"))},[e,r]);(0,i.useEffect)(()=>{o()},[o]),!function(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:U,r=(0,J.zX)(n),o=(0,J.Ql)(t);(0,i.useEffect)(()=>{let n=new MutationObserver(r);return e&&n.observe(e,o),()=>n.disconnect()},[e,r,o])}(t,e=>{e.forEach(e=>{"attributes"===e.type&&"hidden"===e.attributeName&&(n(),o())})},{attributes:!0,characterData:!1,childList:!1,subtree:!1})}(o,a),(0,i.useEffect)(()=>{a()},[e,a]),(0,i.useEffect)(()=>(window.addEventListener("resize",a,{passive:!0}),()=>{window.removeEventListener("resize",a)}),[a]),{codeBlockRef:o,isEnabled:e,isCodeScrollable:t,toggle:s}}();let v=(t=c,(t?.match(S)?.groups.title??"")||d),{lineClassNames:y,code:w}=function(e,n){let t=e.replace(/\n$/,""),{language:r,magicComments:o,metastring:s}=n;if(s&&_.test(s)){let e=s.match(_).groups.range;if(0===o.length)throw Error(`A highlight range has been given in code block's metastring (\`\`\` ${s}), but no magic comment config is available. Docusaurus applies the first magic comment entry's className for metastring ranges.`);let n=o[0].className;return{lineClassNames:Object.fromEntries(H()(e).filter(e=>e>0).map(e=>[e-1,[n]])),code:t}}if(void 0===r)return{lineClassNames:{},code:t};let i=function(e,n){switch(e){case"js":case"javascript":case"ts":case"typescript":return O(["js","jsBlock"],n);case"jsx":case"tsx":return O(["js","jsBlock","jsx"],n);case"html":return O(["js","jsBlock","html"],n);case"python":case"py":case"bash":return O(["bash"],n);case"markdown":case"md":return O(["html","jsx","bash"],n);case"tex":case"latex":case"matlab":return O(["tex"],n);case"lua":case"haskell":case"sql":return O(["lua"],n);case"wasm":return O(["wasm"],n);case"vb":case"vba":case"visual-basic":return O(["vb","rem"],n);case"vbnet":return O(["vbnet","rem"],n);case"batch":return O(["rem"],n);case"basic":return O(["rem","f90"],n);case"fsharp":return O(["js","ml"],n);case"ocaml":case"sml":return O(["ml"],n);case"fortran":return O(["f90"],n);case"cobol":return O(["cobol"],n);default:return O(A,n)}}(r,o),a=t.split("\n"),l=Object.fromEntries(o.map(e=>[e.className,{start:0,range:""}])),c=Object.fromEntries(o.filter(e=>e.line).map(e=>{let{className:n,line:t}=e;return[t,n]})),d=Object.fromEntries(o.filter(e=>e.block).map(e=>{let{className:n,block:t}=e;return[t.start,n]})),u=Object.fromEntries(o.filter(e=>e.block).map(e=>{let{className:n,block:t}=e;return[t.end,n]}));for(let e=0;e<a.length;){let n=a[e].match(i);if(!n){e+=1;continue}let t=n.slice(1).find(e=>void 0!==e);c[t]?l[c[t]].range+=`${e},`:d[t]?l[d[t]].start=e:u[t]&&(l[u[t]].range+=`${l[u[t]].start}-${e-1},`),a.splice(e,1)}t=a.join("\n");let h={};return Object.entries(l).forEach(e=>{let[n,{range:t}]=e;H()(t).forEach(e=>{h[e]??=[],h[e].push(n)})}),{lineClassNames:h,code:t}}(o,{metastring:c,language:g,magicComments:p});let k=u??(r=c,!!r?.includes("showLineNumbers"));return(0,s.jsxs)(z,{as:"div",className:(0,a.Z)(l,g&&!l.includes(`language-${g}`)&&`language-${g}`),children:[v&&(0,s.jsx)("div",{className:W.codeBlockTitle,children:v}),(0,s.jsxs)("div",{className:W.codeBlockContent,children:[(0,s.jsx)(q.y$,{theme:j,code:w,language:g??"text",children:e=>{let{className:n,style:t,tokens:r,getLineProps:o,getTokenProps:i}=e;return(0,s.jsx)("pre",{tabIndex:0,ref:b.codeBlockRef,className:(0,a.Z)(n,W.codeBlock,"thin-scrollbar"),style:t,children:(0,s.jsx)("code",{className:(0,a.Z)(W.codeBlockLines,k&&W.codeBlockLinesWithNumbering),children:r.map((e,n)=>(0,s.jsx)(V,{line:e,getLineProps:o,getTokenProps:i,classNames:y[n],showLineNumbers:k},n))})})}}),(0,s.jsxs)("div",{className:W.buttonGroup,children:[(b.isEnabled||b.isCodeScrollable)&&(0,s.jsx)(er,{className:W.codeButton,onClick:()=>b.toggle(),isEnabled:b.isEnabled}),(0,s.jsx)(ee,{className:W.codeButton,code:w})]})]})]})}let es=(r=function(e){var n;let{children:t,...r}=e,o=(0,l.Z)();let a=(n=t,i.Children.toArray(n).some(e=>(0,i.isValidElement)(e))?n:Array.isArray(n)?n.join(""):n),c="string"==typeof a?eo:$;return(0,s.jsx)(c,{...r,children:a},String(o))},function(e){return e.live?(0,s.jsx)(I,{scope:X,...e}):(0,s.jsx)(r,{...e})});function ei(e){return(0,s.jsx)(es,{...e})}}}]); |