{% extends 'news/master.twig' %}
{% from 'macros.twig' import pagination, container_title %}
{% from 'news/macros.twig' import news_preview %}

{% set title = category_info.name ~ ' :: News' %}
{% set manage_link = url('manage-news-category', {'category': category_info.id}) %}
{% set canonical_url = url('news-category', {
    'category': category_info.id,
    'page': news_pagination.page > 2 ? news_pagination.page : 0,
}) %}

{% set feeds = [
    {
        'type': 'rss',
        'title': '',
        'url': url('news-category-feed-rss', {'category': category_info.id}),
    },
    {
        'type': 'atom',
        'title': '',
        'url': url('news-category-feed-atom', {'category': category_info.id}),
    },
] %}

{% block content %}
    <div class="news__container">
        <div class="news__preview__listing">
            {% for post in posts %}
                {{ news_preview(post) }}
            {% endfor %}

            <div class="container" style="padding: 4px; display: {{ news_pagination.pages > 1 ? 'block' : 'none' }}">
                {{ pagination(news_pagination, url('news-category', {'category':category_info.id})) }}
            </div>
        </div>

        <div class="news__sidebar">
            <div class="container news__list">
                {{ container_title('News » ' ~ category_info.name) }}

                <div class="container__content">
                    {{ category_info.description }}
                </div>
            </div>

            <div class="container">
                {{ container_title('Feeds') }}

                <div class="news__feeds">
                    <a href="{{ url('news-category-feed-atom', {'category': category_info.id}) }}" class="news__feed">
                        <div class="news__feed__icon">
                            <i class="fas fa-rss"></i>
                        </div>
                        <div class="news__feed__type">
                            Atom
                        </div>
                    </a>
                    <a href="{{ url('news-category-feed-rss', {'category': category_info.id}) }}" class="news__feed">
                        <div class="news__feed__icon">
                            <i class="fas fa-rss"></i>
                        </div>
                        <div class="news__feed__type">
                            RSS
                        </div>
                    </a>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
