Article archive
This commit is contained in:
parent
29a963733d
commit
38786d5e3c
4 changed files with 42 additions and 2 deletions
3
Rules
3
Rules
|
|
@ -1,8 +1,7 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
preprocess do
|
||||
#generate_archive_pages
|
||||
#generate_tag_pages
|
||||
generate_archive_pages
|
||||
generate_twitter_archive_pages
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
ErrorDocument 404 /404/index.html
|
||||
|
||||
RedirectMatch 301 ^/archives/articles/$ /archives/articles/<%= latest_articles(1)[0][:created_at].year %>/
|
||||
RedirectMatch 301 ^/archives/twitter/$ /archives/twitter/<%= twitter_grouped_by_month.keys.sort.last %>/
|
||||
|
||||
|
|
|
|||
11
layouts/article_archive.erb
Normal file
11
layouts/article_archive.erb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<%= render 'pager', :linkprev => @linkprev, :linknext => @linknext %>
|
||||
<div class="row">
|
||||
<% latest_articles.select { |a| a[:created_at].year == @year }.each do |item| %>
|
||||
<div class="span8">
|
||||
<%= render 'article_intro', :article => item, :extended => true %>
|
||||
<p>
|
||||
<a itemprop="blogPost" href="<%= item.path() %>">Zum Artikel</a>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= render 'pager', :linkprev => @linkprev, :linknext => @linknext %>
|
||||
29
lib/articlearchive.rb
Normal file
29
lib/articlearchive.rb
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
require 'ostruct'
|
||||
|
||||
def generate_archive_pages()
|
||||
# articles = items.select { |i| i[:kind] == 'article' }.
|
||||
# sort { |a,b| b[:created_at] <=> a[:created_at] }
|
||||
# articles = sorted_articles
|
||||
articles = items.select { |i| i[:kind] == 'article' }
|
||||
yearmap = articles.group_by { |item| item[:created_at].year }
|
||||
# yearmap.keys.sort.each { |year|
|
||||
# puts "#{year} --> #{yearmap[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}/")
|
||||
}
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue