Skip to content

Instantly share code, notes, and snippets.

@devth
Created October 8, 2010 22:24
Show Gist options
  • Save devth/617670 to your computer and use it in GitHub Desktop.
Save devth/617670 to your computer and use it in GitHub Desktop.
def articles_list
articles = @items.select { |i| i.path.match(/reading_room\/.+/) unless i.path.nil? }
articles_by_category = {}
# organize by category
articles.each do |article|
articles_by_category[article[:category]] ||= []
articles_by_category[article[:category]].push article
end
# return sorted articles by sorted categories
articles_by_category.sort.map do |category, articles|
%{
<h1>#{category}</h1>
#{ articles.sort_by{|a| a[:title] }.map { |a| article_preview a }.join '' }
}
end.join ''
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment