Skip to content

Commit

Permalink
add horizontal card and postslist layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
hjonin committed Jun 19, 2023
1 parent 0cd49d6 commit d1edc1d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
22 changes: 22 additions & 0 deletions _includes/components/card-horizontal.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{# Mandatory variable `card { url: string, title: string, description: string, tags: string[], date: string, imagePath: string, imageAlt: string }` to make it work #}
<div class="fr-card fr-enlarge-link fr-card--horizontal-tier">
<div class="fr-card__body">
<div class="fr-card__content">
<h3 class="fr-card__title"><a href="{{ card.url | locale_url }}">{{ card.title }}</a></h3>
<p class="fr-card__desc">{{ card.description }}</p>
<div class="fr-card__start">
{% set tags = card.tags %}
{% include "components/taggroup-disabled.njk" %}
<p class="fr-card__detail fr-icon-time-fill">
<time class="postlist-date"
datetime="{{ card.date | htmlDateString }}">{{ card.date | readableDate("LLLL yyyy") }}</time>
</p>
</div>
</div>
</div>
{% if card.imagePath %}
<div class="fr-card__header">
<div class="fr-card__img">{% image card.imagePath, card.imageAlt %}</div>
</div>
{% endif %}
</div>
17 changes: 17 additions & 0 deletions _includes/postslist-horizontal.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{# Mandatory variable `postslist: CollectionItem[]` to make it work #}
<div class="fr-grid-row fr-grid-row--gutters fr-mb-3w">
{% asyncAll post in postslist %}
<div class="fr-col-12">
{% set card = {
url: post.url,
title: post.data.title,
description: post.data.description,
tags: post.data.tags,
date: post.date,
imagePath: post.data.image.path,
imageAlt: post.data.image.alt
} %}
{% include "components/card-horizontal.njk" %}
</div>
{% endall %}
</div>
2 changes: 1 addition & 1 deletion content/fr/blog/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ eleventyNavigation:
</div>
<div class="fr-col-12 fr-col-md-9">
{% set postslist = pagination.items %}
{% include "postslist.njk" %}
{% include "postslist-horizontal.njk" %}
{% include "components/pagination.njk" %}
</div>
</div>
Expand Down

0 comments on commit d1edc1d

Please sign in to comment.