cards as component thanks to asyncEach
This commit is contained in:
parent
0bb4db78d6
commit
fd973b4b4f
6 changed files with 42 additions and 58 deletions
19
src/_includes/partials/card-blog.njk
Normal file
19
src/_includes/partials/card-blog.njk
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<custom-card clickable>
|
||||
<h2 slot="headline">
|
||||
<a href="{{ item.url | url }}">{{ item.data.title }}</a>
|
||||
</h2>
|
||||
<span slot="date"> {% include "partials/date.njk" %} </span>
|
||||
{%
|
||||
if
|
||||
item.data.tags.length > 1
|
||||
%}
|
||||
<div slot="tag" webc:nokeep>
|
||||
{% for tag in item.data.tags %}
|
||||
{% if tag != "posts" %}
|
||||
<span class="button post-tag">{{ tag }}</span>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div slot="content" webc:nokeep>{{ item.data.description | markdownFormat | safe }}</div>
|
||||
</custom-card>
|
||||
7
src/_includes/partials/card-tag.njk
Normal file
7
src/_includes/partials/card-tag.njk
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<custom-card clickable>
|
||||
<h2 slot="headline">
|
||||
<a href="{{ item.url | url }}">{{ item.data.title }}</a>
|
||||
</h2>
|
||||
<span slot="date"> {% include "partials/date.njk" %} </span>
|
||||
<p slot="content">{{ item.data.description }}</p>
|
||||
</custom-card>
|
||||
|
|
@ -14,30 +14,14 @@ layout: base
|
|||
<div class="region flow prose" style="--region-space-top: var(--space-xl-2xl)">{{ content | safe }}</div>
|
||||
|
||||
<custom-masonry layout="50-50">
|
||||
{% for item in pagination.items %}
|
||||
{% set definedDate = item.date %}
|
||||
|
||||
<custom-card clickable>
|
||||
<h2 slot="headline">
|
||||
<a href="{{ item.url | url }}">{{ item.data.title }}</a>
|
||||
</h2>
|
||||
<span slot="date"> {% include "partials/date.njk" %} </span>
|
||||
{%
|
||||
if
|
||||
item.data.tags.length > 1
|
||||
%}
|
||||
<div slot="tag" webc:nokeep>
|
||||
{% for tag in item.data.tags %}
|
||||
{% if tag != "posts" %}
|
||||
<span class="button post-tag">{{ tag }}</span>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div slot="content" webc:nokeep>{{ item.data.description | markdownFormat | safe }}</div>
|
||||
</custom-card>
|
||||
{% endfor %}
|
||||
</custom-masonry>
|
||||
{% asyncEach item in pagination.items %}
|
||||
{% set definedDate = item.date %}
|
||||
|
||||
{% include "partials/card-blog.njk" %}
|
||||
{% endeach %}
|
||||
|
||||
</custom-masonry>
|
||||
|
||||
<!-- set collection to paginate -->
|
||||
{% set collectionToPaginate = collections.posts %}
|
||||
|
|
|
|||
|
|
@ -28,28 +28,12 @@ layout: base
|
|||
<custom-masonry layout="50-50">
|
||||
<!-- loop posts -->
|
||||
{% set itemList = collections.allPosts %}
|
||||
{% for item in itemList.slice(0, 4) %}
|
||||
{% asyncEach item in itemList.slice(0, 4) %}
|
||||
{% set definedDate = item.date %}
|
||||
<custom-card clickable>
|
||||
<h3 slot="headline">
|
||||
<a href="{{ item.url | url }}">{{ item.data.title }}</a>
|
||||
</h3>
|
||||
<span slot="date"> {% include "partials/date.njk" %} </span>
|
||||
{%
|
||||
if
|
||||
item.data.tags.length > 1
|
||||
%}
|
||||
<div slot="tag" webc:nokeep>
|
||||
{% for tag in item.data.tags %}
|
||||
{% if tag != "posts" %}
|
||||
<span class="button post-tag">{{ tag }}</span>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div slot="content" webc:nokeep>{{ item.data.description | markdownFormat | safe }}</div>
|
||||
</custom-card>
|
||||
{% endfor %}
|
||||
|
||||
{% include "partials/card-blog.njk" %}
|
||||
|
||||
{% endeach %}
|
||||
</custom-masonry>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -12,13 +12,8 @@ eleventyComputed:
|
|||
<custom-masonry layout="50-50">
|
||||
{% set itemList = collections[tag] | reverse %}
|
||||
{% for item in itemList %}
|
||||
<custom-card clickable>
|
||||
<h2 slot="headline">
|
||||
<a href="{{ item.url | url }}">{{ item.data.title }}</a>
|
||||
</h2>
|
||||
<span slot="date"> {% include "partials/date.njk" %} </span>
|
||||
<p slot="content">{{ item.data.description }}</p>
|
||||
</custom-card>
|
||||
|
||||
{% include "partials/card-tag.njk" %}
|
||||
{% endfor %}
|
||||
</custom-masonry>
|
||||
|
||||
|
|
|
|||
|
|
@ -14,12 +14,7 @@ eleventyComputed:
|
|||
<custom-masonry layout="50-50">
|
||||
{% set itemlist = collections.posts %}
|
||||
{% for item in itemlist %}
|
||||
<custom-card clickable>
|
||||
<h2 slot="headline">
|
||||
<a href="{{ item.url | url }}">{{ item.data.title }}</a>
|
||||
</h2>
|
||||
<span slot="date"> {% include "partials/date.njk" %} </span>
|
||||
<p slot="content">{{ item.data.description }}</p>
|
||||
</custom-card>
|
||||
|
||||
{% include "partials/card-tag.njk" %}
|
||||
{% endfor %}
|
||||
</custom-masonry>
|
||||
|
|
|
|||
Loading…
Reference in a new issue