dist/index.js
function transform(file, enc, cb, opts) {
      if (file.isNull()) {
        cb(null, file);
      }

      if (file.isStream()) {
        cb(new PluginError('base-apps-router', 'Streams not supported.'));
      }

      if (file.isBuffer()) {
        var frontMatter = fm(file.contents.toString());
        if (frontMatter.frontmatter) {
          frontMatter.attributes.path = file.path;
          router.addRoute(frontMatter.attributes);
          file.contents = new Buffer(frontMatter.body);
        }
        cb(null, file);
      }
    }
function transform(file, enc, cb, opts) {
      if (file.isNull()) {
        cb(null, file);
      }

      if (file.isStream()) {
        cb(new PluginError('base-apps-router', 'Streams not supported.'));
      }

      if (file.isBuffer()) {
        var frontMatter = fm(file.contents.toString());
        if (frontMatter.frontmatter) {
          frontMatter.attributes.path = file.path;
          router.addRoute(frontMatter.attributes);
          file.contents = new Buffer(frontMatter.body);
        }
        cb(null, file);
      }
    }
function transform ( file , enc , cb , opts ) { if ( file . isNull ( ) ) { cb ( null , file ) ; } if ( file . isStream ( ) ) { cb ( new PluginError ( 'base-apps-router' , 'Streams not supported.' ) ) ; } if ( file . isBuffer ( ) ) { var frontMatter = fm ( file . contents . toString ( ) ) ; if ( frontMatter . frontmatter ) { frontMatter . attributes . path = file . path ; router . addRoute ( frontMatter . attributes ) ; file . contents = new Buffer ( frontMatter . body ) ; } cb ( null , file ) ; } }
Pulls the Front Matter from an HTML file, adds it to the route list, and returns a modified file without the Front Matter.
@prop {File} file - Vinyl file.
@prop {String} enc - File encoding.
@prop {Function} cb - Callback to return modified file or errors.
@prop {PluginOptions} opts - Plugin options.
Pulls the Front Matter from an HTML file adds it to the route list and returns a modified file without the Front Matter .