Created
January 17, 2014 02:54
-
-
Save doowb/8467651 to your computer and use it in GitHub Desktop.
Generating assemble targets.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _ = require('lodash'); | |
module.exports = function(grunt) { | |
var config = grunt.file.readJSON('path/to/blog/config.json'); | |
grunt.initConfig({ | |
config: config, | |
assemble: { | |
options: { | |
assets: 'public/assets', | |
flatten: true | |
}, | |
// Blog Index | |
blogindex: { | |
options: { | |
pages: '<%= config.blogindex.index %>' | |
} | |
}, | |
} | |
}); | |
grunt.loadNpmTasks('assemble'); | |
grunt.registerTask('default', ['assemble']); | |
_.map(config.blogindex.blogs, function (blog) { | |
var target = { | |
options: { | |
flatten: false, | |
layout: blog.layout, | |
pages: { | |
'index': { | |
data: { name: blog.name, ... }, | |
content: blog.index | |
} | |
} | |
} | |
}; | |
var postBase = blog.name + '/posts/'; | |
_.map(blog.posts, function(post) { | |
target.options.pages[postBase + post.name] = { | |
content: post.content | |
}; | |
}); | |
grunt.config(['assemble', blog.name], target); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment