Gulp plugin to pipe vinyl file objects and transform them into static HTML pages
var maki = require"gulp-pagemaki";var path = require"path";gulptask'statics'return gulpsrc"./src/pages/**/*.html"pipemakitemplateDir: pathjoin__dirname "src" "layouts"pipegulpdest"./public";;
This takes a folder structure that looks like this:
And will take all of the
.html files in src/pages, run them them through
the pagemaki parser to find Yaml metadata similar to Jekyll, then use that
to find which layout to load from your layout directory that you passed in
the gulpfile above.
Once it finds the layout, it drops the content part of each file into the
<%= content %> tag in the layout and makes the rest of the variables available
to that layout as js vars.
When the parsing and compiling is done, it writes each file, in its preserved folder structure, to the public folder. Now you're building your static HTML files with gulp just like your sass, browserified scripts, etc.
---layout: defaulttitle: My Homepage---# Hello from my homepage
<%= page.title %><%= content %>
gulp statics runs...
My HomepageHello from my homepage