Compare commits
5 commits
b41d0124b7
...
29140453e8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
29140453e8 | ||
|
|
d786f02c9a | ||
|
|
6f508915f3 | ||
|
|
8ffa99f8ac | ||
|
|
ca111b50ae |
|
|
@ -1,4 +1,4 @@
|
||||||
import { Recipe, Parser, getImageURL } from '@cooklang/cooklang-ts';
|
import { Parser } from '@cooklang/cooklang';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
|
||||||
let config = {}
|
let config = {}
|
||||||
|
|
@ -10,66 +10,65 @@ export default function (eleventyConfig, pluginOptions) {
|
||||||
|
|
||||||
const cookExtension = {
|
const cookExtension = {
|
||||||
getData: async function (inputPath) {
|
getData: async function (inputPath) {
|
||||||
const content = fs.readFileSync(inputPath, "utf-8").split("---")[2];
|
const content = fs.readFileSync(inputPath, "utf-8");
|
||||||
|
|
||||||
// Parse recipe using cooklang-ts
|
// Parse recipe using cooklang
|
||||||
const recipe = new Recipe(content);
|
const parser = new Parser();
|
||||||
|
const recipe = parser.parse(content);
|
||||||
|
|
||||||
let steps = [];
|
let sections = [];
|
||||||
let ingredients = [];
|
let ingredients = recipe.recipe.ingredients || [];
|
||||||
let cookware = [];
|
let cookware = recipe.recipe.cookware || [];
|
||||||
const recipeTags = recipe?.metadata?.tags?.split(",") || [];
|
let timers = recipe.recipe.timers || [];
|
||||||
|
|
||||||
function getStepTokenHTML(token) {
|
const metadata = recipe?.metadata || [];
|
||||||
const { quantity, units, name, value, type } = token;
|
|
||||||
let tagContent = "";
|
|
||||||
|
|
||||||
if (token.type == "timer") {
|
recipe.recipe.sections.forEach((section, i) => {
|
||||||
tagContent = `${quantity} ${units}`;
|
if (!sections[i]) sections[i] = {};
|
||||||
} else {
|
if (section.name != null) {
|
||||||
tagContent = token.name || token.value;
|
sections[i].title = { type: "title", content: section.name };
|
||||||
}
|
}
|
||||||
|
section.content.forEach((step, stepI) => {
|
||||||
if (config.outputHtml) {
|
if (!sections[i].content) sections[i].content = [];
|
||||||
return `<span class="recipe--${type}">${tagContent}</span>`;
|
let steps = [];
|
||||||
} else {
|
|
||||||
return `${tagContent}`;
|
step.value.items.forEach(item => {
|
||||||
}
|
if (item.type === 'text') {
|
||||||
}
|
steps.push({ type: "text", content: item.value });
|
||||||
|
} else if (item.type === 'ingredient') {
|
||||||
recipe.steps.forEach((stepTokens, i) => {
|
let ingredient = recipe.recipe.ingredients[item.index];
|
||||||
if (!steps[i]) steps[i] = [];
|
steps.push({ type: "ingredient", content: ingredient.name, ...ingredient });
|
||||||
|
} else if (item.type === 'cookware') {
|
||||||
stepTokens.forEach((token) => {
|
let cookware = recipe.recipe.cookware[item.index];
|
||||||
if (token.type == "ingredient") {
|
steps.push({ type: "cookware", content: cookware.name, ...cookware});
|
||||||
let { name, quantity, units } = token;
|
} else if (item.type === 'timer') {
|
||||||
|
let timer = recipe.recipe.timers[item.index];
|
||||||
if (
|
steps.push({ type: "timer", content: timer.quantity.value.value.value + " " + timer.quantity.unit, ...timer });
|
||||||
config.limitIngredientDecimals &&
|
} else if (item.type === 'inlineQuantity') {
|
||||||
!isNaN(config.limitIngredientDecimals)
|
let inlineQuantity = recipe.recipe.inline_quantities[item.index];
|
||||||
) {
|
steps.push({ type: "inlineQuantity", content: inlineQuantity.value.value.value + " " + inlineQuantity.unit, ...inlineQuantity });
|
||||||
const decimalPlaces = parseInt(config.limitIngredientDecimals);
|
} else {
|
||||||
// Parsing float twice removes any trailing 0s
|
console.log("Unknown type: ", item.type)
|
||||||
quantity = parseFloat(parseFloat(quantity).toFixed(decimalPlaces));
|
|
||||||
}
|
}
|
||||||
ingredients.push({ name, quantity, units });
|
});
|
||||||
}
|
sections[i].content.push(steps);
|
||||||
|
|
||||||
if (token.type == "cookware") {
|
|
||||||
const { name } = token;
|
|
||||||
cookware.push({ name });
|
|
||||||
}
|
|
||||||
|
|
||||||
steps[i].push(getStepTokenHTML(token));
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// const {value, error} = parser.parse_render(
|
||||||
|
// content
|
||||||
|
// );
|
||||||
|
// const html = value;
|
||||||
|
|
||||||
|
// TODO Sections name in ingredients list
|
||||||
|
|
||||||
return {
|
return {
|
||||||
recipe,
|
recipe,
|
||||||
steps,
|
sections,
|
||||||
ingredients,
|
ingredients,
|
||||||
cookware,
|
cookware,
|
||||||
recipeTags,
|
timers,
|
||||||
|
metadata
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
compile: async (inputContent) => {
|
compile: async (inputContent) => {
|
||||||
|
|
|
||||||
1960
package-lock.json
generated
1960
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -16,14 +16,14 @@
|
||||||
"author": "Maël Brunet",
|
"author": "Maël Brunet",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@11ty/eleventy": "^3.0.0",
|
"@11ty/eleventy": "^3.1.2",
|
||||||
"@11ty/eleventy-img": "^6.0.1",
|
"@11ty/eleventy-img": "^6.0.4",
|
||||||
"@11ty/eleventy-navigation": "^1.0.4",
|
"@11ty/eleventy-navigation": "^1.0.5",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"sass": "^1.86.3"
|
"sass": "^1.86.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cooklang/cooklang-ts": "^1.2.7",
|
"@cooklang/cooklang": "^0.17.2",
|
||||||
"alpinejs": "^2.8.2",
|
"alpinejs": "^2.8.2",
|
||||||
"decap-cms-app": "^3.6.2",
|
"decap-cms-app": "^3.6.2",
|
||||||
"decap-server": "^3.2.0"
|
"decap-server": "^3.2.0"
|
||||||
|
|
|
||||||
|
|
@ -13,15 +13,29 @@
|
||||||
</div>
|
</div>
|
||||||
{% set ingredientsArray = [] %}
|
{% set ingredientsArray = [] %}
|
||||||
{% for ingredient in ingredients %}
|
{% for ingredient in ingredients %}
|
||||||
{% set value = [ingredient.quantity, ingredient.units, " ", ingredient.name] | join %}
|
{% set notes = "" %}
|
||||||
|
{% if ingredient.note %}
|
||||||
|
{% set notes = [" (", ingredient.note, ")"] | join %}
|
||||||
|
{% endif %}
|
||||||
|
{% set value = [ingredient.quantity.value.value.value, ingredient.quantity.unit, " ", ingredient.name, notes] | join %}
|
||||||
{% set ingredientsArray = (ingredientsArray.push(value), ingredientsArray) %}
|
{% set ingredientsArray = (ingredientsArray.push(value), ingredientsArray) %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<div class="c-recipe__ingredients-wrapper" x-data='{currentServings: {{ servings if not servings == "" else false }}, ingredients: decodeURI("{{ ingredientsArray | arrayToString }}").split("£") }'>
|
<div class="c-recipe__ingredients-wrapper" x-data='{currentServings: {{ servings if not servings == "" else false }}, ingredients: decodeURI("{{ ingredientsArray | arrayToString }}").split("£") }'>
|
||||||
<!-- <div class="c-recipe__ingredients-wrapper" x-data='{currentServings: {{ servings if not servings == "" else false }}, ingredients: decodeURI("{{ ingredients | arrayToString }}").split("£") }'> -->
|
|
||||||
{% if time or not servings == "" %}
|
{% if time or not servings == "" %}
|
||||||
<div class="c-recipe__additional-info">
|
<div class="c-recipe__additional-info">
|
||||||
{% if time %}
|
{% if time %}
|
||||||
<p>{% include "icons/time.svg" %}{{ time }}</p>
|
{% if time.prep %}
|
||||||
|
<p>{% include "icons/time.svg" %}Prep: {{ time.prep }}</p>
|
||||||
|
{% endif %}
|
||||||
|
{% if time.cook %}
|
||||||
|
<p>{% include "icons/time.svg" %}Cook: {{ time.cook }}</p>
|
||||||
|
{% endif %}
|
||||||
|
{% if not time.cook and not time.prep %}
|
||||||
|
<p>{% include "icons/time.svg" %}Total: {{ time }}</p>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% if duration %}
|
||||||
|
<p>{% include "icons/time.svg" %}Total: {{ duration }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not servings == "" %}
|
{% if not servings == "" %}
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -62,38 +76,39 @@
|
||||||
<h3>Cookware</h3>
|
<h3>Cookware</h3>
|
||||||
<ul class="c-recipe__ingredients-list">
|
<ul class="c-recipe__ingredients-list">
|
||||||
{% for ingredient in cookware %}
|
{% for ingredient in cookware %}
|
||||||
<li><label><input type="checkbox"><span>{{ingredient.quantity}}{{ ingredient.units}} {{ ingredient.name }}</span></label></li>
|
{% set notes = "" %}
|
||||||
|
{% if ingredient.note %}
|
||||||
|
{% set notes = [" (", ingredient.note, ")"] | join %}
|
||||||
|
{% endif %}
|
||||||
|
<li><label><input type="checkbox"><span>{{ingredient.quantity}}{{ ingredient.units}} {{ ingredient.name }} {{notes}}</span></label></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="c-recipe__instructions-wrapper u-free-text">
|
<div class="c-recipe__instructions-wrapper u-free-text">
|
||||||
|
{% for section in sections %}
|
||||||
|
{% if section.title %}
|
||||||
|
<h3>{{ section.title.content }}</h3>
|
||||||
|
{% endif %}
|
||||||
|
<ol>
|
||||||
|
{% for steps in section.content %}
|
||||||
|
<li>
|
||||||
|
{% for items in steps %}{% if items.type == "ingredient" %}{% if items.reference %}<a href="../{{ items.reference.components | join("/") }}/{{ items.reference.name }}" target="_blank">{{items.content}}</a>{% else %}{{items.content}}{% endif %} ({{items.quantity.value.value.value}}{% if items.quantity.unit %} {{items.quantity.unit}}{% endif %}){% else %}{{items.content}}{% endif %}{% endfor %}
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ol>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
{% set notesArr = notes.split('|') %}
|
{% set notesArr = notes.split('|') %}
|
||||||
{% if notesArr.length > 1 %}
|
{% if notesArr.length > 1 %}
|
||||||
|
<h3>Notes</h3>
|
||||||
<aside class="alert">
|
<aside class="alert">
|
||||||
{%- for note in notesArr -%}
|
{%- for note in notesArr -%}
|
||||||
{{ note | safe }}<br>
|
{{ note | safe }}<br>
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
</aside>
|
</aside>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<!-- {% if notes.length > 1 %}
|
|
||||||
<aside class="alert">
|
|
||||||
{%- for note in notes -%}
|
|
||||||
{{ note | safe }}
|
|
||||||
{%- endfor -%}
|
|
||||||
</aside>
|
|
||||||
{% endif %} -->
|
|
||||||
<!-- {{ content | safe }} -->
|
|
||||||
{% for step in steps %}
|
|
||||||
<p>
|
|
||||||
{% for stepDetail in step %}{{ stepDetail | safe }}{% endfor %}
|
|
||||||
</p>
|
|
||||||
{% endfor %}
|
|
||||||
<!-- {% for step in steps %}
|
|
||||||
<p>
|
|
||||||
{% for stepDetail in step %}{{ stepDetail.value | safe }}{{ stepDetail.name | safe }}{% endfor %}
|
|
||||||
</p>
|
|
||||||
{% endfor %} -->
|
|
||||||
{% if source %}
|
{% if source %}
|
||||||
<p><a href="{{ source }}" target="_blank" rel="noopener">Source</a></p>
|
<p><a href="{{ source }}" target="_blank" rel="noopener">Source</a></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
||||||
20
src/recipes-cook/sauces/Hollandaise.cook
Normal file
20
src/recipes-cook/sauces/Hollandaise.cook
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
title: Hollandaise
|
||||||
|
image: https://ichef.bbci.co.uk/food/ic/food_16x9_1600/recipes/richchocolatebrownie_1933_16x9.jpg
|
||||||
|
tags:
|
||||||
|
- Sauce
|
||||||
|
time: 5 minutes
|
||||||
|
servings: 4
|
||||||
|
source: https://www.bbc.co.uk/food/recipes/richchocolatebrownie_1933/
|
||||||
|
notes: I much prefer a flatbread to a crunchy tostada or taco so that's what I have this with. | I like [these Deli Kitchen ones](https://mydelikitchen.co.uk/products/4-greek-style-flatbreads/).
|
||||||
|
---
|
||||||
|
|
||||||
|
= Dough
|
||||||
|
|
||||||
|
Heat the oven to 190C/170C Fan/Gas 5. Line a #20x30cm baking tin{} with baking paper.
|
||||||
|
|
||||||
|
Gently melt the @butter{225%g}(preferably unsalted) and the @caster sugar{450%g} together in a #large pan{}. Once melted, take off the heat and add the @chocolate{140%g}(dark, broken into pieces). Stir until melted.
|
||||||
|
|
||||||
|
Beat in the @eggs{5}(free-range medium eggs), then stir in the @flour{110%g}(plain) and the @cocoa powder{55%g}.
|
||||||
|
|
||||||
|
Mix @onion{1}(peeled and finely chopped) and @garlic{2%cloves}(peeled and minced) into paste.
|
||||||
|
|
@ -7,7 +7,10 @@ tags:
|
||||||
- Vegetarian 🌿
|
- Vegetarian 🌿
|
||||||
- Sharable
|
- Sharable
|
||||||
- Favourite ⭐
|
- Favourite ⭐
|
||||||
time: 45 min
|
duration: 45 minutes
|
||||||
|
time:
|
||||||
|
prep: 10 minutes
|
||||||
|
cook: 35 minutes
|
||||||
servings: 4
|
servings: 4
|
||||||
source: https://www.bbc.co.uk/food/recipes/richchocolatebrownie_1933/
|
source: https://www.bbc.co.uk/food/recipes/richchocolatebrownie_1933/
|
||||||
notes: I much prefer a flatbread to a crunchy tostada or taco so that's what I have this with. | I like [these Deli Kitchen ones](https://mydelikitchen.co.uk/products/4-greek-style-flatbreads/).
|
notes: I much prefer a flatbread to a crunchy tostada or taco so that's what I have this with. | I like [these Deli Kitchen ones](https://mydelikitchen.co.uk/products/4-greek-style-flatbreads/).
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue