Hi!
I’m currently migrating a blog from Refinery-blog to middleman-blog
. Exporting the data to middleman from refinery and I want to create an index page for each category. Currently category is added as a frontmatter in each blog post article, like so:
---
category: Salud
---
What I want is /category/salud.html
to list the blog posts that belong to this category. Apparently middleman-blog
doesn’t have this feature built-in (categories index - please let me know if it’s possible outside the box). I tried to use the dynamic pages (the proxy
method) to generate the pages:
blog_categories.each do |name, articles|
proxy "/categories/#{name}.html", "category.html", :locals => { :articles => articles }
end
blog_categories
is custom method defined in a helper
, and it basically builds a list of categories based off blog.articles
and filters the corresponding articles for each cat, adding them to a Hash of cat => list of articles
. It works great if called from a template, but fails on config.rb
because blog
is undefined at this moment.
I’m a bit lost on how to accomplish this. Any hints would be much appreciated!
Thanks.