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

    // Finish the stream so we get a full array of files, that
    // we can use to figure out whether add prev/next placeholders.
    streamHelpers.finishWithFiles(stream, function(files) {

      // loop through each file and get the title of the heading
      // as well as the relative file path.
      _.each(files, function(file, i) {

        var nav = {};

        // if there was a file before this one, add placeholders
        if(files[i-1]) {
          file.prev = files[i-1];
          nav.prev = { label: "MBINSERTPREVLABEL", href: "MBINSERTPREVHREF" }
        }

        // if there is a file after this one, add placeholders
        if(files[i+1]) {
          file.next = files[i+1];
          nav.next = { label: "MBINSERTNEXTLABEL", href: "MBINSERTNEXTHREF" }
        }

        _.set(file, "pageLocals.navigation", nav);
        _.set(file, "layoutLocals.navigation", nav);

      });

      // create new stream from the files
      stream = streamHelpers.streamFromArray(files);

      callback(null, config, stream, extras);

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

    // Finish the stream so we get a full array of files, that
    // we can use to figure out whether add prev/next placeholders.
    streamHelpers.finishWithFiles(stream, function(files) {

      // loop through each file and get the title of the heading
      // as well as the relative file path.
      _.each(files, function(file, i) {

        var nav = {};

        // if there was a file before this one, add placeholders
        if(files[i-1]) {
          file.prev = files[i-1];
          nav.prev = { label: "MBINSERTPREVLABEL", href: "MBINSERTPREVHREF" }
        }

        // if there is a file after this one, add placeholders
        if(files[i+1]) {
          file.next = files[i+1];
          nav.next = { label: "MBINSERTNEXTLABEL", href: "MBINSERTNEXTHREF" }
        }

        _.set(file, "pageLocals.navigation", nav);
        _.set(file, "layoutLocals.navigation", nav);

      });

      // create new stream from the files
      stream = streamHelpers.streamFromArray(files);

      callback(null, config, stream, extras);

    });
  }
function ( config , stream , extras , callback ) { // Finish the stream so we get a full array of files, that // we can use to figure out whether add prev/next placeholders. streamHelpers . finishWithFiles ( stream , function ( files ) { // loop through each file and get the title of the heading // as well as the relative file path. _ . each ( files , function ( file , i ) { var nav = { } ; // if there was a file before this one, add placeholders if ( files [ i - 1 ] ) { file . prev = files [ i - 1 ] ; nav . prev = { label : "MBINSERTPREVLABEL" , href : "MBINSERTPREVHREF" } } // if there is a file after this one, add placeholders if ( files [ i + 1 ] ) { file . next = files [ i + 1 ] ; nav . next = { label : "MBINSERTNEXTLABEL" , href : "MBINSERTNEXTHREF" } } _ . set ( file , "pageLocals.navigation" , nav ) ; _ . set ( file , "layoutLocals.navigation" , nav ) ; } ) ; // create new stream from the files stream = streamHelpers . streamFromArray ( files ) ; callback ( null , config , stream , extras ) ; } ) ; }
On load we add placeholders, to be filled in later in the build process when we have the correct filenames.
On load we add placeholders to be filled in later in the build process when we have the correct filenames .