Sha256: 28035837d4dedff1650e2b104f3aa64ed2c6e328ec99ec415cbbff00f48e6903
Contents?: true
Size: 974 Bytes
Versions: 251
Compression:
Stored size: 974 Bytes
Contents
module GovukPublishingComponents module Presenters # @private class ContentBreadcrumbsBasedOnTaxons def initialize(content_item) @content_item = ContentItem.new(content_item) end def breadcrumbs ordered_parents = all_parents.map.with_index do |parent, index| { title: parent.title, url: parent.base_path, is_page_parent: index.zero? } end ordered_parents << { title: "Home", url: "/", is_page_parent: ordered_parents.empty? } { breadcrumbs: ordered_parents.reverse } end private attr_reader :content_item def all_parents parents = [] direct_parent = content_item.parent_taxon while direct_parent parents << direct_parent direct_parent = direct_parent.parent_taxon end parents end end end end
Version data entries
251 entries across 251 versions & 1 rubygems