63 lines
2.4 KiB
Text
63 lines
2.4 KiB
Text
{% assign media = artists | concat:books | concat:genres | concat:movies | concat:posts | concat:shows %}
|
|
{% if media.size > 0 %}
|
|
<div class="associated-media">
|
|
{% assign sections =
|
|
"artists:headphones:music:Related artist(s):true," | append:
|
|
"books:books:books:Related book(s):true," | append:
|
|
"genres:headphones:music:Related genre(s):false," | append:
|
|
"movies:movie:movies:Related movie(s):true," | append:
|
|
"posts:article:article:Related post(s):false," | append:
|
|
"shows:device-tv-old:tv:Related show(s):true"
|
|
| split:"," %}
|
|
{% for section in sections %}
|
|
{% assign parts = section | split:":" %}
|
|
{% assign key = parts[0] %}
|
|
{% assign icon = parts[1] %}
|
|
{% assign css_class = parts[2] %}
|
|
{% assign label = parts[3] %}
|
|
{% assign hasGrid = parts[4] == "true" %}
|
|
{% assign items = nil %}
|
|
{% case key %}
|
|
{% when "artists" %} {% assign items = artists %}
|
|
{% when "books" %} {% assign items = books %}
|
|
{% when "genres" %} {% assign items = genres %}
|
|
{% when "movies" %} {% assign items = movies %}
|
|
{% when "posts" %} {% assign items = posts %}
|
|
{% when "shows" %} {% assign items = shows %}
|
|
{% endcase %}
|
|
{% if items and items.size > 0 %}
|
|
<h3 id="{{ key }}" class="{{ css_class }}">
|
|
{% tablericon icon %}
|
|
{{ label }}
|
|
</h3>
|
|
{% if hasGrid %}
|
|
{% assign shape = "square" %}
|
|
{% if key == "books" or key == "movies" or key == "shows" %}
|
|
{% assign shape = "vertical" %}
|
|
{% endif %}
|
|
{% render "media/grid.liquid",
|
|
data:items,
|
|
shape:shape
|
|
%}
|
|
{% else %}
|
|
<ul>
|
|
{% for item in items %}
|
|
<li class="{{ css_class }}">
|
|
<a href="{{ item.url }}">{{ item.title | default:item.name }}</a>
|
|
{% if key == "artists" and item.total_plays > 0 %}
|
|
({{ item.total_plays }} {{ item.total_plays | pluralize:"play" }})
|
|
{% elsif key == "books" %}
|
|
by {{ item.author }}
|
|
{% elsif key == "movies" or key == "shows" %}
|
|
({{ item.year }})
|
|
{% elsif key == "posts" %}
|
|
({{ item.date | date:"%B %e, %Y" }})
|
|
{% endif %}
|
|
</li>
|
|
{% endfor %}
|
|
</ul>
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|