{% if posts or title or text %}
  {% set archiveLink = fn.get_post_type_archive_link('campaigns') %}
  <section class="m_panel" m-pack="premium">
    {% include 'm_components/widgets/headline.twig' with {
      title : title,
      text: text,
      link: archiveLink
    }
    only %}
    {% if posts %}
      <div class="grid">
        {% for post in posts %}

          {% set tax = fn.wp_get_post_terms(post.ID, 'category', {'fields': 'names'}) %}

          {% set post_title = post.post_title %}
          {% set post_text = post.post_excerpt
            ? post.post_excerpt
            : fn.wp_trim_words(post.post_content, 18, '...') %}
          {% set post_date = post.post_date | date('d. m. y') %}
          {% set dateTime = post.post_date|date('Y-m-d') %}

          {% set post_link = fn.get_the_permalink(post.ID) %}

          {% set postThumbM = fn.get_the_post_thumbnail_url(post.ID, 'medium') %}
          {% set postThumbS = fn.get_the_post_thumbnail_url(post.ID, 'thumbnail') %}

          <a href="{{post_link}}" class="m_panel__block">

            <div class="m_panel__image ">
              {% if post.video_news %}
                <span class="m_video__player"></span>{% endif %}
              <picture class="objectfit--cover">
                <source media="(min-width: 786px)" lazy-src="{{postThumbM}}">
                <source media="(min-width: 320px)" lazy-src="{{postThumbS}}">
                <img lazy-src="{{postThumbM}}" alt="{{postTitle}}">
              </picture>
            </div>

            <div class="m_panel__content">

              <small>
                <time datetime="{{dateTime}}">{{ post_date }}</time>
                {% if tax %}
                  <span class="separator">|</span>
                  {{tax|join(', ')}}
                {% endif %}
              </small>
              <h3>{{post_title}}</h3>
              {% if post_text %}
                <p>{{post_text|striptags}}</p>
              {% endif %}
            </div>
          </a>

        {% endfor %}
      </div>

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