-
Notifications
You must be signed in to change notification settings - Fork 31
/
Gruntfile.js
57 lines (45 loc) · 1.47 KB
/
Gruntfile.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
var jqueryContent = require( "grunt-jquery-content" ),
taxonomies = require( "./taxonomies" );
module.exports = function( grunt ) {
grunt.loadNpmTasks( "grunt-jquery-content" );
grunt.initConfig({
"build-posts": {
post: "minutes/**",
page: "pages/**"
},
"build-resources": {
all: "resources/**"
},
wordpress: (function() {
var config = require( "./config" );
config.dir = "dist/wordpress";
return config;
})()
});
grunt.registerTask( "build-categories", function() {
grunt.file.write(
grunt.config( "wordpress.dir" ) + "/taxonomies.json",
JSON.stringify( taxonomies )
);
});
jqueryContent.postPreprocessors.post = (function() {
var teamNames = {};
taxonomies.category.forEach(function( category ) {
teamNames[ category.slug ] = category.name;
});
return function( post, postPath, callback ) {
var categorySlug = postPath.replace( /^.+?.+\/(.+)\/(.+)\.\w+$/, "$1" ),
postDateSlug = postPath.replace( /^.+?.+\/(.+)\/(.+)\.\w+$/, "$2" ),
postDate = new Date( postDateSlug + " 12:00:00"),
// Slice off the "DAY " from the date string
postDateString = postDate.toDateString().slice( 4 ),
teamName = teamNames[ categorySlug ];
post.title = teamName + " Meeting - " + postDateString;
post.date = postDate;
post.termSlugs = { "category": [ categorySlug ] };
post.fileName = postDateSlug + "-" + categorySlug + ".html";
callback( null, post );
};
})();
grunt.registerTask( "build", [ "build-posts", "build-categories", "build-resources" ] );
};