{% extends "page/titled/default.html.twig" %}

{%- block page_title -%}
    {{- parent()|build_string(post) -}}
{% endblock %}

{%- block meta_title -%}
    {{- parent()|build_string(post) -}}
{% endblock %}

{% block meta_description %}
    {{- parent()|build_string(post) -}}
{% endblock %}

{%- block page_subtitle -%}
    <ul class="list--inline no-margin">
        <li>
            <time datetime="{{ post.publishedAt|date("Y-m-d") }}" title="{{ post.publishedAt|date("r") }}">
                {{- 'Le ' ~ post.publishedAt|date("d/m/Y à H\\hi") -}}
            </time>
        </li>
        {% for category in post.categories %}
            <li>
                <a href="{{ safe_path('blog_menu_category', {category: category.id, slug: category.slug, _domain: _domain}) }}">
                    {{- category.title -}}
                </a>
            </li>
        {% endfor %}

        {% for tag in post.tags %}
            <li>
                <a href="{{ safe_path('blog_menu_search', {tag: tag.label, _domain: _domain}) }}">
                    {{- '#' ~ tag.label -}}
                </a>
            </li>
        {% endfor %}
    </ul>
{% endblock %}

{%- block body -%}
    {{ include('page/post/_post.html.twig', {full: true}) }}
{% endblock %}

{%- block openGraph -%}
    {% if not post.isQuick %}
        {% set name = 'Deblan Blog' %}
        {% set title = 'Blog - ' ~ block('meta_title') %}
        {% set image = post.image ? absolute_url(asset(post.image)) : null %}
    {% else %}
        {% set image = null %}

        {% if post.quickImage %}
            {% set image = post.quickImage %}
        {% elseif post.image %}
            {% set image = absolute_url(asset(post.image)) %}
        {% endif %}

        {% set title = block('meta_title') %}
        {% set name = '' %}
    {% endif %}

    <link rel="canonical" href="{{ safe_url(_node.routeName, {post: post.id, slug: post.slug, _domain: _domain}) }}" />
    <meta property="og:title" content="{{ _page.ogTitle|build_string(post) }}" />
    <meta property="og:url" content="{{ safe_url(_node.routeName, {post: post.id, slug: post.slug, _domain: _domain}) }}" />

    {% if image %}
        <meta property="og:image" content="{{ image }}" />
        <meta property="og:image:secure_url" content="{{ image }}" />
    {% endif %}

    <meta property="og:site_name" content="{{ name }}" />
    <meta property="og:locale" content="fr_FR" />
    <meta property="og:type" content="article" />
{% endblock %}
