vite-plugin-md-data

Access the markdown data
694 3
Install
npm install vite-plugin-md-data
Latest Version:1.3.3
Vue:3
License:MIT
Last Updated:Feb 5, 2023
Links: GitHub  ·  npm
Maintainer: ryo_gk

vite-plugin-md-data

Getting Started

Install

> npm install -D vite-plugin-md-data 

Add the below to vite.config.js. You have to pass the options having path property which is used to specify the directory containing markdown files.

import vue from '@vitejs/plugin-vue'
import ViteMdData from 'vite-plugin-md-data'

export default {
  plugins: [
    vue(),
    ViteMdData({ 
      path: './dev/posts/',
      callback: (data) => data.filter(d => d.publised === true), // Callback to process for markdown data.
      asRaw: false, // Not parse the content to HTML if `true`.
      declaration: { // Generate d.ts file.
        outDir: './types/' // Path to which generate a declaration.
      }
    })
  ]
}

And you can import path, frontmatter, and content via virtual:vite-plugin-md-data like below.

<script setup>
import { data } from 'virtual:vite-plugin-md-data'

console.log(data)// [{ path: '...', frontmatter: { ... }, content: '<h2>...</h2>...' }, { ... }]
</script>

Also, this may be needed.

Related Packages

vite-plugin-vue-md

Simple and fast vue3 markdown vite plugin

365 1
@vitejs/plugin-vue

The official plugin for Vue SFC support in Vite.

333,357,380 686
vite-plugin-checker

Vite plugin that runs TypeScript type checker on a separate process.

133,975,562 1,242
@vitejs/plugin-vue-jsx

Provides Vue 3 JSX & TSX support with HMR.

93,663,827 686
vite-plugin-ssr

Like Next.js/Nuxt but as do-one-thing-do-it-well Vite plugin.

550,634 18

Version History

Version Released Vue License
1.3.3 ^3.2.36 MIT
1.3.2 ^3.2.36 MIT
1.3.0 ^3.2.36 MIT
1.2.0 ^3.2.36 MIT
1.1.0 ^3.2.36 MIT