Sha256: a0199702877b3498f8d9de12fa41ad303c1f7e04043028ce15dc85b7889a47e7
Contents?: true
Size: 941 Bytes
Versions: 8
Compression:
Stored size: 941 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?, } 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
8 entries across 8 versions & 1 rubygems