Middleman doesn't yet support multiple blogs, so on my portfolio, I needed a way to loop through my "work" items in a reliable way. I didn't want to have to mess with a bunch of code just when I was adding a new project to the mix. Thanks to Middleman's sitemap feature, and a little Googling, I figured out a way. In Haml:
- sitemap.resources.each do |page|
- if page.url =~ /^(\/work\/)/
=link_to page.data.title, page.urlBasically, this loops through every page in the sitemap and filters out everything that doesn't contain the string in the regex. The string I'm looking for here is "/work/". Edit accordingly, and remember that forward slashes (these guys: /) must be escaped with a backslash (one of these: ).