This repository has been archived by the owner on Nov 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
77 lines (65 loc) · 1.79 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
67
68
69
70
71
72
73
74
75
76
77
"use strict";
var gulp = require("gulp");
var $ = require("gulp-load-plugins")();
$.nunjucksRender.nunjucks.configure({watch: false});
var configFile = "etc/settings.json";
var config = require("./lib/config").create(configFile);
(function(){
var del = require("del");
gulp.task("clean", () => {
return del([config.allFilesInDest]);
});
})();
(function(){
var browserSync = require("browser-sync");
gulp.task("serve", () => {
browserSync({
proxy: "local.mozilla.jp",
open: false
});
});
})();
gulp.task("lint", function() {
return gulp.src(configFile)
.pipe($.jsonlint())
.pipe($.jsonlint.reporter());
});
(function(){
var transform = require("./lib/transformer").transform;
var eachAsync = require("each-async");
var path = require("path");
gulp.task("transform", callback => {
var markdown = config.markdown;
var data = transform(markdown, config.title, config.ids);
gulp.src("templates/index.html")
.pipe($.nunjucksRender({
title: data.title,
categories: data.categories
}))
.pipe($.size({showFiles: true}))
.pipe(gulp.dest(config.dest));
eachAsync(data.categories, function(item, index, next) {
gulp.src("templates/category.html")
.pipe($.nunjucksRender({
title: data.title,
categories: data.categories,
currentIndex: index,
currentCategory: item
}))
.pipe($.rename({
dirname: item.id,
basename: "index"
}))
.pipe($.size({showFiles: true}))
.pipe(gulp.dest(config.dest))
.on("end", next);
}, callback);
});
})();
(function(){
var runner = require("run-sequence");
gulp.task("build", () => {
runner("clean", "transform");
});
})();
gulp.task("default", ["build"]);