添加Remark Github Alert插件
参考文档:MDX Plugins
本文使用的是:remark-github-alerts
Github地址:https://github.com/hyoban/remark-github-alerts
也可以使用:remark-github-blockquote-alert
Github地址:https://github.com/jaywcjlove/remark-github-blockquote-alert
安装插件
- npm
- Yarn
- pnpm
npm install remark-github-alerts --save
yarn add remark-github-alerts
pnpm add remark-github-alerts
配置
1、修改docusaurus.config.js
配置文件,加入remark-github-alerts
插件。
import remarkGithubAlerts from 'remark-github-alerts';
export default {
// ...
presets: [
[
'@docusaurus/preset-classic',
{
docs: {
remarkPlugins: [
remarkGithubAlerts,
],
},
pages: {
remarkPlugins: [remarkGithubAlerts],
},
blog: {
remarkPlugins: [
remarkGithubAlerts,
],
// ...
},
},
],
],
};
2、引入样式:修改src/css/custom.css
导入样式文件
@import "remark-github-alerts/styles/github-base.css";
@import "remark-github-alerts/styles/github-colors-light.css";
...
还有 github-colors-dark-class.css
和github-colors-dark-media.css
可以选择。
使用方式
使用方式与Github中的Alerts使用方式一致。
> [!NOTE]
> Useful information that users should know, even when skimming content.
> [!TIP]
> Helpful advice for doing things better or more easily.
> [!IMPORTANT]
> Key information users need to know to achieve their goal.
> [!WARNING]
> Urgent info that needs immediate user attention to avoid problems.
> [!CAUTION]
> Advises about risks or negative outcomes of certain actions.
Note
Useful information that users should know, even when skimming content.
Tip
Helpful advice for doing things better or more easily.
Important
Key information users need to know to achieve their goal.
Warning
Urgent info that needs immediate user attention to avoid problems.
Caution
Advises about risks or negative outcomes of certain actions.
对比Docusaurus原生Admonition
Useful information that users should know, even when skimming content.
Helpful advice for doing things better or more easily.
Key information users need to know to achieve their goal.
Urgent info that needs immediate user attention to avoid problems.
Advises about risks or negative outcomes of certain actions.
将Github Alert转为Admonition
使用插件remark-github-admonitions-to-directives
可以将Github Alert转为Admonition。
插件地址:https://github.com/incentro-dc/remark-github-admonitions-to-directives
使用方式请参考项目中的README.MD
文档说明。本文中不再赘述。