General functionality "yearly archive"
This commit is contained in:
parent
f67285f37c
commit
4c872a7be8
2 changed files with 23 additions and 18 deletions
|
|
@ -2,22 +2,5 @@ require 'ostruct'
|
|||
|
||||
def generate_archive_pages()
|
||||
articles = items.select { |i| i[:kind] == 'article' }
|
||||
yearmap = articles.group_by { |item| item[:created_at].year }
|
||||
yearmap.keys.each { |year|
|
||||
# Simplified assumption: At least one blog post each year
|
||||
linkprev = if (year>yearmap.keys.min)
|
||||
", :linkprev => OpenStruct.new(:title => #{year-1}, :link => '/archives/articles/#{year-1}/')"
|
||||
else
|
||||
""
|
||||
end
|
||||
linknext = if (year<yearmap.keys.max)
|
||||
", :linknext => OpenStruct.new(:title => #{year+1}, :link => '/archives/articles/#{year+1}/')"
|
||||
else
|
||||
""
|
||||
end
|
||||
@items << Nanoc::Item.new(
|
||||
"<%= render 'article_archive', :year => #{year} #{linkprev} #{linknext} %>",
|
||||
{ :title => "Blogarchiv #{year}", :kind => "fullpage" },
|
||||
"/archives/articles/#{year}/")
|
||||
}
|
||||
generate_yearly_archive(articles, '/archives/articles', 'Blogarchiv')
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue