open current category on root page

master
muflax 2012-05-15 00:03:48 +02:00
parent c2bf29249c
commit 43151827e2
6 changed files with 19 additions and 6 deletions

View File

@ -13,4 +13,4 @@ Feel free to comment or [contact][Contact] me directly. There is an [RSS feed][R
Latest post:
<%= render "content-embed", :item => @site.items_by_date.last %>
<%= render "content-embed", :item => @site.latest_article %>

View File

@ -11,4 +11,4 @@ Because death doesn't conquer itself, you know.
Latest entry:
<%= render "content-embed", :item => @site.items_by_date.last %>
<%= render "content-embed", :item => @site.latest_article %>

View File

@ -6,4 +6,4 @@ no_comments: true
muflax reads stuff and comments on it. Sometimes, quotes out of context.
<%= render "content-embed", :item => @site.items_by_date.last %>
<%= render "content-embed", :item => @site.latest_article %>

View File

@ -24,5 +24,5 @@ It's time for a [Bro][PhiloBro]dhisattva to step forward and [reblog][] Buddhist
Thus have I heard:
<%= render "content-embed", :item => @site.items_by_date.last %>
<%= render "content-embed", :item => @site.latest_article %>

View File

@ -4,9 +4,9 @@
<% @site.categories(false).each do |cat| %>
<li><%= cat.link true %></li>
<% if @item.category == cat %>
<% if @item.category == cat or (@item.root? and @site.latest_category? cat) %>
<ul>
<% @site.items_by_date(@item.category).reverse.each do |i| %>
<% @site.items_by_date(cat).reverse.each do |i| %>
<%= render 'list-item', :item => i, :episteme => false %>
<% end %>
</ul>

View File

@ -42,6 +42,10 @@ class Nanoc::Item
""
end
end
def root?
self.identifier == "/"
end
end
class Category
@ -132,6 +136,15 @@ class Nanoc::Site
def categories all=true
@categories.select{|c| c[:not_empty] or all}.map{|c| c[:cat]}
end
def latest_article
items_by_date.last
end
# is this category on the main site?
def latest_category? cat
latest_article.category == cat unless latest_article.nil?
end
end
def category name_or_cat