Skip to content

Instantly share code, notes, and snippets.

@nullcookies
Forked from DavidWells/generate-md-files.js
Created September 13, 2019 21: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 nullcookies/9579447a96c1ae6b39681d98a942abdf to your computer and use it in GitHub Desktop.
Save nullcookies/9579447a96c1ae6b39681d98a942abdf to your computer and use it in GitHub Desktop.
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