templates/post/all_posts.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}
  3.   Статьи и публикации – Николай Макаров
  4. {% endblock %}
  5. {% block body %}
  6.   <div class="flex flex-col md:flex-row">
  7.     <div class="w-full md:w-1/4">
  8.       <!-- Categories -->
  9.       <h2 class="text-3xl font-bold text-gray-800 m-4 text-center">Категории статей</h2>
  10.       <div class="flex justify-center">
  11.         <ul class="space-y-2 mx-auto">
  12.           <li>
  13.             <a href="{{ path('app_posts') }}" class="category-link text-lg font-bold text-blue-500" data-category="all" aria-label="Все категории статей">Все категории</a>
  14.           </li>
  15.           {% for genre, count in genreCounts %}
  16.             {% if genre != 'non-genre' %}
  17.               <li>
  18.                 <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 }} статей">
  19.                   {{ genre }} ({{ count }})
  20.                 </a>
  21.               </li>
  22.             {% endif %}
  23.           {% endfor %}
  24.         </ul>
  25.       </div>
  26.     </div>
  27.     <div class="w-full md:w-3/4">
  28.       <!-- Posts -->
  29.       <h2 class="text-3xl font-bold text-gray-800 m-4 text-center">Все статьи и публикации</h2>
  30.       <div class="grid grid-cols-1 justify-items-center md:grid-cols-2 lg:grid-cols-3 gap-4 mx-auto">
  31.         {% for post in pagination %}
  32.           {% set normalizedGenre = post.genre|trim|lower %}
  33.           {% if normalizedGenre != 'non-genre' %}
  34.             <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 }}">
  35.               <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">
  36.                 <div class="md:flex-shrink-0 h-64">
  37.                   {% if post.photo %}
  38.                     <img src="{{ asset('photos/' ~ post.photo) }}" alt="Изображение к статье {{ post.title }}" class="object-cover w-full h-full rounded-lg rounded-b-none">
  39.                   {% else %}
  40.                     <img src="/photos/abstract.jpg" alt="Заглушка для статьи" class="object-cover w-full h-full rounded-lg rounded-b-none">
  41.                   {% endif %}
  42.                 </div>
  43.                 <div class="flex items-center justify-between px-4 py-2 overflow-hidden">
  44.                   <span class="text-xs font-medium text-blue-600 uppercase">{{ post.genre }}</span>
  45.                 </div>
  46.                 <hr class="border-gray-300">
  47.                 <div class="flex flex-wrap items-center flex-1 px-4 py-1 text-center mx-auto">
  48.                   <a href="{{ path('post_by_id', {'id': post.id}) }}" class="hover:underline" aria-label="Читать статью: {{ post.title }}">
  49.                     <h3 class="text-2xl font-bold tracking-normal text-gray-800 dark:text-gray-400">{{ post.title }}</h3>
  50.                   </a>
  51.                 </div>
  52.                 <hr class="border-gray-300">
  53.                 <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">
  54.                   {% if post.epigraph %}
  55.                     {{ post.epigraph }}
  56.                   {% else %}
  57.                     Откройте и прочитайте полностью этот пост
  58.                   {% endif %}
  59.                 </p>
  60.               </div>
  61.             </div>
  62.           {% endif %}
  63.         {% endfor %}
  64.       </div>
  65.       {% if pagination.totalItemCount > pagination.itemNumberPerPage %}
  66.         <nav aria-label="Навигация по страницам" class="mt-8 mb-8 flex justify-center">
  67.           <ul class="inline-flex -space-x-px">
  68.             {% for page in 1..pagination.pageCount %}
  69.               <li>
  70.                 <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 }}">
  71.                   {{ page }}
  72.                 </a>
  73.               </li>
  74.             {% endfor %}
  75.           </ul>
  76.         </nav>
  77.       {% endif %}
  78.     </div>
  79.   </div>
  80. {% endblock %}