Sha256: f809adf5fcaa6a0d0decb6a543c0f9dd79b4ca2261ee48c4e9f172526304e198
Contents?: true
Size: 964 Bytes
Versions: 2
Compression:
Stored size: 964 Bytes
Contents
# encoding: utf-8 module Nanoc3::Helpers # Provides support for breadcrumbs, which allow the user to go up in the # page hierarchy. module Breadcrumbs # Creates a breadcrumb trail leading from the current item to its parent, # to its parent’s parent, etc, until the root item is reached. This # function does not require that each intermediate item exist; for # example, if there is no `/foo/` item, breadcrumbs for a `/foo/bar/` item # will contain a `nil` element. # # @return [Array] The breadcrumbs, starting with the root item and ending # with the item itself def breadcrumbs_trail trail = [] current_identifier = @item.identifier loop do item = @items.find { |i| i.identifier == current_identifier } trail.unshift(item) break if current_identifier == '/' current_identifier = current_identifier.sub(/[^\/]+\/$/, '') end trail end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nanoc3-3.1.0b1 | lib/nanoc3/helpers/breadcrumbs.rb |
nanoc3-3.1.0a3 | lib/nanoc3/helpers/breadcrumbs.rb |