feat(theme-classic): standalone Admonition component (#5848)

This commit is contained in:
Joshua Chen 2021-12-21 00:51:19 +08:00 committed by GitHub
parent 770418f8d2
commit cb4265253a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 158 additions and 0 deletions

View file

@ -143,3 +143,43 @@ import TabItem from '@theme/TabItem';
```
:::
## Usage in JSX
Outside of Markdown, you can use the `@theme/Admonitions` component to get the same output.
```jsx title="MyReactPage.jsx"
import Admonition from '@theme/Admonitions';
export default function MyReactPage() {
return (
<div>
<Admonition type="info">
<p>Some information</p>
</Admonition>
</div>
);
}
```
The types that are accepted are the same as above: `note`, `tip`, `danger`, `info`, `caution`. Optionally, you can specify an icon by passing a JSX element or a string, or a title:
```jsx title="MyReactPage.jsx"
<Admonition type="tip" icon="💡" title="Did you know...">
<p>
Use plugins to introduce shorter syntax for the most commonly used JSX
elements in your project.
</p>
</Admonition>
```
```mdx-code-block
import Admonition from '@theme/Admonition';
import BrowserWindow from '@site/src/components/BrowserWindow';
<BrowserWindow>
<Admonition type="tip" icon="💡" title="Did you know...">
<p>Use plugins to introduce shorter syntax for the most commonly used JSX elements in your project.</p>
</Admonition>
</BrowserWindow>
```