Skip to content

Instantly share code, notes, and snippets.

@doowb
Created January 17, 2014 02:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doowb/8467651 to your computer and use it in GitHub Desktop.
Save doowb/8467651 to your computer and use it in GitHub Desktop.
Generating assemble targets.
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