{"size": 1005, "ext": "js", "max_stars_repo_path": "scripts/extend.generator.js", "max_stars_repo_name": "xulinfeng/blog", "max_stars_repo_stars_event_min_datetime": "2015-05-27T14:45:39.000Z", "max_stars_repo_stars_event_max_datetime": "2015-11-25T12:16:18.000Z", "max_issues_repo_path": "scripts/extend.generator.js", "max_issues_repo_name": "zilong-thu/hexo-theme-darkchenall", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "scripts/extend.generator.js", "max_forks_repo_name": "zilong-thu/hexo-theme-darkchenall", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.7692307692, "max_line_length": 82, "alphanum_fraction": 0.6547263682}
var extend = hexo.extend;
var route = hexo.route;
var fs = require('fs');

extend.generator.register(function(locals, render, callback){
  if (usercfg && usercfg.themeconfig && usercfg.themeconfig.ajax_widgets){
    var base_path = hexo.theme_dir + 'layout/_widgets/static/';

    if (!fs.existsSync(base_path)) callback();

    var files=fs.readdirSync(base_path);
    files.forEach(function(file){
      var ff = file.match(/^(.+)\.ejs$/);

      if (ff == null) return;

      render('widgets/'+ff[1]+'.html', ['widget'],{name: ff[1],layout: 'widget'});
    });
  }
  callback();
});

extend.generator.register(function(locals, render, callback){
  var posts = locals.posts;
  var SitePosts = [];
  posts.each(function(item){
    SitePosts.push({title: item.title,uri: item.path});
  })
  route.set('js/posts.js',JSON.stringify(SitePosts));
  callback();
});

hexo.on('generateBefore',function(){
  hexo.log.d('generateBefore');
})
hexo.on('generateAfter',function(){
  hexo.log.d('generateAfter');
})
