Middleman App, sort blog posts by month -


i'm using middlemanapp create blog. i'm trying output archive of blog posts sorted month , year display in sidebar. eg. april 2010, may 2010, june 2010, clickable links archive.

so far have code below output month in number form (eg. july being output 7) , need have list displayed month shown above.

<% blog.articles.group_by {|a| a.date.month }.each |month, articles| %>  <li><%= link_to month, blog_year_path(month) %> </a></li>  <% end %> 

can help, i'm not if middleman offers functionality, i'm not familiar ruby.

i couldn't find easy built-in way middleman either, following give nested list of years , months, relevant links:

<ul> <% blog.articles.group_by {|y| y.date.year }.each |year, articles| %>     <li>          <a href="<%= blog_year_path(year) %>">         <%= year %>     </a>     <ul>     <% articles.group_by {|a| a.date.month}.each |month, month_articles| %>     <li><%= link_to month_articles.first.date.strftime("%b"), blog_month_path(year, month) %></li>     <% end %>     </ul> <% end %>     </li> </ul> 

e.g.

  • 2013
    • august
    • july
    • june
    • ...

(i'm sure borrowed above this middleman template on github, if not found via github search "blog.articles.group_by month".)


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -