Compare commits

...

5 commits

Author SHA1 Message Date
902af258a3
removed an extraneous space in the html output
All checks were successful
continuous-integration/drone/push Build is passing
it is 7:30am and i haven't slept yet what am i doing with my life
2020-03-01 07:31:44 +10:00
2a631e46fd
format time as 'x hours, y minutes' instead of just 'page.time' 2020-03-01 07:28:40 +10:00
b527bbf48e
add link to front matter docs 2020-03-01 07:16:16 +10:00
9e5299377a
add sub/recipe layouts to _config.yml to avoid repititious repitition 2020-03-01 07:14:38 +10:00
44cfec0496
update readme to reflect issue closure 2020-03-01 07:07:20 +10:00
4 changed files with 38 additions and 6 deletions

View file

@ -32,7 +32,6 @@ 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]
@ -48,20 +47,29 @@ 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. The extension should always be `.md` - other extensions will cause issues with subrecipes (see #1).
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
```
### 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,3 +1,13 @@
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,7 +14,21 @@ layout: default
{%- endfor -%}
<h1>{{ page.name }}</h1>
<p class='subtle'> {{ page.method.size }} steps - Estimated cooking time: {{ page.time | default: "Not provided" }} {% if page.author %} - By {{ page.author }} {% endif %}</p>
{%- 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>
{%- if applicable_subrecipes %}
<h2> Subrecipes </h2>
{% for subrecipe in site.subrecipes -%}