Make highlighted tag generic + editable

This commit is contained in:
Maël Brunet 2021-06-06 09:44:05 +02:00
parent 9528e72dfc
commit e71b7b6e89
4 changed files with 16 additions and 6 deletions

View file

@ -18,12 +18,12 @@ bodyClass: c-home
</div>
</section>
{% if collections["Favourite ⭐"] %}
{% if collections[highlightedTag] %}
<section class="u-bgc-grey-100">
<div class="l-container">
<h2 class="u-mb-large">{{ favouriteRecipes }}</h2>
<h2 class="u-mb-large">{{ highlightedTitle }}</h2>
<div class="c-card__wrapper">
{% set favouriteRecipes = collections["Favourite ⭐"] | limit(4) %}
{% set favouriteRecipes = collections[highlightedTag] | limit(4) %}
{% for recipe in favouriteRecipes %}
<div class="c-card">
{% recipeimage recipe.data.image, "c-card__image", recipe.data.title, "(min-width: 1150px) 25vw, (min-width: 850px) 33vw, (min-width: 550px) 50vw, 100vw" %}
@ -46,6 +46,7 @@ bodyClass: c-home
</div>
{% endfor %}
</div>
<a href="/tags/{{ highlightedTag | noEmoji | slug }}" class="c-home__highlighted-tag-link">{{ highlightedLinkText }}</a>
</div>
</section>
{% endif %}

View file

@ -62,8 +62,9 @@ collections:
- {label: "Title", name: "title", widget: "string"}
- {label: "Add author to title", name: "authorInTitle", widget: "boolean"}
- {label: "Meta title", name: "metaTitle", widget: "string", hint: "used for SEO"}
- {label: "Favourite recipes label", name: "favouriteRecipes", widget: "string"}
- {label: "Random recipe label", name: "randomRecipe", widget: "string"}
- {label: "Highlighted tag", name: "highlightedTag", widget: "string", hint: "This must correspond to one of your recipes' tag !"}
- {label: "Title of the highlighted tag section (label)", name: "highlightedTitle", widget: "string"}
- {label: "Link text to all recipes with the highlighted tag (label)", name: "highlightedLinkText", widget: "string"}
- name: "recipes"
label: "All recipes page"
file: "src/recipes.md"

View file

@ -3,5 +3,7 @@ layout: layouts/home.njk
title: This cookbook belongs to
authorInTitle: true
metaTitle: Home
favouriteRecipes: Some of my favourite recipes
highlightedTag: Favourite ⭐
highlightedTitle: Some of my favourite recipes
highlightedLinkText: All my favourite recipes
---

View file

@ -16,4 +16,10 @@
padding: 2px 12px;
text-decoration: underline dashed;
text-underline-offset: 6px;
}
.c-home__highlighted-tag-link {
margin-top: 30px;
display: block;
text-align: center;
}