Update carousel to show all appropriate articles

Ensure that if articles are written by more than one author, both 
authors are compared to each article individually
This commit is contained in:
Matthew Grove
2019-03-06 06:39:16 +00:00
parent b94c4ba3aa
commit 11ebbc1cb1
2 changed files with 46 additions and 40 deletions

View File

@@ -2,49 +2,55 @@
{% assign article_list_displayed = false %} {% assign article_list_displayed = false %}
{% for article in site.categories.articles %} {% for article in site.categories.articles %}
{% if article.url != page.url %} {% if article.url != page.url %}
{% for author in article.authors %} {% assign authors = article.authors | split: ", " %}
{% for current_author in page.authors %} {% for author in authors %}
{% if author == current_author %} {% if article.date | date: "%Y" == page.date | date: "%Y" %}
{% if article_list_displayed == false %} {% assign current_authors = page.authors | split: ", " %}
<h2 class="mdc-typography--headline5"> {% for current_author in current_authors %}
{% if page.authors.first %} {% if author == current_author %}
Other Articles By These Authors {% if article_list_displayed == false %}
{% else %} <h2 class="mdc-typography--headline5">
Other Articles By This Author {% if current_authors.first %}
{% endif %} Other Articles By These Authors
</h2> {% else %}
<!-- define carousel --> Other Articles By This Author
<div class="carousel">
{% assign article_list_displayed = true %}
{% endif %} {% endif %}
<!-- display article --> </h2>
<div class="mdc-card carousel-item"> <!-- define carousel -->
<div class="mdc-card__media mdc-card__media--16-9 {{ article.url | relative_url | replace: '/', '-' | replace: '.', '-' }}"></div> <div class="carousel">
<div class="mdc-card-content"> {% assign article_list_displayed = true %}
<h2 class="mdc-typography--headline6">{{ article.title }}</h2> {% endif %}
<h3 class="mdc-typography--subtitle2"> <!-- display article -->
<time class="timeago" datetime="{{ article.date | date: '%Y-%m-%d' }}T{{ article.date | date: '%H:%M:%S' }}">{{ article.date | date: '%A %e %B %Y' }}</time> <div class="mdc-card carousel-item">
| by {{ article.authors }} <div class="mdc-card__media mdc-card__media--16-9 {{ article.url | relative_url | replace: '/', '-' | replace: '.', '-' }}"></div>
</h3> <div class="mdc-card-content">
</div> <h2 class="mdc-typography--headline6">{{ article.title }}</h2>
<div class="mdc-card__actions"> <h3 class="mdc-typography--subtitle2">
<div class="mdc-card__action-buttons"> <time class="timeago" datetime="{{ article.date | date: '%Y-%m-%d' }}T{{ article.date | date: '%H:%M:%S' }}">{{ article.date | date: '%A %e %B %Y' }}</time>
<button class="mdc-button mdc-card__action mdc-card__action--button" data-mdc-auto-init="MDCRipple" onclick="window.location='{{ article.url | relative_url }}';">Read</button> | by {{ article.authors }}
</div> </h3>
</div> </div>
<div class="mdc-card__actions">
<style> <div class="mdc-card__action-buttons">
.{{ article.url | relative_url | replace: '/', '-' | replace: '.', '-' }} { <button class="mdc-button mdc-card__action mdc-card__action--button" data-mdc-auto-init="MDCRipple" onclick="window.location='{{ article.url | relative_url }}';">Read</button>
background-image: url("/images/{{ article.url | relative_url | remove: '.html' | replace: '/', '-' | remove: '-articles-' }}--cover.jpg"); </div>
} </div>
</style>
</div> <style>
{% break %} .{{ article.url | relative_url | replace: '/', '-' | replace: '.', '-' }} {
background-image: url("/images/{{ article.url | relative_url | remove: '.html' | replace: '/', '-' | remove: '-articles-' }}--cover.jpg");
}
</style>
</div>
{% break %}
{% endif %} {% endif %}
{% endfor %}
{% endfor %} {% endfor %}
{% endif %}
{% endfor %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% if article_list_displayed == true %}
<!-- close carousel --> <!-- close carousel -->
</div> </div>
{% endif %}
{% endif %} {% endif %}

View File

@@ -5,7 +5,7 @@
<url> <url>
<loc>/404.html</loc> <loc>/404.html</loc>
<lastmod>2019-03-05</lastmod> <lastmod>2019-03-06</lastmod>
<changefreq>hourly</changefreq> <changefreq>hourly</changefreq>
<priority>0.5</priority> <priority>0.5</priority>
</url> </url>
@@ -16,7 +16,7 @@
<url> <url>
<loc>/</loc> <loc>/</loc>
<lastmod>2019-03-05</lastmod> <lastmod>2019-03-06</lastmod>
<changefreq>hourly</changefreq> <changefreq>hourly</changefreq>
<priority>0.5</priority> <priority>0.5</priority>
</url> </url>