diff --git a/CHANGELOG.md b/CHANGELOG.md index f1c4301..5d9be62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Recipe Changelog +## 1.4.4 - 2023.02.23 +### Fixed +* Fixed an issue where the Nutritional Information display didn't take into account the number of servings ([#66](https://github.com/nystudio107/craft-recipe/issues/66)) + ## 1.4.3 - 2023.02.22 ### Fixed * Fix API Requests ([#65](https://github.com/nystudio107/craft-recipe/pull/65)) diff --git a/composer.json b/composer.json index 2da43b4..4c4124a 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "nystudio107/craft-recipe", "description": "A comprehensive recipe FieldType for Craft CMS that includes metric/imperial conversion, portion calculation, and JSON-LD microdata support", "type": "craft-plugin", - "version": "1.4.3", + "version": "1.4.4", "keywords": [ "craft", "cms", diff --git a/src/templates/recipe-nutrition-facts.twig b/src/templates/recipe-nutrition-facts.twig index 81caae1..4c8e13c 100644 --- a/src/templates/recipe-nutrition-facts.twig +++ b/src/templates/recipe-nutrition-facts.twig @@ -77,6 +77,7 @@ .recipe-plugin-nutrition-label table tr.recipe-plugin-thick-row td { border-top: 4px solid #000; } + .recipe-plugin-nutrition-label table tr.recipe-plugin-micros li:nth-child(1n+0) { padding-right: 8px; } @@ -92,6 +93,7 @@ .recipe-plugin-nutrition-label table tr.recipe-plugin-micros li { border-top: 1px solid #000; } + .recipe-plugin-nutrition-label table tr.recipe-plugin-micros li { box-sizing: border-box; float: left; @@ -106,11 +108,20 @@ } -{% macro percentage(numerator, denomoninator) %} - {% set result = (numerator * 100) / denomoninator %} +{% macro percentage(numerator, denomoninator, serves = 1) %} + {% if serves is empty %} + {% set serves = 1 %} + {% endif %} + {% set result = ((numerator / serves) * 100) / denomoninator %} {{ result | number_format(0) ~ '%' }} {% endmacro %} -{% from _self import percentage %} +{% from _self import percentage %} + +{% macro servesValue(value, serves) %} + {% set result = value / serves %} + {{- result | number_format(0) -}} +{% endmacro %} +{% from _self import servesValue %}