cleaner
This commit is contained in:
parent
76d9894ad1
commit
e44a6a3d35
3 changed files with 6 additions and 12 deletions
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue