Class: GovukNavigationHelpers::NavigationHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/govuk_navigation_helpers.rb

Instance Method Summary collapse

Constructor Details

#initialize(content_item) ⇒ NavigationHelper

Returns a new instance of NavigationHelper.



20
21
22
# File 'lib/govuk_navigation_helpers.rb', line 20

def initialize(content_item)
  @content_item = content_item
end

Instance Method Details

Generate a breadcrumb trail

Returns:

  • (Hash)

    Payload for the GOV.UK breadcrumbs component

See Also:



28
29
30
# File 'lib/govuk_navigation_helpers.rb', line 28

def breadcrumbs
  Breadcrumbs.new(content_item).breadcrumbs
end

Generate a related items payload

Returns:

  • (Hash)

    Payload for the GOV.UK Component

See Also:



53
54
55
# File 'lib/govuk_navigation_helpers.rb', line 53

def related_items
  RelatedItems.new(content_item).related_items
end

Generate a payload containing related navigation sidebar data. Intended for use with the related navigation component

Returns:

  • (Hash)

    Payload for the GOV.UK related navigation component

See Also:



62
63
64
# File 'lib/govuk_navigation_helpers.rb', line 62

def related_navigation_sidebar
  RelatedNavigationSidebar.new(content_item).related_navigation_sidebar
end

#taxon_breadcrumbsHash

Generate a breadcrumb trail for a taxon, using the taxon_parent link field

Returns:

  • (Hash)

    Payload for the GOV.UK breadcrumbs component

See Also:



36
37
38
# File 'lib/govuk_navigation_helpers.rb', line 36

def taxon_breadcrumbs
  TaxonBreadcrumbs.new(content_item).breadcrumbs
end

#taxonomy_sidebarHash

Generate a payload containing taxon sidebar data. Intended for use with the related items component.

Returns:

  • (Hash)

    Payload for the GOV.UK related items component

See Also:



45
46
47
# File 'lib/govuk_navigation_helpers.rb', line 45

def taxonomy_sidebar
  TaxonomySidebar.new(content_item).sidebar
end