1

次のJekyllインデックスがあります

---
layout: default
title: My favourite sandwiches
---

<section class="home">
  {% for post in site.posts %}
    <article class="column">
      <img src="{{ post.image }}">
      <a href="{{ post.url }}">{{ post.title }}</a>
    </article>
  {% endfor %}
</section>

私のサイトには、タイルのように 3 つの記事 (ブロック) が隣り合っています。

ただし、1 番目と 3 番目の記事タグにクラスを追加して、別のスタイルを追加できるようにしたいと考えています。

この動作を追加する方法と、たとえば何かにインデックスを付ける方法があるかどうかを知りたかったのです。class="first" if index == 3/1

私が欲しかったhtmlは、このようなものになることです

<section class="home">
    <article class="column first">
      <img src="images/bigsandwich.jpg">
      <a href="site.com/post/bigsandwich.html">My big sandwich</a>
    </article>

    <article class="column">
      <img src="images/icecreamsandwich.jpg">
      <a href="site.com/post/bigsandwich.html">Icecream sandwich</a>
    </article>

    <article class="column last">
      <img src="images/sushisandwich.jpg">
      <a href="site.com/post/sushisandwich.html">Sushi sandwich</a>
    </article>
</section>

ご理解とご協力をお願いいたします。

4

1 に答える 1