-
Notifications
You must be signed in to change notification settings - Fork 22
/
build-support.js
43 lines (38 loc) · 1.23 KB
/
build-support.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
module.exports = {
//
// helper to create front matter from a JS object.
//
createFrontMatter : function(options) {
var f = "---\n";
for (var k in options)
f += (k + ": " + options[k] + "\n");
f += "---\n";
return f;
},
//
// helper to create a timestamp for inclusion in yaml front matter.
//
timestamp : function() {
var d = new Date();
return d.getFullYear() + "-" + d.getMonth() + "-" + d.getDate() + " 12:00:00";
},
processMarkdownFile : function(grunt, inputDir, filename, template, base, outputDir) {
/*var s = grunt.file.read(inputDir + "/" + filename),
o = this.createFrontMatter({
layout:template,
date:this.timestamp(),
base:base
});
grunt.file.write(outputDir + "/" + filename, o + s);*/
this.createMarkdownFile(grunt, inputDir, filename, {
layout:template,
date:this.timestamp(),
base:base
}, outputDir);
},
createMarkdownFile:function(grunt, inputDir, filename, options, outputDir) {
var s = grunt.file.read(inputDir + "/" + filename),
o = this.createFrontMatter(options);
grunt.file.write(outputDir + "/" + filename, o + s);
}
};