unplugin-vue-markdown

30.0.0 · active · verified Sun Apr 19

unplugin-vue-markdown is a compiler that transforms Markdown files into Vue components, enabling the seamless integration of Markdown content within Vue applications. It supports using Markdown as Vue components and embedding Vue components directly within Markdown. Currently at version 30.0.0, the library follows an active release cadence, frequently updating to support the latest versions of build tools like Vite and Node.js. Its primary differentiator is its `unplugin` architecture, allowing broad compatibility across Vite, Webpack, and Vue CLI, and offering a transformation pipeline similar to VitePress. This makes it a versatile tool for documentation sites, blogs, and content-driven applications built with Vue, especially those prioritizing Markdown as a primary content format. Recent major updates have focused on dependency modernizations and dropping support for older Node.js versions.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to configure `unplugin-vue-markdown` with Vite and `@vitejs/plugin-vue` to enable Markdown file processing as Vue components. It highlights the essential `include` option.

import { defineConfig } from 'vite'
import Vue from '@vitejs/plugin-vue'
import Markdown from 'unplugin-vue-markdown/vite'

// Install dependencies:
// npm install -D vite @vitejs/plugin-vue unplugin-vue-markdown vue

export default defineConfig({
  plugins: [
    Vue({
      include: [/\.vue$/, /\u005c.md$/], // <-- Crucial: enables Vue to process .md files
    }),
    Markdown({
      // Optional configuration, e.g., enabling head management
      // headEnabled: true,
      // markdownUses: [ require('markdown-it-prism') ] // Example for a custom markdown-it plugin (ensure compatibility with markdown-exit in v30)
    }),
  ],
})

// To use in a Vue component (e.g., App.vue):
// <template>
//   <MyMarkdownContent />
// </template>
// <script setup>
// import MyMarkdownContent from './path/to/my-doc.md'
// </script>

view raw JSON →