Skip to content

Instantly share code, notes, and snippets.

@kartiknair
Created March 10, 2020 07:45
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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