Last active
January 10, 2017 14:51
-
-
Save Shwartz/815fd88e35312fd2844145089e788888 to your computer and use it in GitHub Desktop.
gulp task to create index file with a list of all files - TOC
This file contains hidden or 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
/* | |
* Utility to create index file with a list of all files - TOC | |
* */ | |
gulp.task('create-toc', function () { | |
var fs = require('fs'); | |
var fileList = ''; | |
fs.readdir('pages/cats', function(err, files) { | |
files.forEach(function (file) { | |
fileList += '<li><a href="'+ file +'">'+ file +'</a></li>'; | |
}); | |
fs.writeFileSync('pages/cats/index.html', '<html><head></head><body><h3>Content</h3><ul>'+ fileList +'</ul></body></html>'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment