Workaround to allow commas inside ingredients

This commit is contained in:
Maël Brunet 2021-05-20 00:42:14 +02:00
parent 9b888a03b3
commit 31d3801b52
3 changed files with 5 additions and 4 deletions

View file

@ -61,8 +61,9 @@ module.exports = config => {
return value.toLowerCase();
});
config.addFilter('asArray', function(value) {
return value ? [...value] : []
// This workaround is needed so we can transform it back into an array with Alpine (we can't split on "," as it can be included within the items)
config.addFilter('arrayToString', function(value) {
return value.join('£');
});
/* Shortcodes */

View file

@ -11,7 +11,7 @@
<a class="c-tags__tag" href="/tags/{{ tag | noEmoji | slug }}">{{ tag }}</a>
{% endfor %}
</div>
<div class="c-recipe__ingredients-wrapper" x-data="{currentServings: {{ servings }}, ingredients: '{{ ingredients }}'.split(',') }">
<div class="c-recipe__ingredients-wrapper" x-data="{currentServings: {{ servings }}, ingredients: '{{ ingredients | arrayToString }}'.split('£') }">
{% if time or servings %}
<div class="c-recipe__additional-info">
{% if time %}

View file

@ -11,7 +11,7 @@ sourceLabel: BBC good food
sourceURL: https://www.bbcgoodfood.com/recipes/courgette-lemon-risotto/
ingredients:
- 50g butter
- 1 onion finely chopped
- 1 onion, finely chopped
- 1 large garlic clove crushed
- 180g risotto rice
- 1 vegetable stock cube