Fine tune the frontpage
This commit is contained in:
parent
f939698c61
commit
0e5510a3c1
|
@ -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{
|
||||
|
|
|
@ -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
|
||||
#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
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user