diff --git a/app/models/communication/website/menu/item.rb b/app/models/communication/website/menu/item.rb index 347a429c1..b76850cad 100644 --- a/app/models/communication/website/menu/item.rb +++ b/app/models/communication/website/menu/item.rb @@ -143,10 +143,12 @@ def to_static_hash return nil if static_target.nil? hash = { 'title' => title, + 'slug' => title.parameterize, 'target' => static_target, 'kind' => kind, 'new_tab' => should_open_new_tab, - 'children' => children.ordered.map(&:to_static_hash).compact + 'children' => children.ordered.map(&:to_static_hash).compact, + 'descendants_targets' => descendants_targets, } if hugo.present? hash['path'] = hugo.path @@ -178,6 +180,18 @@ def siblings .where.not(id: id) end + def descendants_targets + children.collect(&:descendants_and_self_targets) + .flatten + .compact + .uniq + .sort + end + + def descendants_and_self_targets + [static_target] + children.collect(&:descendants_and_self_targets) + end + protected def hugo