Module: Jekyll::Filters::Breadcrumbs

Defined in:
lib/jekyll/filters/breadcrumbs.rb

Instance Method Summary collapse

Instance Method Details

The breadcrumbs filter returns an Array of Jekyll::Documents that are linked recursively by the same field.

Parameters:

  • (Jekyll::Document)
  • (String)

Returns:

  • (Array)


12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/jekyll/filters/breadcrumbs.rb', line 12

def breadcrumbs(input, field)
  return unless input.respond_to? :[]

  crumbs = [ input ]
  prev   =   input

  while prev&.public_send(:[], field)
    crumbs << (prev = prev[field])
  end

  crumbs.reverse
end