Sha256: e421a56911003fb6d322f65eb46e8a7cb52962871e06b5c903705d0853dc411a
Contents?: true
Size: 914 Bytes
Versions: 13
Compression:
Stored size: 914 Bytes
Contents
module Nanoc::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 = [] idx_start = 0 loop do idx = @item.identifier.to_s.index('/', idx_start) break if idx.nil? idx_start = idx + 1 identifier = @item.identifier.to_s[0..idx] trail << @items[identifier] end trail end end end
Version data entries
13 entries across 13 versions & 1 rubygems