I'm using gulp-markdown-to-json
and gulp-jade
My aim is to grab data from markdown file which looks like this:
---
template: index.jade
title: Europa
---
This is a test.
grab template: index.jade
file and pass it along with other variables to jade compiler.
So far I've this:
gulp.task('docs', function() {
return gulp
.src('./src/docs/pages/*.md')
.pipe(md({
pedantic: true,
smartypants: true
}))
.pipe(jade({
jade: jade,
pretty: true
}))
.pipe(gulp.dest('./dist/docs'));
});
I'm missing a step where json from markdown is read, and jade template filename fed to gulp.src before jade compiler runs.
You don't need to use
gulp-markdownto-json
. There if a lot of better solutions. For example:Here is an example how I use article-data in my personal blog.
gulp-jade
is the wrong gulp plugin for your use case.If you have a stream of templates that you want to fill with data, use
gulp-jade
:If you have a stream of data that you want to render in templates, use
gulp-wrap
:Your case is a little more difficult, since you want a different
.jade
template for each.md
file. Luckilygulp-wrap
accepts a function which can return a different template for each file in the stream:src/docs/pages/test.md
src/docs/templates/index.jade
dist/docs/test.html