{children}
),
code: ({ children, id, collapsible }) => {
const isCollapsible = typeof collapsible !== 'undefined';
const [isOpen, setIsOpen] = React.useState(!isCollapsible);
const content = ;
return isCollapsible ? (
;
},
};
Let me explain a little bit what's going on here.
* Meta properties are automatically passed in as props to both the
pre and code functions, thanks to the rehype-meta-attribute
rehype plugin
* The pre element gets replaced with the Pre component
* The code element is used both by inline code and code blocks
* The H component is used to interact with the content
* The RegisterLink component is used to
make-specific-words-link-to-other-pages
Part 4 - Usage
Finally, this section shows how each feature can be used.
Using a basic code block
Similarly to markdown, in mdx you open a code block with triple
backticks ```. The language is added immediately after it.
For example, an HTML code block:
```html
This is a code block example.
Do you like it?
This is a code block example.
Do you like it?
This is a code block example.
Do you like it?
This is a code block example.
Do you like it?