{% set entrySummary =
  module(
    'V2_Entry_Summary',
    moduleId,
    {
      bid: BID,
      cid: CID,
      eid: EID,
      uid: null,
      page: PAGE,
      limit: 12,
      keyword: KEYWORD,
      tag: TAG|split('/'),
      field: null,
      order: null,
      start: START,
      end: '9999-12-31 23:59:59'
    }
  )
%}

<div>
  {{ include('/admin/module/setting.twig', { moduleInfo: entrySummary.moduleInfo }) }}

  {% if entrySummary.items is empty %}
    <p class="text-gray-900 text-lg text-center">
      記事が見つかりませんでした。
    </p>
  {% endif %}

  {% if touch('Touch_Keyword') %}
    <p class="text-gray-900 text-2xl font-bold mb-8">
      {{ KEYWORD }} の検索結果：

      {{ entrySummary.pagination.total }}件
    </p>
  {% endif %}

  <div class="grid grid-cols-12 pb-10 gap-y-8 gap-x-4 sm:gap-8">
    {% for entry in entrySummary.items %}
      <div class="flex flex-col items-start space-y-3 col-span-12 {{ column_class|default('sm:col-span-6') }}">
        <a href="{{ entry.url }}" class="block w-full text-sm hover:opacity-70">
          {% if entry.mainImage.path %}
            <img
              src="{{ entry.mainImage.path|resizeImg(686, 386) }}"
              width="343"
              height="193"
              alt="{{ entry.mainImage.alt }}"
              loading="lazy"
              decoding="async"
              class="object-cover w-full mb-4 overflow-hidden rounded-md shadow-sm aspect-video"
            />
          {% else %}
            <img
              src="/images/default/noimage.gif"
              width="343"
              height="193"
              alt="画像なし"
              loading="lazy"
              decoding="async"
              class="object-cover w-full mb-4 overflow-hidden rounded-md shadow-sm aspect-video"
            />
          {% endif %}
          <h2 class="mt-3 text-gray-900 text-lg font-bold line-clamp-2">{{ entry.title }}</h2>
          <p class="mt-2 line-clamp-2">
            {{ entry.summary }}
          </p>
          <div class="flex items-center mt-2">
            <p class="text-gray-500">
              <time datetime="{{ entry.datetime|date('Y-m-d') }}">{{ entry.datetime|date('Y年m月d日') }}</time>
            </p>
            {% if entry.isNew %}
              <p class="ml-2 px-2 py-1 rounded-full bg-gray-50 text-gray-900 text-xs">
                NEW
              </p>
            {% endif %}
          </div>
          {% if entry.category.items %}
            <p class="mt-2 text-gray-500 font-bold">
              {{ entry.category.items[0].name }}
            </p>
          {% endif %}
          {% if entry.tags %}
            <ul class="flex flex-wrap gap-x-3 gap-y-1 mt-2 text-gray-500">
              {% for tag in entry.tags %}
                <li>#{{ tag.name }}</li>
              {% endfor %}
            </ul>
          {% endif %}
        </a>
      </div>
    {% endfor %}
  </div>
  {{ include('/include/parts/pagination.twig', { pagination: entrySummary.pagination }) }}
</div>
