This commit is contained in:
Lorin Werthen 2017-04-03 22:32:02 +02:00
parent 76d9894ad1
commit e44a6a3d35
No known key found for this signature in database
GPG key ID: F11FFC921E0E08E0
3 changed files with 6 additions and 12 deletions

View file

@ -14,9 +14,9 @@
<img id="inline-logo" src="<%= zeus_logo_url color: @zeus_logo_color %>" alt="" />
</a>
<div class="nav-menu nav-left">
<% nav_items do |item, active| %>
<a class="nav-item is-tab <%= 'is-active' if active %>" href="<%= item.path %>">
<%= item[:title] %>
<% navigables.each do |i| %>
<a class="nav-item is-tab <%= 'is-active' if child_of(i) %>" href="<%= i.path %>">
<%= i[:title] %>
</a>
<% end %>
</div>

View file

@ -2,15 +2,8 @@
# Helpers for navbar partial
module NavigationHelper
def nav_items
navigables.each do |item|
# Kind of hacky way to check if page is child of another page
root = %r{/.+?/}.match(item.path)[0]
is_active = @item_rep && @item_rep.path.start_with?(root)
yield item, is_active
end
def child_of(item)
item == @item || children_of(item).include?(@item)
end
# Returns every navigable item

View file

@ -3,6 +3,7 @@ include Nanoc::Helpers::Capturing
include Nanoc::Helpers::LinkTo
include Nanoc::Helpers::Rendering
include Nanoc::Helpers::Text
include Nanoc::Helpers::ChildParent
include EnvironmentHelper
include ArchiveHelper