format time as 'x hours, y minutes' instead of just 'page.time'

This commit is contained in:
Lynne Megido 2020-03-01 07:28:40 +10:00
parent b527bbf48e
commit 2a631e46fd
Signed by: lynnesbian
GPG key ID: F0A184B5213D9F90

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