最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

First in for loop in jekyll and liquid - Stack Overflow

programmeradmin2浏览0评论

I want to add a slider for every book that has the page hero banner. But the bootstrap slider needs th 'active' class to work.

<div class="carousel-inner">
    {% for libro in site.libros %}
        {% if libro.heroLibro %}
            {% if forloop.index == 1 %}
                <div class="carousel-item active">
                <img src="{{ site.baseurl }}/assets/img/libros/hero/{{ libro.heroLibro }}" alt=""
                    class="img-fluid rounded shadow border-light w-100">
                </div>
            {% else %}
                <div class="carousel-item">
                    <img src="{{ site.baseurl }}/assets/img/libros/hero/{{ libro.heroLibro }}" alt=""
                        class="img-fluid rounded shadow border-light w-100">
                </div>
            {% endif %}
        {% endif %}
    {% endfor %}
</div>

This i what i´ve got. I've tried

{% if forloop.first === true  %}
{% if forloop.index == 1 %}

But nothing works. What I'm doing wrong?

发布评论

评论列表(0)

  1. 暂无评论