chore: remove code duplication and clean up
This commit is contained in:
parent
5a402c4def
commit
694dae0b06
34 changed files with 246 additions and 292 deletions
22
src/_includes/partials/media/music/chart.liquid
Normal file
22
src/_includes/partials/media/music/chart.liquid
Normal file
|
@ -0,0 +1,22 @@
|
|||
<div class="music-chart">
|
||||
{% assign items = data.items | default: data %}
|
||||
{% for item in items limit: count | default: items.size %}
|
||||
{%- assign playTotal = playTotal | default: mostPlayed -%}
|
||||
{%- assign percentage = item.plays | calculatePlayPercentage: playTotal -%}
|
||||
<div class="item">
|
||||
<div class="presentation">
|
||||
<div class="count">{{ item.rank | formatNumber }}.</div>
|
||||
<div class="info">
|
||||
<div class="title">
|
||||
<a href="{{ item.url }}">{{ item.title }}</a>
|
||||
</div>
|
||||
<div class="subtext">{{ item.artist }} • {{ item.plays }} plays</div>
|
||||
</div>
|
||||
</div>
|
||||
{% render "partials/media/progress-bar.liquid", percentage:percentage %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% unless count %}
|
||||
{% render "partials/widgets/paginator.liquid", pagination:data %}
|
||||
{% endunless %}
|
|
@ -1,19 +0,0 @@
|
|||
<hr class="large-spacing" />
|
||||
<div class="music-chart">
|
||||
{% for item in data.items %}
|
||||
{%- assign percentage = item.plays | calculatePlayPercentage:playTotal -%}
|
||||
<div class="item">
|
||||
<div class="presentation">
|
||||
<div class="count">{{ item.rank | formatNumber }}.</div>
|
||||
<div class="info">
|
||||
<div class="title">
|
||||
<a href="{{ item.url }}">{{ item.title }}</a>
|
||||
</div>
|
||||
<div class="subtext">{{ item.artist }} • {{ item.plays }} plays</div>
|
||||
</div>
|
||||
</div>
|
||||
{% render "partials/media/progress-bar.liquid", percentage:percentage %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% render "partials/widgets/paginator.liquid", pagination:data %}
|
|
@ -1,16 +0,0 @@
|
|||
<hr class="large-spacing" />
|
||||
<div class="media-grid square">
|
||||
{% for item in data.items %}
|
||||
{% assign alt = item.alt | strip | escape %}
|
||||
<a href="{{ item.url | stripUtm }}" title="{{ alt }}">
|
||||
<div class="item-wrapper shadow">
|
||||
<div class="meta-text">
|
||||
<div class="header">{{ item.title }}</div>
|
||||
<div class="subheader">{{ item.plays }} plays</div>
|
||||
</div>
|
||||
<img src="https://coryd.dev/.netlify/images/?url={{ item.image }}&fit=cover&w=240&h=240&fm=webp&q=85"{% if alt %} alt="{{ alt }}"{% endif %} loading="eager" decoding="async" width="240" height="240" />
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% render "partials/widgets/paginator.liquid", pagination:data %}
|
|
@ -1,4 +1,3 @@
|
|||
{% if data.size > 0 %}
|
||||
<div class="music-chart">
|
||||
{% for item in data limit: 10 %}
|
||||
{% capture alt %}{{ item.title | escape }} by {{ item.artist }}{% endcapture %}
|
||||
|
@ -17,5 +16,4 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
|
@ -1,21 +1,19 @@
|
|||
{% if albumReleases.size > 0 %}
|
||||
<h2 id="album-releases" class="section-header flex-centered">
|
||||
{% tablericon "calendar-time" "Anticipated albums" %}
|
||||
Anticipated albums
|
||||
</h2>
|
||||
<ul class="link-list">
|
||||
{% for album in albumReleases %}
|
||||
<li>
|
||||
<strong>{{ album.date }}: </strong>
|
||||
<a href="{{ album.url}}" title="{{ album.title | escape}} by {{ album.artist | escape}}">
|
||||
{{ album.title }}
|
||||
</a>
|
||||
<span> by </span>
|
||||
<a href="{{ album.artist_url }}">
|
||||
{{ album.artist }}
|
||||
</a>
|
||||
<span> • <a href="https://coryd.dev/music/genres/{{ album.genre | slugify | downcase }}">{{ album.genre }}</a></span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
<h2 id="album-releases" class="section-header flex-centered">
|
||||
{% tablericon "calendar-time" "Anticipated albums" %}
|
||||
Anticipated albums
|
||||
</h2>
|
||||
<ul class="link-list">
|
||||
{% for album in albumReleases %}
|
||||
<li>
|
||||
<strong>{{ album.date }}: </strong>
|
||||
<a href="{{ album.url}}" title="{{ album.title | escape}} by {{ album.artist | escape}}">
|
||||
{{ album.title }}
|
||||
</a>
|
||||
<span> by </span>
|
||||
<a href="{{ album.artist_url }}">
|
||||
{{ album.artist }}
|
||||
</a>
|
||||
<span> • <a href="https://coryd.dev/music/genres/{{ album.genre | slugify | downcase }}">{{ album.genre }}</a></span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
|
@ -1,19 +0,0 @@
|
|||
{% if data.size > 0 %}
|
||||
<div class="music-chart">
|
||||
{% for item in data limit: 10 %}
|
||||
{%- assign percentage = item.plays | calculatePlayPercentage: mostPlayed -%}
|
||||
<div class="item">
|
||||
<div class="presentation">
|
||||
<div class="count">{{ item.rank | formatNumber }}.</div>
|
||||
<div class="info">
|
||||
<div class="title">
|
||||
<a href="{{ item.url }}">{{ item.title }}</a>
|
||||
</div>
|
||||
<div class="subtext">{{ item.artist }} • {{ item.plays }} plays</div>
|
||||
</div>
|
||||
</div>
|
||||
{% render "partials/media/progress-bar.liquid", percentage:percentage %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
Reference in a new issue