diff --git a/content/css/_main.scss b/content/css/_main.scss index 6059b72..913017e 100644 --- a/content/css/_main.scss +++ b/content/css/_main.scss @@ -68,7 +68,14 @@ ol.posts { list-style-type: none; list-style-image: none; padding: 0; - margin: 0; + margin: 0 0 24px 0; + + li { + span.date { + width: 50px; + display: inline-block; + } + } } pre, .plaincode{ diff --git a/content/index.haml b/content/index.haml index 6d7ca7b..b95a31a 100644 --- a/content/index.haml +++ b/content/index.haml @@ -5,12 +5,20 @@ title: Home %h2 Ariejan's Blog .content_wrap.nobg %section#middle_content - #posts - - articles_by_year.each do |year, articles| - %h2= year + :markdown + Hi! Welcome to _ariejan.net_. Since 1999 this has been my digital home in one form or the other. I hope you find what you're looking for. - %ol.posts - - articles.each do |article| - %li - %span.date= get_short_date(article) - = link_to article[:title], article.path \ No newline at end of file + #posts + %h3 Recent blog posts + + - articles_by_year_for_two_columns.each do |column_articles| + .one_half + - column_articles.each do |year, articles| + + %h2= year + + %ol.posts + - articles.each do |article| + %li + %span.date= get_short_date(article) + = link_to article[:title], article.path \ No newline at end of file diff --git a/lib/helpers/post.rb b/lib/helpers/post.rb index 65b7ccb..efb3f82 100644 --- a/lib/helpers/post.rb +++ b/lib/helpers/post.rb @@ -1,13 +1,21 @@ module PostHelper - def articles_by_year + def articles_by_year(articles) hash = Hash.new { |h, k| h[k] = [] } - sorted_articles.inject(hash) do |output, article| + articles.inject(hash) do |output, article| year = attribute_to_time(article[:created_at]).year output[year] << article output end end + def articles_by_year_for_two_columns + half_mark = sorted_articles.size / 2 + half_one = sorted_articles[0..half_mark-1] + half_two = sorted_articles[half_mark..-1] + + [articles_by_year(half_one), articles_by_year(half_two)] + end + def get_short_date(post) attribute_to_time(post[:created_at]).strftime('%d %b') end