{% extends 'layouts/_main' %}


{% block content %}
  <div class="container first-container"> 
    <div class="container mt-4">
      <div class="row mb-2 align-items-center">
        <div class="col-lg-6 text-center mx-auto">
          <h2 class="font-weight-bold text-primary heading">
              Latest Articles 
          </h2>
        </div>
      </div>
    </div>

    <section class='my-5'>

          {% set articles = craft.entries.section('articles').status(['live']).limit(15) %}
          
          {% for article in articles %}
          <div class="card">
            <div class="card-body">
              <div class="row">
                <div class="col-4">
                  {% set imgUrl = article.mainImage.one().getUrl() %}
                  
                  {% if imgUrl %}
                    <div class="p-2"><img src="{{imgUrl}}" class="img-fluid"></div>
                  {% endif %}
                </div>
                <div class="col-8">
                  <a href="{{ article.slug }}" class="h4">
                  {{article.title}}</a>
                  <div class="small text-muted mb-2">{{ article.postDate | date('j M Y') }}</div>
                  {{ article.mainText | striptags | truncate(1000) }}
                </div>
              </div>
            </div>
          </div>
          {% endfor %}          
    </section>

  </div>
{% endblock %}