class GovukNavigationHelpers::CuratedTaxonomySidebarLinks
Public Class Methods
new(content_item)
click to toggle source
# File lib/govuk_navigation_helpers/curated_taxonomy_sidebar_links.rb, line 5 def initialize(content_item) @content_item = content_item end
Public Instance Methods
Private Instance Methods
elsewhere_on_gov_uk_links()
click to toggle source
# File lib/govuk_navigation_helpers/curated_taxonomy_sidebar_links.rb, line 29 def elsewhere_on_gov_uk_links elsewhere_items = related_content_elsewhere_on_govuk return [] if elsewhere_items.empty? [ { title: 'Elsewhere on GOV.UK', related_content: format_for_sidebar(elsewhere_items), }, ] end
elsewhere_on_the_web_links()
click to toggle source
# File lib/govuk_navigation_helpers/curated_taxonomy_sidebar_links.rb, line 41 def elsewhere_on_the_web_links return [] if @content_item.external_links.empty? external_links = @content_item.external_links.map do |link| { title: link['title'], link: link['url'], } end [ { title: 'Elsewhere on the web', related_content: external_links, }, ] end
filter_items_by_taxon(items, taxon)
click to toggle source
# File lib/govuk_navigation_helpers/curated_taxonomy_sidebar_links.rb, line 79 def filter_items_by_taxon(items, taxon) items.select do |item| item.parent_taxons.include?(taxon) end end
taxon_links()
click to toggle source
# File lib/govuk_navigation_helpers/curated_taxonomy_sidebar_links.rb, line 18 def taxon_links @content_item.parent_taxons.map do |taxon| { title: taxon.title, url: taxon.base_path, description: taxon.description, related_content: format_for_sidebar(related_content_by_taxon[taxon]), } end end
undisplayed_items(all_items, displayed_items)
click to toggle source
# File lib/govuk_navigation_helpers/curated_taxonomy_sidebar_links.rb, line 85 def undisplayed_items(all_items, displayed_items) all_items - displayed_items end