Skip to content

Latest commit

 

History

History
32 lines (25 loc) · 504 Bytes

20.1-componentizing.md

File metadata and controls

32 lines (25 loc) · 504 Bytes

Just make one.

{# _news/index.twig #}

{% for entry in craft.entries({
    section: "news",
    limit: 10,
}).all() %}
    <div>
        {% include "_components/card" %}
    </div>
{% endfor %}
{# _components/card.twig #}

<div>
    {% for asset in entry.listingImage.limit(1).all() %}
        <img src="{{ asset.url }}" alt="">
    {% endfor %}
    <h3>{{ entry.title }}</h3>
    {{ entry.description }}
</div>