Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generate markdown files with faker.js
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
You can’t perform that action at this time.