Replace Elysia with bun.serve for hot reloading and static serving
This commit is contained in:
19
bun_plugins/markdown-loader.ts
Normal file
19
bun_plugins/markdown-loader.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user