Sha256: 868acd92360f512838ae9aedb79b4461258ad39cb504a916dd24043404aaf3a0

Contents?: true

Size: 1.09 KB

Versions: 35

Compression:

Stored size: 1.09 KB

Contents

module GovukPublishingComponents
  module Presenters
    class TaxonomyNavigation
      RELATED_SECTIONS = %w(
        topical_events
        world_locations
        statistical_data_sets
      ).freeze

      def initialize(content_item)
        @content_item = ContentItem.new content_item
        @related_navigation = RelatedNavigationHelper.new(content_item)
      end

      def sidebar
        {
          items: related_items,
          collections: collections,
        }.merge(related_navigation_links)
      end

    private

      def related_navigation_links
        {}.tap do |hash|
          @related_navigation.related_navigation.each do |key, items|
            hash[key.to_sym] = items if RELATED_SECTIONS.include?(key)
          end
        end
      end

      def related_items
        CuratedTaxonomySidebarLinks.new(@content_item).related_items
      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

35 entries across 35 versions & 1 rubygems

Version Path
govuk_publishing_components-12.20.0 lib/govuk_publishing_components/presenters/taxonomy_navigation.rb
govuk_publishing_components-12.19.0 lib/govuk_publishing_components/presenters/taxonomy_navigation.rb
govuk_publishing_components-12.18.0 lib/govuk_publishing_components/presenters/taxonomy_navigation.rb
govuk_publishing_components-12.17.0 lib/govuk_publishing_components/presenters/taxonomy_navigation.rb
govuk_publishing_components-12.16.0 lib/govuk_publishing_components/presenters/taxonomy_navigation.rb
govuk_publishing_components-12.15.0 lib/govuk_publishing_components/presenters/taxonomy_navigation.rb
govuk_publishing_components-12.14.1 lib/govuk_publishing_components/presenters/taxonomy_navigation.rb
govuk_publishing_components-12.14.0 lib/govuk_publishing_components/presenters/taxonomy_navigation.rb
govuk_publishing_components-12.13.0 lib/govuk_publishing_components/presenters/taxonomy_navigation.rb
govuk_publishing_components-12.12.1 lib/govuk_publishing_components/presenters/taxonomy_navigation.rb
govuk_publishing_components-12.12.0 lib/govuk_publishing_components/presenters/taxonomy_navigation.rb
govuk_publishing_components-12.11.0 lib/govuk_publishing_components/presenters/taxonomy_navigation.rb
govuk_publishing_components-12.10.0 lib/govuk_publishing_components/presenters/taxonomy_navigation.rb
govuk_publishing_components-12.9.1 lib/govuk_publishing_components/presenters/taxonomy_navigation.rb
govuk_publishing_components-12.9.0 lib/govuk_publishing_components/presenters/taxonomy_navigation.rb
govuk_publishing_components-12.8.0 lib/govuk_publishing_components/presenters/taxonomy_navigation.rb
govuk_publishing_components-12.7.1 lib/govuk_publishing_components/presenters/taxonomy_navigation.rb
govuk_publishing_components-12.7.0 lib/govuk_publishing_components/presenters/taxonomy_navigation.rb
govuk_publishing_components-12.6.0 lib/govuk_publishing_components/presenters/taxonomy_navigation.rb
govuk_publishing_components-12.5.0 lib/govuk_publishing_components/presenters/taxonomy_navigation.rb