Markdown NodeJS Blog Generator
see the code on GitHub view the blog on repl.it
My objectives:
- Create my own blog using NodeJS ✅
- Learn
fs
commands in NodeJS ✅ - Convert Markdown files to HTML using the
marked
module ✅ - Create an Express server and host it on repl.it ✅
- ✌
How the code works:
- Posts are made as individual MD files (see ‘content’ folder)
- Front-matter within the posts gets parsed
- The
marked
module converts MD to HTML - and the magic of JavaScript puts it all together 🧙♂️
snippet
const createPost = postPath => {
const data = fs.readFileSync(`${config.dev.postsdir}/${postPath}.md`, "utf8");
const content = fm(data);
content.body = marked(content.body);
content.path = postPath;
return content;
};