Skip to content

Instantly share code, notes, and snippets.

@kartiknair
Created March 10, 2020 07:40
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/008f35e05e0e71cfcef0f757b58acb2a to your computer and use it in GitHub Desktop.
Save kartiknair/008f35e05e0e71cfcef0f757b58acb2a to your computer and use it in GitHub Desktop.
const createPosts = posts => {
posts.forEach(post => {
if (!fs.existsSync(`${config.dev.outdir}/${post.path}`))
fs.mkdirSync(`${config.dev.outdir}/${post.path}`);
fs.writeFile(
`${config.dev.outdir}/${post.path}/index.html`,
posthtml(post),
e => {
if (e) throw e;
console.log(`${post.path}/index.html was created successfully`);
}
);
});
};
module.exports = {
createPost: createPost,
createPosts: createPosts
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment