Page navigation‹ Back
By default, Ornament doesn't come with any out-of-the-box sidebar navigation styling.
This page instead will act as a cookbook of receipes for building second-level page navigation.
Managing tree levels
Simple-navigation makes it really easy to have one single tree, which is what Koi has by default, and allow rendering different parts of that tree.
For example, your header might be using
level: 1..3 to render three levels of navigation, but on your internal page you want only
Understand that navigation will only render if the current page path is in the navigation tree.
Conditionally showing sidebar if needed
Sometimes you have a general page show view, eg.
Sometimes you need this view to show a sidebar when there are links available, and sometimes you need it to not show anything if the page is standalone.
The easiest way I've found to do this is to use a temporary yield.
<%# This is our temporary navigation yield %> <% content_for :page_navigation do %> <%= koi_render_navigation "page_navigation", "header_navgiation" %> <% end %> <%# This navigation yield will only render if navigation was present %> <% if content_for? :page_navigation %> <% content_for :sidebar %> <div class="page--navigation"> <%= yield :navigation %> </div> <% end %> <% end %>