<%#
  Before updating a promotion slot please read the documentation.
  See: https://docs.publishing.service.gov.uk/apps/frontend/update-homepage-promotion-slots.html
%>
<section class="homepage-section">
  <div class="homepage-section__heading">
    <%= render "govuk_publishing_components/components/heading", {
      text: t("homepage.index.featured"),
      font_size: "m",
    } %>
  </div>

  <div class="govuk-grid-row">
    <% t("homepage.index.promotion_slots").each do | item | %>
      <div class="govuk-grid-column-one-third">
        <%= render "govuk_publishing_components/components/image_card", {
          href: item[:href],
          href_data_attributes: {
            track_category: "homepageClicked",
            track_action: "promoLink",
            track_label: item[:href],
            track_value: "1",
            track_dimension_index: "29",
            track_dimension: item[:title],
          },
          image_src: image_url(item[:image_src]),
          image_alt: "",
          image_loading: "lazy",
          heading_level: 3,
          heading_text: item[:title],
          description: item[:text],
          font_size: "m",
          sizes: "(max-width: 640px) 100vw, (max-width: 1020px) 33vw, 300px",
          srcset: item[:srcset],
        } %>
      </div>
    <% end %>
  </div>
</section>

<%#
  Before updating a promotion slot please read the documentation.
  See: https://docs.publishing.service.gov.uk/apps/frontend/update-homepage-promotion-slots.html
%>
<section class="homepage-section">
  <div class="homepage-section__heading">
    <%= render "govuk_publishing_components/components/heading", {
      text: t("homepage.index.featured"),
      font_size: "m",
    } %>
  </div>

  <div class="govuk-grid-row">
    <% t("homepage.index.promotion_slots").each do | item | %>
      <div class="govuk-grid-column-one-third">
        <%= render "govuk_publishing_components/components/image_card", {
          href: item[:href],
          href_data_attributes: {
            track_category: "homepageClicked",
            track_action: "promoLink",
            track_label: item[:href],
            track_value: "1",
            track_dimension_index: "29",
            track_dimension: item[:title],
          },
          image_src: image_url(item[:image_src]),
          image_alt: "",
          image_loading: "lazy",
          heading_level: 3,
          heading_text: item[:title],
          description: item[:text],
          font_size: "m",
          sizes: "(max-width: 640px) 100vw, (max-width: 1020px) 33vw, 300px",
          srcset: item.fetch(:srcset, {}).stringify_keys.transform_keys { |k| image_path(k) }.presence
        } %>
      </div>
    <% end %>
  </div>
</section>

Convert paths of srcset images to asset paths
Convert paths of srcset images to asset paths

Previously these weren't converted to rails asset paths and weren't
operational. Putting them through image_path resolves this.

The use of presence is to set the attribute to nil when there are no
srcset images and not display the attribute.
