{% extends 'base.html.twig' %}
{% block title %}
Статьи и публикации – Николай Макаров
{% endblock %}
{% block body %}
<div class="flex flex-col md:flex-row">
<div class="w-full md:w-1/4">
<!-- Categories -->
<h2 class="text-3xl font-bold text-gray-800 m-4 text-center">Категории статей</h2>
<div class="flex justify-center">
<ul class="space-y-2 mx-auto">
<li>
<a href="{{ path('app_posts') }}" class="category-link text-lg font-bold text-blue-500" data-category="all" aria-label="Все категории статей">Все категории</a>
</li>
{% for genre, count in genreCounts %}
{% if genre != 'non-genre' %}
<li>
<a href="{{ path('post_by_genre', {'genre': genre}) }}" class="category-link text-lg font-bold text-blue-500" data-category="{{ genre }}" aria-label="Категория {{ genre }} – {{ count }} статей">
{{ genre }} ({{ count }})
</a>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
</div>
<div class="w-full md:w-3/4">
<!-- Posts -->
<h2 class="text-3xl font-bold text-gray-800 m-4 text-center">Все статьи и публикации</h2>
<div class="grid grid-cols-1 justify-items-center md:grid-cols-2 lg:grid-cols-3 gap-4 mx-auto">
{% for post in pagination %}
{% set normalizedGenre = post.genre|trim|lower %}
{% if normalizedGenre != 'non-genre' %}
<div class="transition-all duration-150 flex flex-col w-full px-4 py-6 category-card min-w-[200px] max-w-[400px] h-full" data-category="{{ post.genre }}">
<div class="flex flex-col items-stretch min-h-full pb-4 mb-6 transition-all duration-150 bg-white rounded-lg shadow-lg hover:shadow-2xl dark:bg-neutral-700">
<div class="md:flex-shrink-0 h-64">
{% if post.photo %}
<img src="{{ asset('photos/' ~ post.photo) }}" alt="Изображение к статье {{ post.title }}" class="object-cover w-full h-full rounded-lg rounded-b-none">
{% else %}
<img src="/photos/abstract.jpg" alt="Заглушка для статьи" class="object-cover w-full h-full rounded-lg rounded-b-none">
{% endif %}
</div>
<div class="flex items-center justify-between px-4 py-2 overflow-hidden">
<span class="text-xs font-medium text-blue-600 uppercase">{{ post.genre }}</span>
</div>
<hr class="border-gray-300">
<div class="flex flex-wrap items-center flex-1 px-4 py-1 text-center mx-auto">
<a href="{{ path('post_by_id', {'id': post.id}) }}" class="hover:underline" aria-label="Читать статью: {{ post.title }}">
<h3 class="text-2xl font-bold tracking-normal text-gray-800 dark:text-gray-400">{{ post.title }}</h3>
</a>
</div>
<hr class="border-gray-300">
<p class="flex flex-row flex-wrap w-full px-4 py-2 overflow-hidden text-sm text-justify text-gray-700 h-20 md:h-24 lg:h-28 dark:text-gray-400">
{% if post.epigraph %}
{{ post.epigraph }}
{% else %}
Откройте и прочитайте полностью этот пост
{% endif %}
</p>
</div>
</div>
{% endif %}
{% endfor %}
</div>
{% if pagination.totalItemCount > pagination.itemNumberPerPage %}
<nav aria-label="Навигация по страницам" class="mt-8 mb-8 flex justify-center">
<ul class="inline-flex -space-x-px">
{% for page in 1..pagination.pageCount %}
<li>
<a href="{{ path('app_posts', {'page': page}) }}" class="px-3 py-2 leading-tight text-gray-500 bg-white border border-gray-300 {% if pagination.currentPageNumber == page %}text-sky-800 bg-sky-300 border-sky-600 border-2 hover:bg-blue-100 hover:text-blue-700 dark:border-gray-700 dark:bg-gray-700 dark:text-white {% else %}hover:bg-gray-100 hover:text-gray-700{% endif %}" aria-label="Страница {{ page }}">
{{ page }}
</a>
</li>
{% endfor %}
</ul>
</nav>
{% endif %}
</div>
</div>
{% endblock %}