WIP: Architecture Refactor, add and rename plugins for handling content
This commit is contained in:
16
bun_plugins/onStartup-post-importer.ts
Normal file
16
bun_plugins/onStartup-post-importer.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import matter from 'gray-matter';
|
||||
import { loadMetadata } from "./utils";
|
||||
|
||||
// When the server starts, import all the blog post metadata into the database
|
||||
// Executed on startup because it's included in <root> ./bunfig.toml
|
||||
|
||||
(async () => {
|
||||
const glob = new Bun.Glob("**/*.md");
|
||||
for await (const file of glob.scan("./content")) {
|
||||
const {data, content } = matter(await Bun.file(`./content/${file}`).text());
|
||||
const route = `/${file.replace(/\.md$/, "")}`;
|
||||
loadMetadata(route, data);
|
||||
}
|
||||
|
||||
console.log('Posts have been imported into db');
|
||||
})();
|
||||
Reference in New Issue
Block a user