Skip to content

Commit

Permalink
Added script for build-time conversion from md
Browse files Browse the repository at this point in the history
  • Loading branch information
LordKa0S committed Jul 18, 2021
1 parent 125e5b9 commit 806bd01
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/md-to-partials.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import marked from "marked";
import { readdir, readFile, writeFile } from "fs/promises";
import { join } from "path";

const mdDirPath = "markdown";

const genPartialsPath = "handlebars/partials/gen";

marked.setOptions({
headerIds: false,
});

const fileNames = await readdir(mdDirPath);
fileNames.forEach(async fileName => {
const md = await readFile(join(mdDirPath, fileName), "utf8");
const html = marked(md);
writeFile(join(genPartialsPath, fileName.replace("md", "hbs")), html);
})

0 comments on commit 806bd01

Please sign in to comment.