Compare commits

..

No commits in common. "902af258a313aeed2098f507ab2615736c0c7fdf" and "96fcad7f7d9254d7adcbd7c0576b98b90cbfb91d" have entirely different histories.

4 changed files with 6 additions and 38 deletions

View file

@ -32,6 +32,7 @@ Here's an example recipe, which could be saved to `_recipes/chocolate_cake.yml`:
---
name: Chocolate cake
author: Jane Crocker
layout: recipe
ingredients:
- [1, egg, null]
@ -47,29 +48,20 @@ time: 240
```
- `name` (string) - The displayed name of the recipe. Does not appear in the URL.
- `author` (string, optional) - The author of the recipe.
- `layout` (string) - The template to use; should always be `recipe`.
- `ingredients` (list) - Each entry in `ingredients` consists of an amount, ingredient name, and unit terminology. `[2, flour, cups]` is displayed as `2 cups of flour`, while `[1, egg, null]` is displayed as `1 egg`. The third field is optional - `[1, egg, null]` is the same as `[1, egg]`.
- `method` (list) - A list of steps undertaken to create the recipe, written in plain English. Or whatever language you prefer.
- `time` (string, optional) - The time it takes to make the recipe in minutes.
The recipe's file name isn't important, but it's good practice to make it something obvious, like `chocolate_cake.md` and not `strawberry_pie.md`.
The recipe files are standard YAML. Every recipe **must** begin and end with three dashes [to ensure that Jekyll processes it](https://jekyllrb.com/docs/front-matter/).
Good:
```yaml
---
name: Example
---
```
Bad:
```yaml
name: Example
```
The recipe files are standard YAML. The extension should always be `.md` - other extensions will cause issues with subrecipes (see #1).
### Subrecipes
Subrecipes behave a little differently to regular recipes:
- They don't show up on the home page
- The `time` tag is not supported
- `layout` should be `subrecipe`
Subrecipes have a tag that regular recipes do not - the `parents` tag. This is a list of recipes that the subrecipe should be included in. For example:
```yaml

View file

@ -1,13 +1,3 @@
defaults:
- scope:
path: "_recipes"
values:
layout: "recipe"
- scope:
path: "_subrecipes"
values:
layout: "subrecipe"
collections:
# note: subrecipes MUST come before recipes, otherwise subrecipe.output will be empty with no error message given. thanks to https://github.com/jekyll/jekyll/issues/5371#issuecomment-247951926
subrecipes:

View file

@ -5,6 +5,6 @@
<{{tag}}>Ingredients</{{tag}}>
<ul>
{% for item in page.ingredients -%}
<li>{{ item[0] }} {%- if item[2] %} {{ item[2] }} of {% endif %} {{ item[1] }}</li>
<li>{{ item[0] }} {% if item[2] %} {{ item[2] }} of {% endif %} {{ item[1] }}</li>
{% endfor -%}
</ul>

View file

@ -14,21 +14,7 @@ layout: default
{%- endfor -%}
<h1>{{ page.name }}</h1>
{%- if page.time -%}
{%- if page.time > 59 %}
{%- assign hours = page.time | divided_by: 60 -%}
{%- assign minutes = page.time | modulo: 60 -%}
{%- assign time = hours | append: " hour" -%}
{%- if hours > 1 %}{% assign time = time | append: "s" %}{% endif -%}
{%- if minutes > 0 -%}
{%- assign time = time | append: " " | append: minutes | append: " minute" -%}
{%- if minutes > 1 %}{% assign time = time | append: "s" %}{% endif -%}
{%- endif -%}
{%- else -%}
{%- assign time = page.time %}
{%- endif -%}
{%- endif -%}
<p class='subtle'> {{ page.method.size }} steps - Estimated cooking time: {{ time | default: "Not provided" }} {% if page.author %} - By {{ page.author }} {% endif %}</p>
<p class='subtle'> {{ page.method.size }} steps - Estimated cooking time: {{ page.time | default: "Not provided" }} {% if page.author %} - By {{ page.author }} {% endif %}</p>
{%- if applicable_subrecipes %}
<h2> Subrecipes </h2>
{% for subrecipe in site.subrecipes -%}