把我的前体放在哪里

  • 本文关键字:在哪里 node.js npm gulp
  • 更新时间 :
  • 英文 :


我正试图使用这个npm模块从markdown文件中剥离一些前沿内容,然后允许我访问它剥离的markdown。这就引出了我的问题(来自模块页面的代码):

var frontMatter = require('gulp-front-matter');
gulp.task('blog-posts', function() {
    gulp.src('./posts/*.md')
        .pipe(frontMatter({          // optional configuration 
            property: 'frontMatter', // property added to file object  
            remove: true // should we remove front-matter header? 
        }))
        .pipe(…); 
    });

这就是评论// property added to the file object。这是什么意思?我如何获取前端事务数据?也许更准确地说,我如何访问"文件"对象?

永不终止。该模块假设人们将使用该模块,该模块允许访问file对象。我似乎已经找到了我的问题的答案:gullow数据希望成为"将数据附加到文件对象以供其他插件使用"的标准方式,这显然是gullow目前没有标准的东西。

工作代码:

var gulp = require('gulp');
var markdown = require('gulp-markdown');
var frontMatter = require('gulp-front-matter');
var data = require('gulp-data');
markdown.marked.setOptions({
    gfm: false
});
gulp.task('default', function () {
    return gulp.src('*.md')
        .pipe(frontMatter({ 
            property: 'pig',
            remove: true 
        }))
        .pipe(data(function(file) {
            console.log(file.pig.layout);
        }))
        .pipe(markdown({tables: true}))
        .pipe(gulp.dest('dist'));

});

最新更新