Reputation: 492
currently i am not able to generate two different collections of pages with assemble. On the one hand i want to generate my pages, which are displayed in the main navigation - On the other side i want to generate my blog posts, with categories and tags - how can i solve this problem?
Thanks in advance.
My grunt configuration looks like below
assemble: {
options: {
sitename: '<%= site.variables.sitename %>',
plugins: ['permalinks'],
assets: '<%= site.paths.src %>/assets',
partials: ['<%= site.paths.src %>/partials/*.hbs'],
helpers: ['<%= site.paths.src %>/helpers/helper-*.js'],
layout: 'default.hbs',
layoutdir: '<%= site.paths.src %>/layouts',
data: ['<%= site.paths.src %>/data/*.{json,yml}'],
collections: [{
name: 'post',
sortby: 'posted',
sortorder: 'descending'
}]
},
posts: {
files: [{
cwd: '<%= site.paths.src %>/content/',
dest: '<%= site.paths.dist %>',
expand: true,
src: ['**/*.{md,hbs}', '!_pages/**/*.{md,hbs}']
}, {
cwd: '<%= site.paths.src %>/content/_pages/',
dest: '<%= site.paths.dist %>',
expand: true,
src: '**/*.{md,hbs}'
}]
}
},
Upvotes: 1
Views: 70
Reputation: 3372
In v0.4.x the collections specify the types of collections you want to generate from the pages going through and their front-matter. You'll have to add front-matter to your posts
like:
---
posts:
- true
posted: 10-SEP-2014
---
However, the collection sorting isn't smart enough to know how to sort dates property. You might be able to add an actual date object as posted
or just make it the order you want.
Then to use the posts
collection, you could do {{#each this.posts}}
in handlebars. That would give you all the pages that have posts
defined in the front-matter. There might be some other things that need to be added in the templates, but I'm not thinking of them off the top of my head.
If you have a repo I can take a look at, it might be easier to help out.
Upvotes: 1