{% extends 'common/layout.html.twig' %}

{% block content %}
<div class='container newslist mt-5'>
	<h1><i class="fa fa-newspaper"></i> {{'Actualités'|trans}}</h1>
	{% for new in news %}
		<div class="card mb-4">
			<div class="card-header" style='cursor:pointer;'><h2><a href='{{path('show_news', {'slug': new.slug})}}'>{{ new.title|capitalize }}</a></h2></div>
			<div class="card-body">
				<div class="card-text">
					{% if new.media %}
						{% set pathMedia = mediaurl(new.media, 'reference') %}
						{% if pathMedia ends with '.jpg' or pathMedia ends with '.png' or pathMedia ends with '.bmp' or pathMedia ends with '.gif' %}
							<img src="{% path new.media, 'reference' %}" style="max-width: 100%;"/>
						{% else %}
							<a href="{% path new.media, 'reference' %}">{{'Télécharger'|trans}}</a>
						{% endif %}

					{% endif %}
					{{new.content|raw}}
				</div>
			</div>
			<div class="card-footer text-muted">
              {{'Crée le'|trans}} {{new.createdAt|date('d/m/Y')}}
            </div>
		</div>
	{% endfor %}
	<div class="pagination">
    	{{ knp_pagination_render(news) }}
	</div>
</div>
{% endblock %}