我正在努力为我的Gulp流程添加一些简单的Markdown处理,但是我无法完成这些工作.我似乎错过了获取前端内容和确定应用哪个Nunjuck模板之间的步骤.
这是我的Gulp文件中的部分:
gulp.task('pages:md', function() {
gulp.src('./content/**/*.md')
.pipe(frontMatter({ // optional configuration
property: 'frontMatter', // property added to file object
remove: true // should we remove front-matter header?
}))
.pipe(marked({
// optional : marked options
}))
.pipe(nunjucks({
// ?? Feels like I need to specify which template applies based on the front matter "layout" property?
}))
.pipe(gulp.dest('build/'))
});
Run Code Online (Sandbox Code Playgroud)
markdown文件如下所示:
---
title: Title
layout: layout.html
nav_active: home
---
...markdown content...
Run Code Online (Sandbox Code Playgroud)
我觉得它正朝着正确的方向发展,但是能够直观地了解前端数据的去向,以及如何将它暴露给Nunjucks渲染,目前尚不清楚.有帮助吗?