-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: add documentation for custom admonitions #5625
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,3 +121,35 @@ import TabItem from '@theme/TabItem'; | |
``` | ||
|
||
::: | ||
|
||
## Custom Admonitions | ||
|
||
If you're using `@docusaurus/preset-classic`, you can create custom admonitions by adding them to your website's `docusaurus.config.js`. | ||
|
||
For example, the following configuration adds an admonition with the `custom` keyword. This admonition will be styled as an [Infima `alert-info` component](https://infima.dev/docs/components/alert): | ||
|
||
```js title="docusaurus.config.js" | ||
module.exports = { | ||
// ... | ||
presets: [ | ||
[ | ||
"@docusaurus/preset-classic", | ||
{ | ||
docs: { | ||
// ... | ||
admonitions: { | ||
customTypes: { | ||
custom: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "custom" may not be the best choice, I'd rather use "admonitionExample" |
||
ifmClass: "info", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove infima class There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is directly passed to |
||
svg: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M15 2H1c-.55 0-1 .45-1 1v9c0 .55.45 1 1 1h5.34c-.25.61-.86 1.39-2.34 2h8c-1.48-.61-2.09-1.39-2.34-2H15c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm0 9H1V3h14v8z"></path></svg>' | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
] | ||
] | ||
}; | ||
``` | ||
|
||
Further documentation is available on [Remark's own repository](https://github.com/elviswolcott/remark-admonitions#custom-types). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather not couple this doc to Infima, considering we'll provide themes that are not using Infima in the future.
What you can say is that the admonition will have a
.admonition-custom
classname that users can target with custom CSS