-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
48 lines (42 loc) · 1.13 KB
/
gulpfile.js
File metadata and controls
48 lines (42 loc) · 1.13 KB
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
const { watch, src, dest, parallel, series } = require("gulp")
const asciidoctor = require("@asciidoctor/gulp-asciidoctor")
const grayMatter = require("gulp-gray-matter")
const tap = require("gulp-tap")
const rename = require("gulp-rename")
function convertAdoc () {
return src("notes/**/*.adoc")
.pipe(grayMatter())
.pipe(asciidoctor({
standalone: false
}))
.pipe(tap(function(file) {
file.contents = Buffer.concat([
new Buffer("---\nasciiDoctor: true\ntemplateEngineOverride: false\n---\n"),
file.contents
])
}))
.pipe(dest("notes"))
}
function extractFrontMatterFromAdoc () {
return src("notes/**/*.adoc")
.pipe(grayMatter())
.pipe(tap(function(file) {
file.contents = new Buffer(JSON.stringify(file.data))
}))
.pipe(rename(function(path) {
path.extname = ".11tydata.json";
}))
.pipe(dest("notes"))
}
function processAdoc (cb) {
parallel(
convertAdoc,
extractFrontMatterFromAdoc)(cb)
}
function watchAdoc () {
watch('notes/**/*.adoc', processAdoc)
};
exports.processAdoc = processAdoc;
exports.default = parallel(
processAdoc,
watchAdoc)