This commit is contained in:
Jonathan Rudenberg 2012-08-22 11:15:21 -04:00
parent decb9d8430
commit c0ca040c2c
19 changed files with 366 additions and 237 deletions

14
lib/nav.rb Normal file
View file

@ -0,0 +1,14 @@
include Nanoc::Helpers::LinkTo
def nav_link_with_active(text, target, attributes = {})
path = target.is_a?(String) ? target : target.path
rep_path = @item_rep.path
active = if path == '/'
path == rep_path
else
/^#{path}/ =~ rep_path
end
"<li #{'class="active"' if active}>" + link_to(text, target, attributes) + "</li>"
end