From 2a631e46fd2e5c3a8a73c3366e847cd8f796a99c Mon Sep 17 00:00:00 2001 From: Lynne Date: Sun, 1 Mar 2020 07:28:40 +1000 Subject: [PATCH] format time as 'x hours, y minutes' instead of just 'page.time' --- _layouts/recipe.html | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/_layouts/recipe.html b/_layouts/recipe.html index 756c2a2..7c8addd 100644 --- a/_layouts/recipe.html +++ b/_layouts/recipe.html @@ -14,7 +14,21 @@ layout: default {%- endfor -%}

{{ page.name }}

-

{{ page.method.size }} steps - Estimated cooking time: {{ page.time | default: "Not provided" }} {% if page.author %} - By {{ page.author }} {% endif %}

+{%- 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 -%} +

{{ page.method.size }} steps - Estimated cooking time: {{ time | default: "Not provided" }} {% if page.author %} - By {{ page.author }} {% endif %}

{%- if applicable_subrecipes %}

Subrecipes

{% for subrecipe in site.subrecipes -%}