Sorting siblings by frontmatter

Hi Guys,
I’m more a PHP Developer but inherited a small middleman project. Everything works pretty well and I’ve managed to add a few changes to the templates without too much fuss.

However one thing keeps popping up. I have a pretty straightforward second level navigation that just lists the siblings of the current page with links:

`


    <% current_page.siblings.each do |resource| %>
  • <%= link_to resource.data.title, resource %>
  • <% end %>
` Now I need to change the order of these pages. My thinking was to just add a custom front matter to all the pages and then sort by that.

`


    <% current_page.siblings.order_by(:weight).each do |resource| %>
  • <%= link_to resource.data.title, resource %>
  • <% end %>
`

However this errors out and I’m kinda stuck here. Most solutions I found online seem overly complicated to me. Is there some simple way of solving this issue?

The solution you have found looks like the way to go. Would you post your error?

Best,
Robert

I never seen an order_by method in ruby actually. There is an order method in Active Record but it is RoR specific, @mfkffm is looking for sort_by probably.