{% extends 'base.html.twig' %}
{% set blogTags = getBlogTags(app.request) %}
{% set blogLang = getLang(blog.getBlogLangs(), app.request) %}
{% set pageTitle = blogLang.title %}

{% if blogLang.keywords %}
    {% set keywords = blogLang.keywords %}
{% else %}
    {% set keywords = "" %}
    {% set precondition = true %}
    {% set text = blogLang.description|replace({'\n': ''}) %}
    {% for i in 0..5 %}
        {% if precondition %}
            {% set elementContent = getElementContent(text, 'b') %}
            {% set precondition = elementContent['content'] %}
            {% if precondition %}
                {% set text = elementContent['after'] %}
                {% if i != 0 %}{% set keywords = keywords ~ "," %}{% endif %}
                {% set keywords = keywords ~ precondition %}
            {% endif %}
        {% endif %}
    {% endfor %}
{% set keywords = keywords|replace({' ,': ','}) %}

{% endif %}
{% block meta %}
    <meta property="og:image" content="{{ app.request.schemeAndHttpHost }}{{ asset('img/blog/'~blog.image) }}">
    {% if blogLang.metaDescription %}
        <meta name="description" content='{{ blogLang.metaDescription }}'>
    {% elseif '</p>' in blogLang.description %}
        <meta name="description" content='{{ blogLang.description|split('.')[0]|replace({'<p>': ''}) }}'>
    {% endif %}
    <meta name="keywords" content="{{ keywords }}">
{% endblock %}
{% block og_type %}article|raw{% endblock %}

{% block stylesheets %}
    <link rel="stylesheet" href="{{ asset('styles/blog-detail.css') }}">
    <style>
        .intro-img {
            background-image: url({{asset('img/blog/'~blog.image)}}) !important;
        }
    </style>
{% endblock %}

{% block content %}
    {% include "components/_intro.html.twig" with {options: {
        title: blogLang.title,
        skip: false,
        isBlogDetail: true,
        watchButton: false,
        blogTags: blog.tagIdentifierArray
    }} %}
    <div class="section-wrapper blog-detail-wrapper">
        <div class="content-section blog-detail">
            {{blogLang.description|raw}}
        </div>
    </div>
    <div class="section-wrapper home-blogs-wrapper">
        <div class="content-section home-blogs">
            <div class="content-title-wrapper">
                <h2 class="content-title">technoone'dan haberler</h2>
            </div>
            <div class="blogs-wrapper">
                <h2 class="section-title">{{ "featured_blogs"|trans|title }}</h2>
                <a href="{{path('blog', {'locale': locale})}}" class="standart-button border-button arrow-anim arrow-dark">Tümünü inceleyin</a>
            </div>
            <div class="blog-content">
                {% for blog in getBlogs({'perPage':3, 'exclude': [blog.id]}, app.request)['blogs'] %}
                    {% include "components/_blog-item.html.twig" with {blog: blog} %}
                {% endfor %}
            </div>
        </div>
    </div>
{% endblock %}