2016-07-31 19:28:23 +02:00
|
|
|
module NavigationHelper
|
|
|
|
def nav_items
|
|
|
|
navigables.each do |item|
|
2016-10-31 13:48:39 +01:00
|
|
|
# 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)
|
|
|
|
|
2016-07-31 19:28:23 +02:00
|
|
|
yield item, is_active
|
|
|
|
end
|
|
|
|
end
|
2016-10-31 13:48:39 +01:00
|
|
|
|
|
|
|
def navigables
|
|
|
|
items.select { |i| i[:navigable] }.sort_by { |x| x[:order] || 10_000 }
|
|
|
|
end
|
2016-07-31 19:28:23 +02:00
|
|
|
end
|