Gathering detailed insights and metrics for vite-plugin-markdown
Gathering detailed insights and metrics for vite-plugin-markdown
Gathering detailed insights and metrics for vite-plugin-markdown
Gathering detailed insights and metrics for vite-plugin-markdown
A vite plugin to import a Markdown file in various formats like Front Matter, HTML, ToC, and React/Vue Component
npm install vite-plugin-markdown
Typescript
Module System
Node Version
NPM Version
TypeScript (72.08%)
JavaScript (27.92%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
281 Stars
281 Commits
50 Forks
2 Watchers
8 Branches
9 Contributors
Updated on Jun 15, 2025
Latest Version
2.2.0
Package Id
vite-plugin-markdown@2.2.0
Unpacked Size
23.14 kB
Size
7.12 kB
File Count
6
NPM Version
10.3.0
Node Version
18.19.0
Published on
Jan 17, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
4
1
A plugin enables you to import a Markdown file as various formats on your vite project.
npm i -D vite-plugin-markdown
npm i -D vite-plugin-markdown@vite-1
1const mdPlugin = require('vite-plugin-markdown') 2 3module.exports = { 4 plugins: [mdPlugin(options)] 5}
Then you can import front matter attributes from .md
file as default.
1--- 2title: Awesome Title 3description: Describe this awesome content 4tags: 5 - "great" 6 - "awesome" 7 - "rad" 8--- 9 10# This is awesome 11 12Vite is an opinionated web dev build tool that serves your code via native ES Module imports during dev and bundles it with Rollup for production.
1import { attributes } from './contents/the-doc.md'; 2 3console.log(attributes) //=> { title: 'Awesome Title', description: 'Describe this awesome content', tags: ['great', 'awesome', 'rad'] }
1mode?: ('html' | 'markdown' | 'toc' | 'react' | 'vue')[] 2markdown?: (body: string) => string 3markdownIt?: MarkdownIt | MarkdownIt.Options
Enum for mode
is provided as Mode
1import { Mode } from 'vite-plugin-markdown' 2 3console.log(Mode.HTML) //=> 'html' 4console.log(Mode.MARKDOWN) //=> 'markdown' 5console.log(Mode.TOC) //=> 'toc' 6console.log(Mode.REACT) //=> 'react' 7console.log(Mode.VUE) //=> 'vue'
"Mode" enables you to import markdown file in various formats (HTML, ToC, React/Vue Component)
Mode.HTML
1# This is awesome 2 3Vite is an opinionated web dev build tool that serves your code via native ES Module imports during dev and bundles it with Rollup for production.
1import { html } from './contents/the-doc.md'; 2 3console.log(html) //=> "<h1>This is awesome</h1><p>ite is an opinionated web dev build tool that serves your code via native ES Module imports during dev and bundles it with Rollup for production.</p>"
Mode.MARKDOWN
1import { markdown } from './contents/the-doc.md' 2 3console.log(markdown) //=> "# This is awesome \n Vite is an opinionated web dev build tool that serves your code via native ES Module imports during dev and bundles it with Rollup for production."
Mode.TOC
1# vite 2 3Vite is an opinionated web dev build tool that serves your code via native ES Module imports during dev and bundles it with Rollup for production. 4 5## Status 6 7## Getting Started 8 9# Notes
1import { toc } from './contents/the-doc.md' 2 3console.log(toc) //=> [{ level: '1', content: 'vite' }, { level: '2', content: 'Status' }, { level: '2', content: 'Getting Started' }, { level: '1', content: 'Notes' },]
Mode.REACT
1import React from 'react' 2import { ReactComponent } from './contents/the-doc.md' 3 4function MyReactApp() { 5 return ( 6 <div> 7 <ReactComponent /> 8 </div> 9}
1# This is awesome 2 3Vite is <MyComponent type={'react'}>
1import React from 'react' 2import { ReactComponent } from './contents/the-doc.md' 3import { MyComponent } from './my-component' 4 5function MyReactApp() { 6 return ( 7 <div> 8 <ReactComponent MyComponent={MyComponent} /> 9 </div> 10}
MyComponent
on markdown perform as a React component.
Mode.VUE
1<template> 2 <article> 3 <markdown-content /> 4 </article> 5</template> 6 7<script> 8import { VueComponent } from './contents/the-doc.md' 9 10export default { 11 components: { 12 MarkdownContent: VueComponent 13 } 14}; 15</script>
1# This is awesome 2 3Vite is <MyComponent :type="'vue'">
1<template> 2 <article> 3 <markdown-content /> 4 </article> 5</template> 6 7<script> 8import { VueComponentWith } from './contents/the-doc.md' 9import MyComponent from './my-component.vue' 10 11export default { 12 components: { 13 MarkdownContent: VueComponentWith({ MyComponent }) 14 } 15}; 16</script>
MyComponent
on markdown perform as a Vue component.
In TypeScript project, need to declare typedefs for .md
file as you need.
1declare module '*.md' { 2 // "unknown" would be more detailed depends on how you structure frontmatter 3 const attributes: Record<string, unknown>; 4 5 // When "Mode.TOC" is requested 6 const toc: { level: string, content: string }[]; 7 8 // When "Mode.HTML" is requested 9 const html: string; 10 11 // When "Mode.RAW" is requested 12 const raw: string 13 14 // When "Mode.React" is requested. VFC could take a generic like React.VFC<{ MyComponent: TypeOfMyComponent }> 15 import React from 'react' 16 const ReactComponent: React.VFC; 17 18 // When "Mode.Vue" is requested 19 import { ComponentOptions, Component } from 'vue'; 20 const VueComponent: ComponentOptions; 21 const VueComponentWith: (components: Record<string, Component>) => ComponentOptions; 22 23 // Modify below per your usage 24 export { attributes, toc, html, ReactComponent, VueComponent, VueComponentWith }; 25}
Save as vite.d.ts
for instance.
MIT
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/6 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
11 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More