Sha256: f337a57dcebc282e4583a849ec203c4e889dc5741ef8b831158e68ee6ed33b25

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

module GovukPublishingComponents
  module Presenters
    # @private
    class TaxonomySidebar
      def initialize(content_item)
        @content_item = ContentItem.new content_item
      end

      def sidebar
        {
          items: related_items,
          collections: collections,
        }
      end

    private

      def there_are_related_item_overrides?
        # TODO: We should check for any external links when we have "new"
        # external links being curated in Content Tagger
        @content_item.curated_taxonomy_sidebar_links.any?
      end

      def related_items
        related_items_factory.new(@content_item).related_items
      end

      def related_items_factory
        if there_are_related_item_overrides?
          CuratedTaxonomySidebarLinks
        else
          RummagerTaxonomySidebarLinks
        end
      end

      def collections
        links = @content_item.related_collections
        links.map do |link|
          {
            path: link["base_path"],
            text: link["title"]
          }
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
govuk_publishing_components-6.0.0 lib/govuk_publishing_components/presenters/taxonomy_sidebar.rb