{% if paths_base == null %}
    {% set paths_base = '../..' %}
{% endif %}

{% set type = "notices" %}

{% extends "base.twig" %}

{% set bodyClasses = 'single single-news' %}

{% set post = post_type[~type~].items[currentPost] %}

{% block breadcrumbs %}

    {% set breadcrumbs_block = 
        {
            "post_type": type,
            "show_terms": false,
            "current_id": currentPost 
        }
    %}
    {% include '../blocks/breadcrumbs.twig' with {'block': breadcrumbs_block } %}

{% endblock %}

{% block content %}

    <div class="grid-container spacing-5">
        <div class="columns">
            <div class="w-full lg:w-1/2 column">
                {% set notice_info_content_items = [
                    {
                        "label": "Data",
                        "text": post.date|date('d.m.Y')
                    }
                ] %}
                {% for term in post.terms %}
                    {% set parent_post_term = term[0] %}
                    {% set post_term = term[1] %}
                    {% set notice_info_content_items = notice_info_content_items|merge([
                        {
                            "label": taxonomies[~type~].terms[~parent_post_term~].name,
                            "text": taxonomies[~type~].terms[~parent_post_term~].items[~post_term~].name
                        }
                    ]) %}
                {% endfor %}
                {% set news_info = 
                    {
                        "key": "grid-list",
                        "content": {
                            "items": notice_info_content_items
                        }
                    }
                %}
                {% include '../blocks/grid-list.twig' with {'block': news_info } %}
            </div>
            <div class="w-full lg:w-1/2 column">
                {% if post.abstract %}
                    <p class="h4">{{post.abstract}}</p>
                {% endif %}
                {{post.content}}
                {% for block in post.blocks %}
                    {% include '../blocks/'~block.key~'.twig' with {'block': block } %}
                {% endfor %}
            </div>
        </div>
    </div>

    {% if post.related_subjects != null %}
        <div class="grid-container">

            {# Titolo #}
            {% set enrollment_block_title = 
                {
                    "key": "title",
                    "tag": "h2",
                    "classes": "block-title--sm block-title--divider",
                    "content": {
                        "title": "Argomenti correlati"
                    }
                }
            %}
            {% include '../blocks/title.twig' with {'block': enrollment_block_title } %}

            <div class="cards-container">
                <div class="cards-container__inner">
                    {% for subject in post.related_subjects %}
                        {% set card = post_type[~subject.post_type~].items[~subject.id~] %}
                        {% include './partials/card.twig' with {'card': card } %}
                    {% endfor %}
                </div>
            </div>
        </div>
    {% endif %}

    {% if post.related_contacts %}
        {% set news_contacts_items = [] %}
        {% for contact in post.related_contacts %}
            {% set news_contacts_items = news_contacts_items|merge([
                post_type[~contact.type~].items[~contact.id~]
            ]) %}
        {% endfor %}
        {% set news_contacts = {
            "key": "contacts-section",
            "classes": "",
            "title": {
                "key": "title",
                "tag": "h2",
                "classes": "block-title--sm",
                "content": {
                    "title": "Contatti",
                    "link": {
                        "label": "Vai alla rubrica contatti",
                        "url": "/pages/contatti/strutture.html"
                    }
                }            
            },
            "content": [
                {
                    "items": news_contacts_items
                }
            ]
        } %}
        {% include '../blocks/contacts-section.twig' with {'block': news_contacts, 'id': 'contatti' } %}
    {% endif %}

    {% if post.related_news %}
        <div class="grid-container">
            {# Titolo #}
            {% set news_block_title = 
                {
                    "key": "title",
                    "tag": "h2",
                    "classes": "block-title--sm block-title--divider",
                    "content": {
                        "title": "Novità dall’ambito architettura",
                        "link": {
                            "label": "Vedi tutte",
                            "url": "#"
                        }
                    }
                }
            %}
            {% include '../blocks/title.twig' with {'block': news_block_title } %}

            {# News posts #}
            {% set news_tease_row = {
                "key": "tease-row",
                "classes": "",
                "content": {
                    "featured": [
                        {
                            "post_type": "news",
                            "items": post.related_news
                        }
                    ]
                }
            } %}
            {% include '../blocks/tease-row.twig' with {'block': news_tease_row } %}
        </div>
    {% endif %}

    {# <div class="news-posts-nav">
        <div class="news-posts-nav__inner">
            <a href="#">
                <span>Notizia precedente</span>
                <span>Agenzia del Demanio e Università Iuav di Venezia insieme...</span>
            </a>
            <a href="#">
                <span>Notizia successiva</span>
                <span>Collaboratori alla didattica Iuav ottengono una menzione...</span>
            </a>
        </div>
    </div> #}

{% endblock %}