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="" />
|
<img id="inline-logo" src="<%= zeus_logo_url color: @zeus_logo_color %>" alt="" />
|
||||||
</a>
|
</a>
|
||||||
<div class="nav-menu nav-left">
|
<div class="nav-menu nav-left">
|
||||||
<% nav_items do |item, active| %>
|
<% navigables.each do |i| %>
|
||||||
<a class="nav-item is-tab <%= 'is-active' if active %>" href="<%= item.path %>">
|
<a class="nav-item is-tab <%= 'is-active' if child_of(i) %>" href="<%= i.path %>">
|
||||||
<%= item[:title] %>
|
<%= i[:title] %>
|
||||||
</a>
|
</a>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,15 +2,8 @@
|
||||||
|
|
||||||
# Helpers for navbar partial
|
# Helpers for navbar partial
|
||||||
module NavigationHelper
|
module NavigationHelper
|
||||||
def nav_items
|
def child_of(item)
|
||||||
navigables.each do |item|
|
item == @item || children_of(item).include?(@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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns every navigable item
|
# Returns every navigable item
|
||||||
|
|
|
@ -3,6 +3,7 @@ include Nanoc::Helpers::Capturing
|
||||||
include Nanoc::Helpers::LinkTo
|
include Nanoc::Helpers::LinkTo
|
||||||
include Nanoc::Helpers::Rendering
|
include Nanoc::Helpers::Rendering
|
||||||
include Nanoc::Helpers::Text
|
include Nanoc::Helpers::Text
|
||||||
|
include Nanoc::Helpers::ChildParent
|
||||||
|
|
||||||
include EnvironmentHelper
|
include EnvironmentHelper
|
||||||
include ArchiveHelper
|
include ArchiveHelper
|
||||||
|
|
Loading…
Reference in a new issue