-
-
Save nnennajohn/8804a92e965dd83db4d6828848526fb2 to your computer and use it in GitHub Desktop.
Generate markdown files with faker.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var faker = require('faker') | |
var fs = require('fs') | |
var path = require('path') | |
for (var i = 0; i < 1000; i++) { | |
generateMD() | |
} | |
function generateMD () { | |
var fileName = faker.lorem.word() + '-' + faker.lorem.word() | |
var fileContents = `--- | |
title: "${faker.lorem.words()}" | |
layout: Page | |
--- | |
${faker.lorem.sentence()} | |
` | |
var outputPath = path.join(__dirname, '../content/md', `${fileName}.md`) | |
fs.writeFile(outputPath, fileContents, function (err) { | |
if (err) { | |
return console.log(err) | |
} | |
console.log(outputPath + ' file generated') | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment