{% if posts or title or text %}
  {% set archiveLink = fn.get_post_type_archive_link('events') %}

  <section class="m_panel" m-pack="premium">
    <div class="grid--lg">
      {% include 'm_components/widgets/headline.twig' with {
        title : title,
        text: text,
        link: archiveLink
      }
      only %}
      <div class="grid">
        {% for item in posts %}

          {% set related_title = item.post_title %}

          {% set related_content = item.post_excerpt
            ? item.post_excerpt
            : fn.wp_trim_words(item.post_content, 18, '...') %}

          {% set image = fn.get_post_thumbnail_id(item.ID) %}

          <a href="{{fn.get_the_permalink(item.ID)}}" class="m_panel__block">
            <div class="m_panel__image">
              {% include 'm_components/widgets/picture.twig' with {image: image, title: title} only %}
              <time class="m_panel__date"><span class="day"> {{ item.m_start_date|date('d') }}</span>{{ item.m_start_date|date('M') }}</time>
            </div>
            <div class="m_panel__content">
              <h2 class="h4">{{ item.post_title }}</h2>
              {% if related_content %}
                <p>{{related_content|striptags}}</p>
              {% endif %}
              <span class="btn__arrow btn__arrow--right">Read more</span>
            </div>
          </a>

        {% endfor %}
      </div>

    </div>

      {% if archive %}
        {% include 'm_components/widgets/link.twig' with {
          textBtn : "View more",
          link: archiveLink
        }
      only %}
      {% endif %}
    </div>

  </section>

{% endif %}
