{% import 'common/macros/elements.html.twig' as elements %}
{% import _self as _ %}
{% macro truncate(text, len) %}
{% if text|length > len %}
{{ text|slice(0,len) ~ '...' }}
{% else %}
{{ text }}
{% endif %}
{% endmacro %}
{% macro list_item(post) %}
{% set href = path('news_show', { news: post.getSlug() }) %}
<article class="list-item">
{% if post.coverImagePath is not null %}
<div class="image">
<a href="{{ href }}">
<img src="{{ getUploadsUrl(post.coverImagePath) }}" alt="{{ post.getTitle() }}"/>
</a>
</div>
{% endif %}
<div class="content">
{{ elements.heading('<a href="' ~ href ~ '">' ~ getNewsTitle(post) ~ '</a>', 3, 'title') }}
<p class="text">{{ getNewsShortDescription(post) }}</p>
{{ elements.CTA('common.read_more'|trans|upper, href, 'link') }}
</div>
</article>
{% endmacro %}
<section class="news-section section {{ isSingleNewsPage is defined and isSingleNewsPage ? 'single-news-section' : '' }}">
<div class="section-header">
{% if isSingleNewsPage is not defined %}
{{ elements.heading('common.news'|trans|upper, 4, 'section-category') }}
{{ elements.heading('common.latest_posts'|trans, 2, 'section-title') }}
{% else %}
{{ elements.heading('common.more_news'|trans, 2, 'section-title') }}
{% endif %}
</div>
<div class="list">
{% for item in items %}
{{ _.list_item(item) }}
{% endfor %}
</div>
{% if hideMore is not defined %}
<div class="more">
{% if more|default('a') == 'a' %}
{{ elements.CTA('common.more_news'|trans|upper, path('news_index'), 'secondary') }}
{% else %}
<div class="btn cta-secondary">{{ 'common.more_news'|trans|upper }}</div>
{% endif %}
</div>
{% endif %}
</section>