<commit_before>var fs = require('fs');

module.exports = function (BasePlugin) {
  return BasePlugin.extend({
      name: 'jsonapi',
      writeAfter: function(opts, next) {
        console.log('hellooooooo!');
        
        var collection, templateData;
        
        ({collection, templateData} = opts);

        //console.log(collection.models[0].attributes);
        //console.log(collection.models[0].meta.attributes);

        collection.models.forEach(function(model, cbEach) {
          var attributes = model.meta.attributes;
          if(attributes.layout && attributes.layout === 'post') {
            //console.log(attributes);
            var outName = model.attributes.outPath;
            if(outName.indexOf('.html') > -1) {
              var jsonName = model.attributes.outPath.replace('/index.html', '.json');
 
              fs.writeFile(jsonName, JSON.stringify(attributes), function (err) {
                if (err) return console.log(err);
                console.log('Wrote ' + jsonName);
              });
            }
          }
        });

        next();
      }
  });
};<commit_msg>Simplified JSON API plugin<commit_after>var fs = require('fs');

module.exports = function (BasePlugin) {
  return BasePlugin.extend({
      name: 'jsonapi',
      writeAfter: function(opts, next) {
        console.log('Starting JSON API Generation');
        
        var collection, templateData;
        
        ({collection, templateData} = opts);

        //console.log(collection.models[0].attributes);
        //console.log(collection.models[0].meta.attributes);

        collection.models.forEach(function(model, cbEach) {
          var attributes = model.meta.attributes;
          if(attributes.layout && attributes.layout === 'post') {
            //console.log(attributes);
            var outName = model.attributes.outPath;
            var jsonName = model.attributes.outPath.replace('/index.html', '.json');

            fs.writeFile(jsonName, JSON.stringify(attributes), function (err) {
              if (err) return console.log(err);
              console.log('Wrote API File ' + jsonName);
            });
          }
        });

        next();
      }
  });
};
{'fraction_non_alphanumeric': 0.1412994093593821, 'fraction_numerical': 0.002271694684234439, 'mean_word_length': 2.0840336134453783, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '932121', 'n_tokens_mistral': 592, 'n_tokens_neox': 578, 'n_words': 108}