<%- 
  
  attachment = @node.attachments.limit(1)[0]

  article_parts = parse_article_html(attachment&.body)

  content_for :title, @node.page_title.blank? ? article_parts[:title] : @node.page_title
  content_for :meta_description, @node.page_description.blank? ? article_parts[:description] : @node.page_description
%>

<article class="link__container">

  <div class="link">

    <%= link_to svg('ico-close'), @node.parent.url, class: 'link__close' %>

    <% @node.attachments.limit(1).each do |attachment| %>
      <% asset = attachment.asset %>
      
      <%= tag.figure class: 'link__image' do %>
        <%= image_tag rails_storage_proxy_url(asset.file.variant(resize_to_fill: [334,456])),
                          alt: asset.title,
                          srcset: "
                            #{rails_storage_proxy_url(asset.file.variant(resize_to_fill: [668,913]))} 668w,
                            #{rails_storage_proxy_url(asset.file.variant(resize_to_fill: [1002,1369]))} 1002w
                          ",
                          sizes: "",
                          class: 'fade-in' if asset&.file&.image? %>
      <% end %>
    
      <div class="link__body-container">
        <div class="link__body">
          <%= article_parts[:html]&.html_safe %>        
        </div>

        <%= tag.div class: "link__learn-more" do %>
          <%= article_parts[:link].html_safe %>
        <% end if article_parts[:link] %>
      </div>

      <div class="link__branding">
        <%= svg 'ikea-foundation-week' %>
      </div>


    <% end %>

  </div>

  <ul class="link__ctas">
    <li><%= link_to t('spot_another_link'), @node.parent.url, class: 'button__base' %></li>
    <li>
      <button type="button" class="button__base button__base-light" data-share-title="<%= yield(:title) %>" data-share-text="<%= strip_tags(t('can_you_spot_the_link')) %>">
        <%= t 'challange_a_friend' %>
      </button>
    </li>
  </ul>

  

</article>