Order of middleware
Been struggling with extending kerouac: for example if I want to add locals.posts variable (array of posts) into the /index.html page, i.e. the homepage, it turns out to be mighty difficult: seems that generating /index.html happens before blog posts are retrieved, or something to that effect.
What I have in the site.js is this:
site.content('content');
site.static('public');
site.plug(require('kerouac-sitemap')());
site.plug(require('kerouac-robotstxt')());
site.plug(require('kerouac-blog')('blog', { layout: 'blog' }));
site.plug(require('kerouac-blog-index')('blog', { layout: 'site/blog-index' }));
site.generate(function(err) {
if (err) {
console.error(err.message);
console.error(err.stack);
return;
}
});
For example, the blog posts don't have .post = true property in them until very late, I think at that point /index.html has been rendered already.
Seems like it should be changed how kerouac runs certain functions/middleware in the generate phase.
Maybe separate generate() and rendering ... if rendering comes after every page has been generated, there shouldn't be a problem.