diff --git a/_config.yml b/_config.yml index 9141378..ff71148 100644 --- a/_config.yml +++ b/_config.yml @@ -15,3 +15,5 @@ collections: recipes: output: true permalink: "/:collection/:name" + +recipes_per_page: 15 diff --git a/_includes/difficulty_stars.html b/_includes/difficulty_stars.html index 6de745f..5595514 100644 --- a/_includes/difficulty_stars.html +++ b/_includes/difficulty_stars.html @@ -1,22 +1,30 @@ -{%- if page.difficulty < 6 and page.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 difficulty = "" -%} - {%- for i in (1..5) -%} - {%- assign difficulty = difficulty | append: empty_star -%} - {%- endfor -%} - {%- comment -%} replace the first page.difficulty stars will filled stars {%- endcomment -%} - {%- assign page_difficulty_rounded = page.difficulty | floor -%} - {%- for i in (1..page_difficulty_rounded) -%} - {%- assign difficulty = difficulty | replace_first: empty_star, full_star -%} - {%- endfor -%} - {%- if page.difficulty != page_difficulty_rounded -%} - {%- comment -%} difficulty ends in .5 (or .1, or .9, or whatever) {%- endcomment -%} - {%- assign difficulty = difficulty | replace_first: empty_star, half_star -%} +{%- 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 -%} - {{ difficulty }} {%- endif -%} diff --git a/_includes/recipes.html b/_includes/recipes.html index c2a1817..8202efc 100644 --- a/_includes/recipes.html +++ b/_includes/recipes.html @@ -1,9 +1,11 @@
- {% for recipe in site.recipes -%} + {% for recipe in site.recipes | limit: 15 -%} -

{{ recipe.name }}

+

{{ recipe.name }}

- By {{ recipe.author }} - {{ recipe.method | size }} steps {%- if recipe.time %} - + By {{ recipe.author }} - + {% if recipe.difficulty %}Difficulty: {% include difficulty_stars.html %} - {%- 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 -%} {%- if mins > 0 %}{{ mins }}m{% endif %} diff --git a/assets/style.css b/assets/style.css index 4d32097..fcf48ca 100644 --- a/assets/style.css +++ b/assets/style.css @@ -35,6 +35,9 @@ h2 { padding-left: 10px; background: linear-gradient(to right, turquoise 5px, transparent 5px 100%); } +h2.no-bg { + background: none; +} h1, h2, h3, h4, h5, h6 { font-weight: 400; } @@ -98,6 +101,9 @@ a { color: turquoise; text-decoration: none; } +a.dark { + filter: brightness(80%); +} a:not(.recipe-listing):hover { text-decoration: underline; } @@ -121,7 +127,8 @@ li { .recipe-listing { display: block; margin: 10px; - padding: 5px; + height: min-content; + padding: 0 5px; border-radius: 10px; background: linear-gradient(to right, turquoise 5px, #eee 5px 100%); max-width: 600px; @@ -136,8 +143,8 @@ a.recipe-listing { color: black; } -.recipe-listing h2 { - background: none; +.recipe-listing h3 { + padding-left: 10px; } .method li input[type=checkbox]:checked + label { @@ -161,13 +168,32 @@ a.recipe-listing { background: linear-gradient(to top, #eee 1em, transparent); } +table { + border-collapse: collapse; + width: max-content; + min-width: 50%; + max-width: 90%; + margin: 0 auto; + background: #0001; + border-radius: 10px; +} +tr:nth-of-type(2n) { + background: #0001; +} +td { + padding: 10px; +} +td:last-of-type { + text-align: right; +} + footer { text-align: center; background: #333; display: block; width: 100%; padding: 20px 0; - margin: 0; + margin: 30px 0 0 0; } footer, .subtle { color: grey; diff --git a/index.html b/index.html index 3640508..a0d0bb6 100644 --- a/index.html +++ b/index.html @@ -3,5 +3,53 @@ title: Home layout: default ---

Home

-

Currently tracking {{ site.recipes.size }} recipes and {{ site.subrecipes.size }} subrecipes.

+

Recipes

+

Showing {% if site.recipes_per_page > site.recipes.size %}{{ site.recipes_per_page}}{% else %}{{ site.recipes.size }}{% endif %} results.

{% include recipes.html %} + +{%- if site.recipes.size > 1 %} +

Stats

+{%- assign steps_total = 0 -%} +{%- assign longest_recipe = site.recipes | first -%} +{%- assign most_ingredients = site.recipes | first -%} +{%- for recipe in site.recipes -%} + {%- assign steps_total = steps_total | plus: recipe.method.size -%} + + {%- if recipe.method.size > longest_recipe.method.size -%} + {%- assign longest_recipe = recipe -%} + {%- endif -%} + + {%- if recipe.ingredients.size > most_ingredients.ingredients.size -%} + {%- assign most_ingredients = recipe -%} + {%- endif -%} +{%- endfor -%} + +{%- assign recipes_size_float = site.recipes.size | times: 1.0 -%} + + + + + + + + + + + + + + + + + + + + + + + + + + +
Recipes{{ site.recipes.size }}
Subrecipes{{ site.subrecipes.size }}
Authors{{ site.recipes | map: "author" | uniq | size }}
Average recipe steps{{ steps_total | divided_by: recipes_size_float | round: 1 | replace: '.0', '' -}}
Most ingredients (excluding subrecipes){{ most_ingredients.name }} ({{ most_ingredients.ingredients.size }} ingredients)
Most steps (excluding subrecipes){{ longest_recipe.name }} ({{ longest_recipe.method.size }} steps)
+{% endif %}