# vite-plugin-md
**Repository Path**: mirrors_antfu/vite-plugin-md
## Basic Information
- **Project Name**: vite-plugin-md
- **Description**: Markdown with Vue for Vite
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 0
- **Created**: 2023-07-17
- **Last Updated**: 2025-12-14
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# vite-plugin-md
Markdown for Vite
- Use Markdown as Vue components
- Use Vue components in Markdown
- Extend functionality with **Builder API**
[](https://www.npmjs.com/package/vite-plugin-md)
> From v0.13, we introduced a pipeline and builder engine ([#54](https://github.com/antfu/vite-plugin-md/pull/54), [#77](https://github.com/antfu/vite-plugin-md/pull/77)) to provide full customizability. If you still prefer the simple Markdown-to-Vue transformation prior to v0.13, it has been moved to [`vite-plugin-vue-markdown`](https://github.com/antfu/vite-plugin-vue-markdown).
## Installing this Plugin
Installation can be done in a few simple steps. From the root of your repo do the following:
1. **NPM Install**
```bash
npm i vite-plugin-md -D # yarn add vite-plugin-md -D
```
2. **Vite Configuration**
Add the following to your `vite.config.js` / `vite.config.ts` file:
```ts
import Vue from '@vitejs/plugin-vue'
import Markdown from 'vite-plugin-md'
export default {
plugins: [
Vue({
include: [/\.vue$/, /\.md$/], // <--
}),
Markdown(),
],
}
```
> This adds the VueJS along with _this_ repo as "plugins" to Vite. With VueJS you'll also want to make sure to include both `vue` and `md` files.
3. **Typescript Config** (optional)
If you're using Typescript than you'll want take the additional step of adding a "shim file" to help Typescript to understand how to think of Vue SFC files and Markdown files structurally. For VueJS developers, you've probably already done this for your VueJS files but you can wrap this up with a single file -- `shims.d.ts` -- in the root of your repo:
```ts
declare module '*.vue' {
import type { ComponentOptions } from 'vue'
const Component: ComponentOptions
export default Component
}
declare module '*.md' {
import type { ComponentOptions } from 'vue'
const Component: ComponentOptions
export default Component
}
```
4. **Builder Installs** (optional)
Modern versions of this plugin provide a powerful pipeline system for extending the functionality of this plugin. You can use provided/recommended plugins but you can create these yourself. More on this below but for now be aware that the three _builders_ which had been originally included as internal builders are now "external" to both demonstrate how you can do this and to keep this repo more focused on core pipelining.
The three "built-in" builders were `code()`, `link()`, and `meta()`. Instead of importing them directly as symbols from this repo you can now just import them directly from their repos:
- **code** - `pnpm add -D @yankeeinlondon/code-builder`
> `npm install -D @yankeeinlondon/code-builder`
> `yarn add -D @yankeeinlondon/code-builder`
- **meta** - `pnpm add --save-dev @yankeeinlondon/meta-builder`
- **link** - `pnpm add --save-dev @yankeeinlondon/link-builder`
At this point the process is exactly the same as before, you simply add these builders into the configuration for this repo like so:
```ts
import Markdown from 'vite-plugin-md'
import code from '@yankeeinlondon/code-builder'
export default {
plugins: [
Markdown({
builders: [code()]
})
]
}
```
>**Note:** `code`, `meta`, and `link` can all be imported from [**md-powerpack**](https://github.com/yankeeinlondon/md-powerpack) -- `npm install -D md-powerpack` -- which is an aggregation repo for builder API's. Either approach is equally valid.
## Using this Plugin
Refer to the _example_ app in this repo for a working example but the really short answer is ... just write markdown files in the same places where you might have written VueJS SFC components and they will both be treated as Vue components in every way.
That means you can:
1. **Import Markdown** as Vue components
```html
This is My Cool App
``` **Leveraging Meta Properties** It is often useful to have certain "meta properties" associated with your pages and you can do this easily in one of two ways: 1. If you use `@vueuse/head` then you can enable the `headEnabled` configuration option 2. If you want to go further you can add the [`meta()`](https://github.com/yankeeinlondon/meta-builder) builder mentioned above With both options you can start to add frontmatter like this: ```yaml meta: - name: My Cool App description: cool things happen to people who use cool apps ``` This will then intelligently be incorporated into `` tags in the resulting output. For more information look at the corresponding docs: - [Docs for `@vueuse/head`](https://github.com/vueuse/head) - [Docs for `@yankeeinlondon/meta-builder`](