-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathgulpfile.js
35 lines (30 loc) · 931 Bytes
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var swig = require('swig');
var path = require('path');
var through = require('through2');
var runSequence = require('run-sequence');
gulp.task('zip', function() {
return gulp.src('app/**/*')
.pipe($.zip('app.zip'))
.pipe(gulp.dest('.'));
});
function applyTemplate(templateFile) {
var tpl = swig.compileFile(path.join(__dirname, templateFile));
return through.obj(function(file, enc, cb) {
var data = {
pagetitle: file.path.replace(/^.*\/(.*?)\.html$/, '$1'),
content: file.contents.toString()
};
file.contents = new Buffer.from(tpl(data), 'utf8');
this.push(file);
cb();
});
};
gulp.task('markdown', function() {
return gulp.src('./*.md')
.pipe($.markdown())
.pipe(applyTemplate('template.html'))
.pipe(gulp.dest('app'));
});
gulp.task('build', gulp.series('markdown', 'zip', done => done()));