From 096e506c1fd089686e5fe7b6cefa2b08b4cda070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Brunet?= Date: Tue, 18 May 2021 00:17:47 +0200 Subject: [PATCH] Fix image paths --- .eleventy.js | 2 +- src/_includes/layouts/home.njk | 2 +- src/_includes/layouts/recipe.njk | 2 +- src/_includes/layouts/recipes-list.njk | 2 +- src/admin/config.yml | 10 +++++++-- src/recipes/coconut-lentil-soup.md | 1 + src/recipes/simple-brownies.md | 30 ++++++++++++++++++++++++++ 7 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 src/recipes/simple-brownies.md diff --git a/.eleventy.js b/.eleventy.js index 62d2510..6c6a490 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -69,7 +69,7 @@ module.exports = config => { /* Shortcodes */ const imageShortcode = async (src, className, alt, sizes) => { - let metadata = await Image(`./src/recipe-images/${src}.jpg`, { + let metadata = await Image(`./src/${src}`, { widths: [600, 1500, 3000], formats: ['webp', 'jpeg'], outputDir: './dist/recipe-images', diff --git a/src/_includes/layouts/home.njk b/src/_includes/layouts/home.njk index 398567c..530c417 100644 --- a/src/_includes/layouts/home.njk +++ b/src/_includes/layouts/home.njk @@ -28,7 +28,7 @@ bodyClass: c-home {% set favouriteRecipes = collections["Favourite ⭐"] | limit(4) %} {% for recipe in favouriteRecipes %} - {% recipeimage recipe.fileSlug, "c-card__image", recipe.data.title, "(min-width: 1150px) 25vw, (min-width: 850px) 33vw, (min-width: 550px) 50vw, 100vw" %} + {% recipeimage recipe.data.image, "c-card__image", recipe.data.title, "(min-width: 1150px) 25vw, (min-width: 850px) 33vw, (min-width: 550px) 50vw, 100vw" %}
{% for tag in recipe.data.tags %} diff --git a/src/_includes/layouts/recipe.njk b/src/_includes/layouts/recipe.njk index 9bf01ff..42c6818 100644 --- a/src/_includes/layouts/recipe.njk +++ b/src/_includes/layouts/recipe.njk @@ -1,7 +1,7 @@ {% extends 'layouts/base.njk' %} {% block content %} - {% recipeimage page.fileSlug, "c-recipe__header-image", title, "100vw" %} + {% recipeimage image, "c-recipe__header-image", title, "100vw" %}

{{ title }}

diff --git a/src/_includes/layouts/recipes-list.njk b/src/_includes/layouts/recipes-list.njk index a370141..9eb7fa9 100644 --- a/src/_includes/layouts/recipes-list.njk +++ b/src/_includes/layouts/recipes-list.njk @@ -15,7 +15,7 @@ {% for recipe in collections.recipes %} {% if not selectedTag or selectedTag in recipe.data.tags %} {# If we don't have a selectedTag, we are on the all recipes page #} - {% recipeimage recipe.fileSlug, "c-card__image", recipe.data.title, "(min-width: 1150px) 25vw, (min-width: 850px) 33vw, (min-width: 550px) 50vw, 100vw" %} + {% recipeimage recipe.data.image, "c-card__image", recipe.data.title, "(min-width: 1150px) 25vw, (min-width: 850px) 33vw, (min-width: 550px) 50vw, 100vw" %}
{% for tag in recipe.data.tags %} diff --git a/src/admin/config.yml b/src/admin/config.yml index df62e0f..25101d2 100644 --- a/src/admin/config.yml +++ b/src/admin/config.yml @@ -11,7 +11,12 @@ collections: create: true fields: - {label: "Title", name: "title", widget: "string"} - - {label: "Tags", name: "tags", widget: "list"} + - {label: "Image", name: "image", widget: "image"} + - label: "Tags" + name: "tags" + widget: "list" + summary: "{{fields.tag}}" + field: {label: "Tag", name: "tag", widget: string} - {label: "Preparation time", name: "time", widget: "string"} - {label: "Number of servings", name: "servings", widget: "number"} - {label: "Source of the recipe", name: "sourceLabel", widget: "string"} @@ -19,4 +24,5 @@ collections: - label: "Ingredients" name: "ingredients" widget: "list" - field: {label: Ingredient, name: ingredient, widget: string} \ No newline at end of file + summary: "{{fields.ingredient}}" + field: {label: "Ingredient", name: "ingredient", widget: string} \ No newline at end of file diff --git a/src/recipes/coconut-lentil-soup.md b/src/recipes/coconut-lentil-soup.md index 688e090..deaf3e3 100644 --- a/src/recipes/coconut-lentil-soup.md +++ b/src/recipes/coconut-lentil-soup.md @@ -1,5 +1,6 @@ --- title: Coconut lentil soup +image: /recipe-images/coconut-lentil-soup.jpg tags: - Soup 🥣 - Vegan 🌱 diff --git a/src/recipes/simple-brownies.md b/src/recipes/simple-brownies.md new file mode 100644 index 0000000..b25275c --- /dev/null +++ b/src/recipes/simple-brownies.md @@ -0,0 +1,30 @@ +--- +title: Simple brownies +image: /recipe-images/brownies.jpg +tags: + - Sweet 🍬 + - Cake 🍰 + - Sharable + - Favourite ⭐ +time: 45 min +sourceLabel: BBC good food +sourceURL: https://www.bbc.co.uk/food/recipes/richchocolatebrownie_1933/ +servings: 4 +ingredients: + - 225g butter (preferably unsalted) + - 450g caster sugar + - 140g dark chocolate broken into pieces + - 5 free-range medium eggs + - 110g plain flour + - 55g cocoa powder +--- + +Heat the oven to 190C/170C Fan/Gas 5. Line a 20x30cm baking tin with baking paper. + +Gently melt the butter and the sugar together in a large pan. Once melted, take off the heat and add the chocolate. Stir until melted. + +Beat in the eggs, then stir in the flour and the cocoa powder. + +Pour the brownie batter into the prepared tin and bake for 30–35 minutes, or until the top of the brownie is just firm but there is still a gentle wobble in the middle. + +Take out of the oven and leave to cool in the tin. Cut the brownies into 5cm squares when only just warm, or completely cool. \ No newline at end of file