{% load wagtailcore_tags wagtailimages_tags wagtailembeds_tags wagtailsettings_tags core_tags gem_tags molo_forms_tags %}
{% get_settings %}

{% if articles %}
  <ul class="teaser-stacklist">
  {% for article in articles|slice:":1" %}
    <li class="teaser-stacklist__item">
      {% if article.homepage_media %}
        {% for block in article.homepage_media %}
          {% with block.value as media %}
            {% if block.value.youtube_link %}
              <div class="teaser-stacklist__iframe">
                {% embed media.youtube_link %}
              </div>
            {% endif %}
          {% endwith %}
        {% endfor %}
      {% else %}
        {% if article.get_effective_image %}
        <div class="teaser-stacklist__images">
              {% image article.get_effective_image width-1080 format-jpeg as teaser_thumbnail %}
              <img alt="{{ article.title }}" src="{{ teaser_thumbnail.url }}" class="teaser-stacklist__thumbnail" />
          </div>
        {% endif %}
      {% endif %}

      <div class="teaser-stacklist__container">
        <div class="teaser-stacklist__main">
          <h1 class="teaser-stacklist__title-secondary">
            <a href="{% pageurl article %}" class="promoted-article-list__anchor">{{ article.title}}</a>
          </h1>
          {% if article.subtitle %}
            <h4 class="teaser-stacklist__subtitle">{{ article.subtitle }}</h4>
          {% endif %}

            {% for block in article.body %}
              {% if not block.block_type == 'media' %}
                <div class="teaser-stacklist__excerpt">
                  <p>{{block.value}}</p>
                </div>
              {% endif %}
            {% endfor %}
        </div>
        <div class="teaser-stacklist__cta-buttons">
          {% has_forms page=article as has_polls %}
          {% if has_polls %}
            <div class="vote__item">
              <a href="#survey-form" class="vote__icon">{% trans "Poll" %}</a>
            </div>
          {% endif %}

          {% comment %}
            <!-- DISPLAY REACTION QUESTIONS RADIO FIELDS -->
          {% endcomment %}
          {% forms_list_linked_to_pages article %}

          {% if settings.core.SiteSettings.facebook_sharing or settings.core.SiteSettings.twitter_sharing %}
            <div class="share__item">
              <a href="#" id="share_article" class="share__icon">{% trans "Share" %}</a>
              <div id="share_reveal" class="share__reveal">
                {% social_media_article page=article %}
              </div>
            </div>
          {% endif %}
        </div>
      </div>
    </li>
  {% endfor %}
  </ul>
{% endif %}
