forked from valueflows/valueflo.ws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
66 lines (57 loc) · 1.63 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var gulp = require('gulp')
var Swig = require('swig').Swig
var data = require('gulp-data')
var markdown = require('markdown-it')()
var map = require('through2-map')
var buffer = require('vinyl-buffer')
var replaceExt = require('replace-ext')
var assign = require('object-assign')
var prettify = require('gulp-prettify')
function docs () {
var swig = new Swig()
var renderDoc = swig.compileFile('./templates/doc.swig')
return gulp.src('./docs/*.md')
.pipe(buffer())
.pipe(data(getData))
.pipe(map.obj(function toMarkdown (file) {
var input = String(file.contents)
var output = markdown.render(input)
file.contents = Buffer(output)
file.path = replaceExt(file.path, '.html')
return file
}))
.pipe(map.obj(function toTemplate (file) {
var input = String(file.contents)
var locals = assign({}, file.data, { contents: input })
var output = renderDoc(locals)
file.contents = Buffer(output)
return file
}))
.pipe(prettify())
.pipe(gulp.dest('./.build'))
function getData (file) {
return require(file.path + '.json')
}
}
function ns () {
gulp.src('./ns/*.jsonld')
.pipe(gulp.dest('./.build/ns'))
}
function css () {
gulp.src('./css/*.css')
.pipe(gulp.dest('./.build/css'))
}
function server () {
gulp.src(['./server.js', './package.json'])
.pipe(gulp.dest('./.build'))
}
function assets () {
gulp.src('./assets/**/*')
.pipe(gulp.dest('./.build'))
}
gulp.task('docs', docs)
gulp.task('ns', ns)
gulp.task('css', css)
gulp.task('assets', assets)
gulp.task('server', server)
gulp.task('build', ['docs', 'ns', 'css', 'assets', 'server'])