{% 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'
    }
  )
%}

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

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

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

  <h2 class="sr-only">記事一覧</h2>

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

  {% if entrySummary.items is not empty %}
    {% if PAGE >= 2 %}
      <p class="sr-only">
        {{ PAGE }}ページ目
      </p>
    {% endif %}

    <div class="grid grid-cols-12 pb-10 gap-y-8 gap-x-4 sm:gap-8">
      {% for entry in entrySummary.items %}
        <article
          aria-labelledby="card-entry{{ entry.eid }}"
          class="col-span-12 {{ column_class|default('sm:col-span-6') }}"
        >
          <a href="{{ entry.url }}" class="block w-full hover:opacity-70">
            {% if entry.mainImage and entry.mainImage.path %}
              <img
                src="{{ entry.mainImage.path|resizeImg(700) }}"
                width="700"
                height="{{ entry.mainImage.ratio|getHeightFromRatio(700) }}"
                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="640"
                height="480"
                alt=""
                loading="lazy"
                decoding="async"
                class="object-cover w-full mb-4 overflow-hidden rounded-md shadow-sm aspect-video"
              />
            {% endif %}
            <h3 id="card-entry{{ entry.eid }}" class="mt-3 text-gray-900 text-base md:text-lg font-bold line-clamp-2">
              {{ entry.title }}
            </h3>
            <p class="mt-2 text-sm line-clamp-2">
              {{ entry.summary }}
            </p>
            <div class="flex flex-wrap items-center gap-x-2 gap-y-1 mt-2 text-sm">
              <p class="text-gray-500">
                <span class="sr-only">公開日</span><time datetime="{{ entry.datetime|date('Y-m-d') }}">{{
                    entry.datetime|date('Y年m月d日')
                  }}</time>
              </p>
              {% if entry.isNew %}
                <p class="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 text-sm">
                <span class="sr-only">カテゴリー</span>{{ entry.category.items[0].name }}
              </p>
            {% endif %}
            {% if entry.tags %}
              <ul class="mt-2 flex flex-wrap gap-x-3 gap-y-1">
                {% for tag in entry.tags %}
                  <li class="text-gray-500 text-sm">#{{ tag.name }}</li>
                {% endfor %}
              </ul>
            {% endif %}
          </a>
        </article>
      {% endfor %}
    </div>
  {% endif %}

  {{ include('/include/parts/pagination.twig', { pagination: entrySummary.pagination }) }}
</section>
