{% if posts is defined and posts|length > 0 %}
<section class="m_position-relative m_recent-news">
<div class="m_container-lg">
<div class="m_title-h2 m_flex">
<h2 class="">{{ 'recent.posts'|trans }}</h2>
<a href="{{ path('app_posts_all') }}" title="{{ 'see.more'|trans }}" class="m_link-read-more">
{{ 'see.more'|trans }}
</a>
</div>
<div class="m_listing-news m_flex">
{% if posts is defined and posts is not empty %}
{% for elt in posts %}
<article class="m_item-news m_item-post">
<div class="m_item-news-container m_position-relative">
<div class="m_item-news-thumb m_item-post-thumb">
{% if elt.thumbnail is defined and elt.thumbnail.filename is defined %}
<img src="{{ path('proxy_avatar', {'path': elt.thumbnail.filename}) }}"
alt="{{ i18n.name|default('No title') }}"/>
{% else %}
<img src="{{ asset('images/defaults/media.png') }}"
alt="Default Image"/>
{% endif %}
</div>
<div class="m_item-news-content m_item-post-content">
{% set localeCode = elt.i18ns[0].locale|split('_')|first %}
{% set i18n = (app.request.locale == localeCode and elt.i18ns[0] is defined)
? elt.i18ns[0]
: (elt.i18ns[1] is defined ? elt.i18ns[1] : null) %}
{% if i18n %}
{# Affichage de la date de publication #}
{% if elt.publishedDate is defined %}
<time datetime="{{ elt.publishedDate|date('Y-m-d') }}" class="m_post-date">
{{ elt.publishedDate|format_date(locale= app.request.locale, pattern='d MMMM y') }}
</time>
{% endif %}
{% if elt.category is defined and elt.category.i18ns is defined %}
{% set categoryI18n =(app.request.locale == localeCode and elt.category.i18ns[0] is defined) ? elt.category.i18ns[0] : ( elt.category.i18ns[1] is defined ? elt.category.i18ns[1] : null) %}
{% if categoryI18n is defined %}
<div class="m_badge-category">
{{ categoryI18n.name }}
</div>
{% endif %}
{% endif %}
<h3>{{ i18n.name|striptags|u.truncate(90, '...') }}</h3>
<div class="m_item-news-excerpt m_item-post-excerpt">
<p>{{ i18n.description|striptags|u.truncate(120, '...')|raw }}</p>
</div>
{% endif %}
<a href="{{ path('app_posts_detail', {'id': elt.id,'slug':i18n.slug}) }}"
class="m_underline-link-blue">
{{ 'see.more'|trans }}
</a>
</div>
<a href="{{ path('app_posts_detail', {'id': elt.id,'slug':i18n.slug}) }}"
class="m_link-overlay"></a>
</div>
</article>
{% endfor %}
{% else %}
<p>{{ 'no.posts.found'|trans }}</p>
{% endif %}
</div>
</div>
</section>
{% endif %}