diff options
author | Connor Shea <connor.james.shea@gmail.com> | 2016-10-27 07:51:09 +0300 |
---|---|---|
committer | Connor Shea <connor.james.shea@gmail.com> | 2016-10-27 07:51:09 +0300 |
commit | 280cdc29c34beece0dadb41a462baf2b74c29789 (patch) | |
tree | 0d5695b0dd56b6ea314f3319d8a7797b4d7532d4 /lib | |
parent | bf1c63a1b46e1cacb0c27e4946da40917bf82926 (diff) |
Working breadcrumbs!
Diffstat (limited to 'lib')
-rw-r--r-- | lib/helpers/child_parent_better.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/helpers/child_parent_better.rb b/lib/helpers/child_parent_better.rb index 8f8945cd..0a4ed86e 100644 --- a/lib/helpers/child_parent_better.rb +++ b/lib/helpers/child_parent_better.rb @@ -1,5 +1,21 @@ module Nanoc::Helpers module ChildParentBetter + def parent_path_array(item) + parent_array = Array.new + current_item = item + until (parent_path(current_item).nil?) do + if (parent_array.length == 0) + parent = parent_path(item) + parent_array.push(parent) if parent + else + parent = parent_path(parent_array.last) + current_item = parent_array.last + parent_array.push(parent) if parent + end + end + parent_array + end + def parent_path(item) parent = get_nearest_parent(item.identifier.to_s) parent @@ -11,7 +27,7 @@ module Nanoc::Helpers return elsif item_identifier.to_s.end_with?('README.md') parent_dir = item_identifier.sub(/[^\/]+$/, '').chop - get_nearest_parent(parent_dir) + return get_nearest_parent(parent_dir) else parent_dir = item_identifier.sub(/[^\/]+$/, '').chop parent = @items[parent_dir + '/README.*'] |