20 lines
435 B
TypeScript
20 lines
435 B
TypeScript
import type {BunPlugin} from 'bun';
|
|
import { marked } from 'marked';
|
|
|
|
const markdownLoader: BunPlugin = {
|
|
name: 'markdown-loader',
|
|
setup(build) {
|
|
// Plugin implementation
|
|
build.onLoad({filter: /\.md$/}, async args => {
|
|
const text = await Bun.file(args.path).text();
|
|
const html = marked.parse(text);
|
|
return {
|
|
contents: `export default ${html};`,
|
|
loader: 'html',
|
|
};
|
|
});
|
|
},
|
|
};
|
|
|
|
export default markdownLoader;
|