sparkartgroup / gulp-markdown-to-json

Parse Markdown and YAML → compile Markdown to HTML → wrap it all up in JSON
MIT License
75 stars 14 forks source link

Contents returning as buffer #27

Open dblodorn opened 6 years ago

dblodorn commented 6 years ago

Hi im trying to use this to render templates in pug with gulp-wrap. for some reason when console out the contents of my test.md file get returned as a buffer 🤷‍♂️ ? Any idea as to why this would be happening - i'm using marked as the markdown renderer.

gulp.task('docs', function() {
  return gulp.src('./src/pages/*.md')
     .pipe(md(marked))
     .pipe(wrap(function(data) {
        console.log(data);
        var template = __dirname + '/src/pug/templates/' + data.contents.template;
        return fs.readFileSync(template).toString();
    }, {}, {
      engine: 'pug'
    }))
    .pipe(rename({extname:'.html'}))
    .pipe(gulp.dest('./dist/'));
});

-----> CONSOLES:

{ file: <File "test.md" <Buffer 7b 22 74 65 6d 70 6c 61 74 65 22 3a 22 74 65 6d 70 6c 61 74 65 2e 70 75 67 22 2c 22 74 69 74 6c 65 22 3a 22 54 65 73 74 22 2c 22 75 70 64 61 74 65 64 ... >>,
engine: 'pug',
contents: <Buffer 7b 22 74 65 6d 70 6c 61 74 65 22 3a 22 74 65 6d 70 6c 61 74 65 2e 70 75 67 22 2c 22 74 69 74 6c 65 22 3a 22 54 65 73 74 22 2c 22 75 70 64 61 74 65 64 ... > }