src/plugins/toc.js
function(config, stream, extras, callback) {

    var tocFiles = this.tocFiles = [];

    // First run through every file and get a tree of the section
    // navigation within that file. Save to our nav object.
    stream = stream.pipe(through.obj(function(file, enc, cb) {

      // create cheerio element for file if not present
      file.$el = file.$el || cheerio.load(file.contents.toString());

      // make this work whether or not we have a
      // full HTML file.
      var root = file.$el.root();
      var body = file.$el('body');
      if(body.length) root = body;

      // add sections to plugin array for use later in the pipeline
      tocFiles.push({
        file: file,
        sections: getSections(file.$el, root, file.relative)
      });

      cb(null, file);
    }));

    callback(null, config, stream, extras);
  }
function(config, stream, extras, callback) {

    var tocFiles = this.tocFiles = [];

    // First run through every file and get a tree of the section
    // navigation within that file. Save to our nav object.
    stream = stream.pipe(through.obj(function(file, enc, cb) {

      // create cheerio element for file if not present
      file.$el = file.$el || cheerio.load(file.contents.toString());

      // make this work whether or not we have a
      // full HTML file.
      var root = file.$el.root();
      var body = file.$el('body');
      if(body.length) root = body;

      // add sections to plugin array for use later in the pipeline
      tocFiles.push({
        file: file,
        sections: getSections(file.$el, root, file.relative)
      });

      cb(null, file);
    }));

    callback(null, config, stream, extras);
  }
function ( config , stream , extras , callback ) { var tocFiles = this . tocFiles = [ ] ; // First run through every file and get a tree of the section // navigation within that file. Save to our nav object. stream = stream . pipe ( through . obj ( function ( file , enc , cb ) { // create cheerio element for file if not present file . $el = file . $el || cheerio . load ( file . contents . toString ( ) ) ; // make this work whether or not we have a // full HTML file. var root = file . $el . root ( ) ; var body = file . $el ( 'body' ) ; if ( body . length ) root = body ; // add sections to plugin array for use later in the pipeline tocFiles . push ( { file : file , sections : getSections ( file . $el , root , file . relative ) } ) ; cb ( null , file ) ; } ) ) ; callback ( null , config , stream , extras ) ; }
When the files have been converted, we run the TOC generation. This is happening before the layouts, because it won't work if the markup is wrapped in container div's. We should rewrite the TOC generation to work with this.
When the files have been converted we run the TOC generation . This is happening before the layouts because it won t work if the markup is wrapped in container div s . We should rewrite the TOC generation to work with this .