|
5 | 5 | <div id="site-canvas"> |
6 | 6 | <div class="header-image header-blog"> |
7 | 7 | <div class="dark-overlay center-text"> |
8 | | - <h1 class="title feature-header">{{site.data[locale].blog.title}}</h1> |
| 8 | + <h1 class="title feature-header">{{site.data[site.active_lang].blog.title}}</h1> |
9 | 9 | </div> |
10 | 10 | </div> |
11 | 11 | <div class="row"> |
12 | 12 | <div class="large-12 columns"> |
13 | | - {% for post in site.posts %} |
14 | | - {% if post.lang == locale %} |
15 | | - <div class="textbox blog-preview"> |
16 | | - <h2 class="title"><a href="{{ post.url }}">{{ post.title }}</a></h2> |
17 | | - <a href="{{ post.url }}"> |
18 | | - <img class="medium-4 pull-right blog-img stack-for-small" src="{{ post.banner }}" alt="{{ post.title }}" /> |
| 13 | + {% comment %} |
| 14 | + Group posts by date to handle multilingual posts. |
| 15 | + For posts with the same date, show only one version with links to other languages. |
| 16 | + {% endcomment %} |
| 17 | + {% assign posts_by_date = site.posts | group_by: 'date' %} |
| 18 | + {% for date_group in posts_by_date %} |
| 19 | + {% assign posts_for_date = date_group.items %} |
| 20 | + {% assign current_lang_post = nil %} |
| 21 | + {% assign english_post = nil %} |
| 22 | + {% assign other_posts = "" | split: "," %} |
| 23 | + |
| 24 | + {% comment %}Find the best post to display for this date{% endcomment %} |
| 25 | + {% for post in posts_for_date %} |
| 26 | + {% if post.lang == site.active_lang %} |
| 27 | + {% assign current_lang_post = post %} |
| 28 | + {% elsif post.lang == 'en' %} |
| 29 | + {% assign english_post = post %} |
| 30 | + {% endif %} |
| 31 | + {% assign other_posts = other_posts | push: post %} |
| 32 | + {% endfor %} |
| 33 | + |
| 34 | + {% comment %}Choose which post to display (prefer current language, fallback to English){% endcomment %} |
| 35 | + {% if current_lang_post %} |
| 36 | + {% assign display_post = current_lang_post %} |
| 37 | + {% elsif english_post %} |
| 38 | + {% assign display_post = english_post %} |
| 39 | + {% else %} |
| 40 | + {% assign display_post = posts_for_date.first %} |
| 41 | + {% endif %} |
| 42 | + |
| 43 | + <article class="blog-card"> |
| 44 | + <div class="blog-card__image"> |
| 45 | + <a href="{{ display_post.url }}" aria-label="Read {{ display_post.title }}"> |
| 46 | + <img src="{{ display_post.banner }}" alt="{{ display_post.title }}" /> |
19 | 47 | </a> |
20 | | - {% assign month_number = post.date | date: "%-m" | plus: 0 %} |
21 | | - <p><span class="blog-date">{{ post.date | date: "%-d" }} {{ site.data[site.active_lang].months[month_number] }} {{ post.date | date: "%Y" }} </span> | by {{ post.author }}</p> |
22 | | - <p class="medium-7">{{ post.excerpt }}</p> |
23 | | - </div> |
24 | | - {% endif %} |
| 48 | + </div> |
| 49 | + <div class="blog-card__content"> |
| 50 | + <h2 class="blog-card__title"> |
| 51 | + <a href="{{ display_post.url }}">{{ display_post.title }}</a> |
| 52 | + </h2> |
| 53 | + <div class="blog-card__meta"> |
| 54 | + {% assign month_number = display_post.date | date: "%-m" | plus: 0 %} |
| 55 | + <span class="blog-date">{{ display_post.date | date: "%-d" }} {{ site.data[site.active_lang].months[month_number] }} {{ display_post.date | date: "%Y" }}</span> |
| 56 | + <span class="blog-author">by {{ display_post.author }}</span> |
| 57 | + </div> |
| 58 | + |
| 59 | + {% comment %}Show language links if there are multiple versions{% endcomment %} |
| 60 | + {% if posts_for_date.size > 1 %} |
| 61 | + <div class="blog-card__languages"> |
| 62 | + <span class="language-label">{{site.data[site.active_lang].blog.also_available}}: </span> |
| 63 | + {% for post in posts_for_date %} |
| 64 | + {% unless post.url == display_post.url %} |
| 65 | + <a href="{{ post.url }}" class="language-link" title="{{ post.title }}"> |
| 66 | + {% if post.lang == 'en' %}English{% endif %} |
| 67 | + {% if post.lang == 'fr' %}Français{% endif %} |
| 68 | + {% if post.lang == 'es' %}Español{% endif %} |
| 69 | + {% if post.lang == 'cs' %}Čeština{% endif %} |
| 70 | + </a> |
| 71 | + {% unless forloop.last %} | {% endunless %} |
| 72 | + {% endunless %} |
| 73 | + {% endfor %} |
| 74 | + </div> |
| 75 | + {% endif %} |
| 76 | + |
| 77 | + <div class="blog-card__excerpt">{{ display_post.excerpt }}</div> |
| 78 | + </div> |
| 79 | + </article> |
25 | 80 | {% endfor %} |
26 | 81 | </div> |
27 | 82 | </div> |
|
0 commit comments