Navigation Helper - aadlani/nanoc-toolbox GitHub Wiki
Helper for generating navigation for your pages, like navigation menu, breadcrumbs or table of contents.
http://rubydoc.info/github/aadlani/nanoc-toolbox/Nanoc/Toolbox/Helpers/Navigation
In the folder lib/helpers_.rb
add the Helper inclusion as following:
# Helpers of the nanoc-toolbox
include Nanoc::Toolbox::Helpers::Navigation
Generate a Breadcrumb for a given item. The breadcrumbs, is starting with the root item and ending with the item itself.
<% unless @item.identifier == '/' %>
<%= breadcrumb_for(@item.identifier, collection_class: "navbar-text breadcrumb", separator: content_tag(:span, "»", :class => "divider")) %>
<% end %>
<ul class="navbar-text breadcrumb">
<li><a href="./">Home</a><span class="divider">»</span></li>
<li><a href="resume.html">Curriculum Vitae</a><span class="divider">»</span></li>
</ul>
Generate a Table of Content for a given item. The toc will be generated from the item content. By default this method is expecting nested div with "section" class. The parsing is done with Nokogiri through XPath.
<%= toc_for(@item, :collection_class => "nav nav-list toc") %>
<ol class="nav nav-list toc">
<li><a href="#flexible-working-hours">Flexible working hours</a></li>
<li><a href="#keep-the-team-fresh">Keep the team fresh</a></li>
<li><a href="#good-hardware-and-furniture">Good hardware and furniture.</a></li>
<li><a href="#environment-freedom">Environment freedom</a></li>
<li><a href="#courtesy">Courtesy</a></li>
<li><a href="#quiet-working-condition">Quiet working condition</a></li>
<li><a href="#decent-salary">Decent Salary</a></li>
<li><a href="#conclusion">Conclusion</a></li>
<li><a href="#reading-list">Reading list</a>
<ol class="nav nav-list toc">
<li><a href="#articles">Articles</a></li>
<li><a href="#books">Books</a></li>
</ol>
</li>
</ol>
If your structure is completely flat and follows the flow of headings h1 to h6, then you could use the filter add_sections
to create this stucture for you, by adding this line in compile block of your Rules:
filter :add_sections