diff --git a/_includes/difficulty_stars.html b/_includes/difficulty_stars.html deleted file mode 100644 index 5595514..0000000 --- a/_includes/difficulty_stars.html +++ /dev/null @@ -1,30 +0,0 @@ -{%- if page.difficulty or recipe.difficulty -%} - {%- if page.difficulty -%} - {%- assign difficulty = page.difficulty -%} - {%- else -%} - {%- assign difficulty = recipe.difficulty -%} - {%- endif -%} - - {%- if difficulty < 6 and difficulty > 0 -%} - {%- comment -%} note: these characters are invalid unicode. they will only render properly on the webpage using the bundled "stars" font. {%- endcomment -%} - {%- assign empty_star ="" -%} - {%- assign full_star = "" -%} - {%- assign half_star = "" -%} - - {%- comment -%} build a string of empty stars {%- endcomment -%} - {%- assign stars = "" -%} - {%- for i in (1..5) -%} - {%- assign stars = stars | append: empty_star -%} - {%- endfor -%} - {%- comment -%} replace the first difficulty stars will filled stars {%- endcomment -%} - {%- assign page_stars_rounded = difficulty | floor -%} - {%- for i in (1..page_stars_rounded) -%} - {%- assign stars = stars | replace_first: empty_star, full_star -%} - {%- endfor -%} - {%- if difficulty != page_stars_rounded -%} - {%- comment -%} stars ends in .5 (or .1, or .9, or whatever) {%- endcomment -%} - {%- assign stars = stars | replace_first: empty_star, half_star -%} - {%- endif -%} - {{ stars }} - {%- endif -%} -{%- endif -%} diff --git a/_includes/recipes.html b/_includes/recipes.html index 8202efc..18d3bf3 100644 --- a/_includes/recipes.html +++ b/_includes/recipes.html @@ -4,7 +4,7 @@
By {{ recipe.author }} - - {% if recipe.difficulty %}Difficulty: {% include difficulty_stars.html %} - {%- endif %} + {% if recipe.difficulty %}Difficulty: {{ recipe.difficulty | to_stars }} - {%- endif %} {{ recipe.method | size }} steps {%- if recipe.time %} - {%- if recipe.time > 59 %} {{ recipe.time | divided_by: 60}}h {% endif -%} {% assign mins = recipe.time | modulo: 60 -%} diff --git a/_layouts/recipe.html b/_layouts/recipe.html index 0fd7c6e..ad079e6 100644 --- a/_layouts/recipe.html +++ b/_layouts/recipe.html @@ -31,7 +31,7 @@ custom_h1: true {%- endif -%} {%- endif -%} -
{% if page.difficulty %}Difficulty: {% include difficulty_stars.html %} - {% endif %}{{ page.method.size }} steps - Estimated cooking time: {{ time | default: "Not provided" }} {% if page.author %} - By {{ page.author }} {% endif %}
+{% if page.difficulty %}Difficulty: {{ page.difficulty | to_stars }} - {% endif %}{{ page.method.size }} steps - Estimated cooking time: {{ time | default: "Not provided" }} {% if page.author %} - By {{ page.author }} {% endif %}
{%- if applicable_subrecipes %}