Add Markdown-it Plugins in VitePress
How to add a Markdown-it plugin to your VitePress site to extend the functionality of the Markdown parser.
You can extend the functionality of the Markdown parser in VitePress by adding Markdown-it plugins (VitePress uses Markdown-it under the hood). This allows you to add custom syntax, modify the output of the parser, or integrate with other tools.
To add a Markdown-it plugin to your VitePress site, follow these steps:
- Install the plugin: Use
npmoryarnto install the Markdown-it plugin you want to use. For example, to install the@mdit/plugin-footnoteplugin, you can run:
bash
npm install @mdit/plugin-footnoteor
bash
yarn add @mdit/plugin-footnote- Import it in your
.vitepress/config.mtsfile:
ts
import { footnote } from "@mdit/plugin-footnote";- Add the plugin to the
markdownoption in your.vitepress/config.mtsfile:
ts
markdown: {
config: (md) => {
md.use(footnote);
},
},And that's it! The Markdown-it plugin is now added to your VitePress site, and you can start using its features in your Markdown content.