You can use gulp for all the file stuff!

```js
var es = require('event-stream');

gulp.task('docs-index', function() {
  var idx = lunrStuff();
  var ref = {};

  return gulp.src([
    'tmp/ionic-site/docs/{components,guide,overview,angularjs}/**/*.{md,html}', 
    'tmp/ionic-site/tutorials/**/*.{md,html}'
  ])
    .pipe(es.map(function(file, callback) {
      var contents = file.contents.toString(); //was buffer
      var yamlStartIndex = contents.indexOf('---');
      if (yamlStartIndex > -1) {
        var yamlEndIndex = contents.indexOf('\n---', yamlStartIndex);
        var yamlRaw = contents.substring(yamlStartIndex + 3, yamlEndIndex);
        //read yaml and etc
      }
      //read html and etc
      
      //uh oh a problem!
      if (hadAProblem) {
        callback('You had a problem, yo');
      } else {
        callback();
      }
    })).on('end', function() {
      //write that json file
    });
});