
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
vite-plugin-markdown
Advanced tools
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
const mdPlugin = require('vite-plugin-markdown')
module.exports = {
plugins: [mdPlugin(options)]
}
Then you can import front matter attributes from .md file as default.
---
title: Awesome Title
description: Describe this awesome content
tags:
- "great"
- "awesome"
- "rad"
---
# This is awesome
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.
import { attributes } from './contents/the-doc.md';
console.log(attributes) //=> { title: 'Awesome Title', description: 'Describe this awesome content', tags: ['great', 'awesome', 'rad'] }
mode?: ('html' | 'markdown' | 'toc' | 'react' | 'vue')[]
markdown?: (body: string) => string
markdownIt?: MarkdownIt | MarkdownIt.Options
Enum for mode is provided as Mode
import { Mode } from 'vite-plugin-markdown'
console.log(Mode.HTML) //=> 'html'
console.log(Mode.MARKDOWN) //=> 'markdown'
console.log(Mode.TOC) //=> 'toc'
console.log(Mode.REACT) //=> 'react'
console.log(Mode.VUE) //=> 'vue'
"Mode" enables you to import markdown file in various formats (HTML, ToC, React/Vue Component)
Mode.HTML# This is awesome
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.
import { html } from './contents/the-doc.md';
console.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.MARKDOWNimport { markdown } from './contents/the-doc.md'
console.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# vite
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.
## Status
## Getting Started
# Notes
import { toc } from './contents/the-doc.md'
console.log(toc) //=> [{ level: '1', content: 'vite' }, { level: '2', content: 'Status' }, { level: '2', content: 'Getting Started' }, { level: '1', content: 'Notes' },]
Mode.REACTimport React from 'react'
import { ReactComponent } from './contents/the-doc.md'
function MyReactApp() {
return (
<div>
<ReactComponent />
</div>
}
# This is awesome
Vite is <MyComponent type={'react'}>
import React from 'react'
import { ReactComponent } from './contents/the-doc.md'
import { MyComponent } from './my-component'
function MyReactApp() {
return (
<div>
<ReactComponent MyComponent={MyComponent} />
</div>
}
MyComponent on markdown perform as a React component.
Mode.VUE<template>
<article>
<markdown-content />
</article>
</template>
<script>
import { VueComponent } from './contents/the-doc.md'
export default {
components: {
MarkdownContent: VueComponent
}
};
</script>
# This is awesome
Vite is <MyComponent :type="'vue'">
<template>
<article>
<markdown-content />
</article>
</template>
<script>
import { VueComponentWith } from './contents/the-doc.md'
import MyComponent from './my-component.vue'
export default {
components: {
MarkdownContent: VueComponentWith({ MyComponent })
}
};
</script>
MyComponent on markdown perform as a Vue component.
In TypeScript project, need to declare typedefs for .md file as you need.
declare module '*.md' {
// "unknown" would be more detailed depends on how you structure frontmatter
const attributes: Record<string, unknown>;
// When "Mode.TOC" is requested
const toc: { level: string, content: string }[];
// When "Mode.HTML" is requested
const html: string;
// When "Mode.RAW" is requested
const raw: string
// When "Mode.React" is requested. VFC could take a generic like React.VFC<{ MyComponent: TypeOfMyComponent }>
import React from 'react'
const ReactComponent: React.VFC;
// When "Mode.Vue" is requested
import { ComponentOptions, Component } from 'vue';
const VueComponent: ComponentOptions;
const VueComponentWith: (components: Record<string, Component>) => ComponentOptions;
// Modify below per your usage
export { attributes, toc, html, ReactComponent, VueComponent, VueComponentWith };
}
Save as vite.d.ts for instance.
MIT
FAQs
Import markdown files in vite
The npm package vite-plugin-markdown receives a total of 45,465 weekly downloads. As such, vite-plugin-markdown popularity was classified as popular.
We found that vite-plugin-markdown demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.