vuecssuiant-designantdreactantantd-vueenterprisefrontendui-designvue-antdvue-antd-uivue3vuecomponent
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
655 B
22 lines
655 B
import { createMarkdownToVueRenderFn } from './markdownToVue'; |
|
import type { MarkdownOptions } from './markdown/markdown'; |
|
import type { Plugin } from 'vite'; |
|
|
|
interface Options { |
|
root?: string; |
|
markdown?: MarkdownOptions; |
|
} |
|
|
|
export default (options: Options = {}): Plugin => { |
|
const { root, markdown } = options; |
|
const markdownToVue = createMarkdownToVueRenderFn(root, markdown); |
|
return { |
|
name: 'mdToVue', |
|
async transform(code, id) { |
|
if (id.endsWith('.md')) { |
|
// transform .md files into vueSrc so plugin-vue can handle it |
|
return { code: (await markdownToVue(code, id)).vueSrc, map: null }; |
|
} |
|
}, |
|
}; |
|
};
|
|
|