<% related_nav_helper = GovukPublishingComponents::Presenters::RelatedNavigationHelper.new(local_assigns) shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns) disable_ga4 ||= false ga4_type = local_assigns[:context] == :footer ? "contextual footer" : "related content" data = {} data[:module] = "gem-track-click" data[:module] << " ga4-link-tracker" unless disable_ga4 ga4_tracking_counts ||= OpenStruct.new(index_section_count: 0) ga4_tracking_counts.index_section_count += related_nav_helper.index_section_count add_gem_component_stylesheet("related-navigation") %> <% if related_nav_helper.related_navigation? %> <% random = SecureRandom.hex(4) %> <%= tag.div(class: "gem-c-related-navigation", data: data) do %> <% if local_assigns[:context] != :footer %> <% end %> <% section_index = 0 %> <% related_nav_helper.related_navigation.each do |section_title, links| %> <% next unless links.any? %> <% section_index += 1 %> <%= render 'govuk_publishing_components/components/related_navigation/section', related_nav_helper: related_nav_helper, shared_helper: shared_helper, section_title: section_title, links: links, section_index: section_index, section_count: ga4_tracking_counts.index_section_count, random: random, disable_ga4: disable_ga4, ga4_type: ga4_type %> <% end %> <% end %> <% end %>