Skip to content

Instantly share code, notes, and snippets.

@kartiknair
Created March 10, 2020 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kartiknair/c377abca0552c582b05920e51771525c to your computer and use it in GitHub Desktop.
Save kartiknair/c377abca0552c582b05920e51771525c to your computer and use it in GitHub Desktop.
const fs = require("fs");
const postMethods = require("./posts");
const config = require("./config");
const addHomePage = require("./homepage");
const posts = fs
.readdirSync(config.dev.postsdir)
.map(post => post.slice(0, -3))
.map(post => postMethods.createPost(post))
.sort(function(a, b) {
return b.attributes.date - a.attributes.date;
});
if (!fs.existsSync(config.dev.outdir)) fs.mkdirSync(config.dev.outdir);
postMethods.createPosts(posts);
addHomePage(posts);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment