lib/generate.js
function(site_path, arg, cmd, done) {
    var start = Date.now();
    var nell_site = {
      site_path: site_path
    };

    async.series([
      function(callback) {
        nell_site.config_path = path.join(site_path, 'nell.json');
        fs.exists(nell_site.config_path, function(exists) {
          if (!exists) {
            return callback(new Error(__('Unable to load nell.json config file')));
          }
          callback();
        });
      },
      function(callback) {
        nell_site.config = require(nell_site.config_path);
        nell_site.output_path =  (nell_site.config.output && nell_site.config.output.path) ? path.join(nell_site.site_path, nell_site.config.output.path) : path.join(nell_site.site_path, 'output');
        async.forEach(Object.keys(nell_site.config), function(key, key_done) {
          nell_site[key] = nell_site.config[key] || {};
          key_done();
        }, callback);
      },
      function(callback) {
        loadSwig(nell_site, callback);
      },
      function(callback) {
        loadItems(nell_site, 'post', callback);
      },
      function(callback) {
        loadItems(nell_site, 'page', callback);
      },
      function(callback) {
        if (nell_site.config.output && nell_site.config.output.delete) {
          fs.unlink(nell_site.output_path, callback);
        } else {
          callback();
        }
      },
      function(callback) {
        outputItems(nell_site, 'post', callback);
      },
      function(callback) {
        outputItems(nell_site, 'page', callback);
      },
      function(callback) {
        outputIndex(nell_site, callback);
      },
      function(callback) {
        moveStatic(nell_site, callback);
      }
    ], function(err) {
      var end = Date.now();
      if (err) {
        return done(err);
      }
      done(null, __('Site "%s" generated in %ds', nell_site.site.title, (end - start) / 1000));
    });
  }
function(site_path, arg, cmd, done) {
    var start = Date.now();
    var nell_site = {
      site_path: site_path
    };

    async.series([
      function(callback) {
        nell_site.config_path = path.join(site_path, 'nell.json');
        fs.exists(nell_site.config_path, function(exists) {
          if (!exists) {
            return callback(new Error(__('Unable to load nell.json config file')));
          }
          callback();
        });
      },
      function(callback) {
        nell_site.config = require(nell_site.config_path);
        nell_site.output_path =  (nell_site.config.output && nell_site.config.output.path) ? path.join(nell_site.site_path, nell_site.config.output.path) : path.join(nell_site.site_path, 'output');
        async.forEach(Object.keys(nell_site.config), function(key, key_done) {
          nell_site[key] = nell_site.config[key] || {};
          key_done();
        }, callback);
      },
      function(callback) {
        loadSwig(nell_site, callback);
      },
      function(callback) {
        loadItems(nell_site, 'post', callback);
      },
      function(callback) {
        loadItems(nell_site, 'page', callback);
      },
      function(callback) {
        if (nell_site.config.output && nell_site.config.output.delete) {
          fs.unlink(nell_site.output_path, callback);
        } else {
          callback();
        }
      },
      function(callback) {
        outputItems(nell_site, 'post', callback);
      },
      function(callback) {
        outputItems(nell_site, 'page', callback);
      },
      function(callback) {
        outputIndex(nell_site, callback);
      },
      function(callback) {
        moveStatic(nell_site, callback);
      }
    ], function(err) {
      var end = Date.now();
      if (err) {
        return done(err);
      }
      done(null, __('Site "%s" generated in %ds', nell_site.site.title, (end - start) / 1000));
    });
  }
function ( site_path , arg , cmd , done ) { var start = Date . now ( ) ; var nell_site = { site_path : site_path } ; async . series ( [ function ( callback ) { nell_site . config_path = path . join ( site_path , 'nell.json' ) ; fs . exists ( nell_site . config_path , function ( exists ) { if ( ! exists ) { return callback ( new Error ( __ ( 'Unable to load nell.json config file' ) ) ) ; } callback ( ) ; } ) ; } , function ( callback ) { nell_site . config = require ( nell_site . config_path ) ; nell_site . output_path = ( nell_site . config . output && nell_site . config . output . path ) ? path . join ( nell_site . site_path , nell_site . config . output . path ) : path . join ( nell_site . site_path , 'output' ) ; async . forEach ( Object . keys ( nell_site . config ) , function ( key , key_done ) { nell_site [ key ] = nell_site . config [ key ] || { } ; key_done ( ) ; } , callback ) ; } , function ( callback ) { loadSwig ( nell_site , callback ) ; } , function ( callback ) { loadItems ( nell_site , 'post' , callback ) ; } , function ( callback ) { loadItems ( nell_site , 'page' , callback ) ; } , function ( callback ) { if ( nell_site . config . output && nell_site . config . output . delete ) { fs . unlink ( nell_site . output_path , callback ) ; } else { callback ( ) ; } } , function ( callback ) { outputItems ( nell_site , 'post' , callback ) ; } , function ( callback ) { outputItems ( nell_site , 'page' , callback ) ; } , function ( callback ) { outputIndex ( nell_site , callback ) ; } , function ( callback ) { moveStatic ( nell_site , callback ) ; } ] , function ( err ) { var end = Date . now ( ) ; if ( err ) { return done ( err ) ; } done ( null , __ ( 'Site "%s" generated in %ds' , nell_site . site . title , ( end - start ) / 1000 ) ) ; } ) ; }
This function allows us to generate the complete site output.
It first needs to read all the source data, this way we have all the available
post and page data used to generate our page content, and also make available
to other sections like sidebars
This function allows us to generate the complete site output . It first needs to read all the source data this way we have all the available post and page data used to generate our page content and also make available to other sections like sidebars