Skip to content

Commit 8f5fcab

Browse files
Colour post summary list titles by index rather than title length (#6)
* Updated Navigating Enterprise Ai Architecture and 1 other file * Updated Tools For Measuring Cloud Carbon Emissions Updated For 2025 * Updated Accelerating Financial Process Automation Scott Logic Finos Fluxnova * Updated Accelerating Financial Process Automation Scott Logic Finos Fluxnova * Updated Rapid Development With Devin * Colour posts on summary page by loop index * fix mode * Cycle colours on featured posts --------- Co-authored-by: [email protected] <[email protected]>
1 parent a484cf3 commit 8f5fcab

File tree

5 files changed

+221
-31
lines changed

5 files changed

+221
-31
lines changed

_includes/featured_posts.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@
1313
{%- if numPosts > 0 -%}
1414
<div class="featured-posts grid-x grid-margin-x grid-margin-y">
1515
{%- assign topPost = featuredPosts[0] -%}
16+
{% assign randIdx = "now" | date: "%N" | modulo: 4 %}
1617
<div
17-
class="featured-post {% include post_colour.html post=topPost %} cell large-12 grid-x"
18+
class="featured-post {% include post_colour.html post=topPost postIndex=randIdx %} cell large-12 grid-x"
1819
>
1920
{%- include featured_post.html post=topPost -%}
2021
</div>
2122

2223
{%- if numPosts >= 3 -%}
2324
{%- assign splitPosts = featuredPosts | slice: 1, 2 -%}
2425
{%- for post in splitPosts -%}
26+
{%- assign colourIndex = randIdx | plus: forloop.index -%}
2527
<div
26-
class="featured-post {% include post_colour.html post=post %} cell large-6 grid-x"
28+
class="featured-post {% include post_colour.html post=post postIndex=colourIndex %} cell large-6 grid-x"
2729
>
2830
{%- include featured_post.html post=post -%}
2931
</div>

_includes/post_colour.html

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
{%- if include.post.colour -%}
22
{{- include.post.colour -}}
3+
{%- elsif include.postIndex != nil -%}
4+
{%- assign colourIndex = include.postIndex | modulo: 4 -%}
5+
{%- case colourIndex -%}
6+
{%- when 0 -%} teal
7+
{%- when 1 -%} orange
8+
{%- when 2 -%} pink
9+
{%- when 3 -%} yellow
10+
{%- endcase -%}
311
{%- else -%}
412
{%- assign colourIndex = include.post.title | size | modulo: 4 -%}
513
{%- case colourIndex -%}
6-
{%- when 0 -%}
7-
teal
8-
{%- when 1 -%}
9-
orange
10-
{%- when 2 -%}
11-
pink
12-
{%- when 3 -%}
13-
yellow
14-
{%- endcase -%}
15-
{%- endif -%}
14+
{%- when 0 -%} teal
15+
{%- when 1 -%} orange
16+
{%- when 2 -%} pink
17+
{%- when 3 -%} yellow
18+
{%- endcase -%}
19+
{%- endif -%}

_includes/post_summary.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{%- assign post = include.post -%}
2+
{%- assign postIndex = include.postIndex -%}
23
{%- assign hideCategory = include.hideCategory -%}
34
{%- assign author = site.data.authors.authors[post.author] -%}
45
{%- if include.fullWidth -%}
@@ -7,7 +8,8 @@
78
{%- assign largeClass = 'large-6' -%}
89
{%- endif -%}
910
<div
10-
class="post-summary grid-padding-x grid-margin-y grid-padding-y {% include post_colour.html post=post %} cell {{largeClass}} small-12"
11+
class="post-summary grid-padding-x grid-margin-y grid-padding-y
12+
{% include post_colour.html post=post postIndex=postIndex %} cell {{largeClass}} small-12"
1113
>
1214
<div class="post-summary cell grid-margin-y">
1315
{%- unless hideCategory -%}

_includes/post_summary_list.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
<div class="content grid-x">
1212
{%- for post in posts -%}
1313
{%-
14-
include post_summary.html post=post
14+
include post_summary.html
15+
post=post
16+
postIndex=forloop.index0
1517
hideCategory=hideCategory
1618
fullWidth=fullWidth
1719
-%}

0 commit comments

Comments
 (0)