I am trying to migrate my blog from Middleman 4. In my index.html.erb file I have code like this:
<% page_articles.each_with_index do |article, i| %>
<% if article.data.layout == 'post' %>
<%= partial "post", :locals => { :article => article} %>
<% elsif article.data.layout == 'micro' %>
<%= partial "micro", :locals => { :article => article} %>
<% end %>
<% end %>
This worked fine in Middleman 3 and I could use a different partial depending on the layout property defined in each post's front matter.
However, in Middleman 4 the layout
property is no longer visible in article.data.
All other variables are there. So far the only way to make this work is to declare frontmatter like this:
---
layout: post
l: post
title: "Foo"
date: 2012-10-22 15:14:01
categories: Bar
tags:
---
And use article.data.l
rather than article.data.layout
. This, however, requires that I rewrite all of the articles and seems redundant.
What is the correct way to render articles on the index page with different partials depending on the layout property?