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

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

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

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

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

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

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

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

                <div class="news__feeds">
                    <a href="{{ url('news-category-feed-atom', {'category': news_category.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': news_category.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 %}
