chore: metadata display consistency

This commit is contained in:
Cory Dransfeldt 2024-08-05 18:29:06 -07:00
parent 572d074fea
commit 8da88d97b4
No known key found for this signature in database
7 changed files with 23 additions and 14 deletions

View file

@ -149,8 +149,9 @@ export default {
}, },
// media // media
normalizeMedia: (media) => normalizeMedia: (media, limit) => {
media.map((item) => { const mediaData = limit ? media.slice(0, limit) : media
return mediaData.map((item) => {
let normalized = { let normalized = {
image: item['image'], image: item['image'],
url: item['url'], url: item['url'],
@ -176,7 +177,7 @@ export default {
normalized['alt'] = item['title'] normalized['alt'] = item['title']
normalized['rating'] = item['rating'] normalized['rating'] = item['rating']
normalized['favorite'] = item['favorite'] normalized['favorite'] = item['favorite']
normalized['subtext'] = item['rating'] normalized['subtext'] = `${item['rating']} (${item['year']})`
} }
if (item.type === 'book') { if (item.type === 'book') {
normalized['title'] = `${item['title']} by ${item['author']}` normalized['title'] = `${item['title']} by ${item['author']}`
@ -194,7 +195,8 @@ export default {
normalized['subtext'] = item['subtext'] normalized['subtext'] = item['subtext']
} }
return normalized return normalized
}), })
},
calculatePlayPercentage: (plays, mostPlayed) => `${plays/mostPlayed * 100}%`, calculatePlayPercentage: (plays, mostPlayed) => `${plays/mostPlayed * 100}%`,
listToString: (items, key, count = 10) => { listToString: (items, key, count = 10) => {
const itemData = items.slice(0, count) const itemData = items.slice(0, count)

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "coryd.dev", "name": "coryd.dev",
"version": "21.4.7", "version": "21.4.8",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "coryd.dev", "name": "coryd.dev",
"version": "21.4.7", "version": "21.4.8",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@cdransf/api-text": "^1.4.0", "@cdransf/api-text": "^1.4.0",

View file

@ -1,6 +1,6 @@
{ {
"name": "coryd.dev", "name": "coryd.dev",
"version": "21.4.7", "version": "21.4.8",
"description": "The source for my personal site. Built using 11ty (and other tools).", "description": "The source for my personal site. Built using 11ty (and other tools).",
"type": "module", "type": "module",
"scripts": { "scripts": {

View file

@ -1,7 +1,7 @@
{%- assign hidePagination = count or data.pages.size <= 1 -%} {%- assign hidePagination = count or data.pages.size <= 1 -%}
{%- assign media = data.items | default: data | normalizeMedia -%} {%- assign media = data.items | default: data | normalizeMedia: count -%}
<div class="media-grid {% if shape == 'square' -%}square{%- else -%}vertical{%- endif -%}"> <div class="media-grid {% if shape == 'square' -%}square{%- else -%}vertical{%- endif -%}">
{%- for item in media limit: count | default: media.size -%} {%- for item in media | default: media.size -%}
{%- capture alt -%}{{ item.title | escape }} ({{ item.year }}){% endcapture %} {%- capture alt -%}{{ item.title | escape }} ({{ item.year }}){% endcapture %}
{%- assign alt = item.alt | strip | escape -%} {%- assign alt = item.alt | strip | escape -%}
<a href="{{ item.url }}" title="{{ alt }}"> <a href="{{ item.url }}" title="{{ alt }}">

View file

@ -9,10 +9,10 @@
{%- if item.type == 'movie' -%} {%- if item.type == 'movie' -%}
<div class="header">{{ item.title }}</div> <div class="header">{{ item.title }}</div>
<div class="subheader flex-centered"> <div class="subheader flex-centered">
{{ item.year }}
{%- if item.rating -%} {%- if item.rating -%}
<span class="rating"> ({{ item.rating }})</span> <span class="rating"> {{ item.rating }}</span>
{%- endif -%} {%- endif -%}
({{ item.year }})
</div> </div>
{%- else -%} {%- else -%}
<div class="header">{{ item.name }}</div> <div class="header">{{ item.name }}</div>

View file

@ -33,7 +33,14 @@ schema: movie
/> />
<div class="watching-meta"> <div class="watching-meta">
<p class="title"><strong>{{ movie.title }}</strong></p> <p class="title"><strong>{{ movie.title }}</strong></p>
{% if movie.rating %}<p class="rating">{{ movie.rating }}</p>{% endif %} <p>
{%- if movie.rating -%}
{{ movie.rating }}
{% endif -%}
{%- if movie.year %}
({{ movie.year }})
{%- endif -%}
</p>
{% if movie.lastWatched %}<p class="sub-meta">Last watched on {{ movie.lastWatched | date: "%B %e, %Y" }}</p>{% endif %} {% if movie.lastWatched %}<p class="sub-meta">Last watched on {{ movie.lastWatched | date: "%B %e, %Y" }}</p>{% endif %}
<p class="sub-meta"><a href="https://themoviedb.org/movie/{{ movie.id }}" title="View {{ movie.title | escape }} on TMDB">View on TMDB</a></p> <p class="sub-meta"><a href="https://themoviedb.org/movie/{{ movie.id }}" title="View {{ movie.title | escape }} on TMDB">View on TMDB</a></p>
</div> </div>

View file

@ -33,8 +33,8 @@ schema: show
height="720" height="720"
/> />
<div class="watching-meta"> <div class="watching-meta">
<p class="title"><strong>{{ show.title }}</strong></p> <p class="title"><strong>{{ show.title }}</strong>{%- if show.year %} ({{ show.year }}){%- endif -%}</p>
{% if lastWatched %}<p class="sub-meta">Last watched on {{ lastWatched | date: "%B %e, %Y" }}</p>{% endif %} {%- if lastWatched -%}<p class="sub-meta">Last watched on {{ lastWatched | date: "%B %e, %Y" }}</p>{%- endif -%}
<p class="sub-meta"><a href="https://themoviedb.org/tv/{{ show.tmdb_id }}" title="View {{ show.title | escape }} on TMDB">View on TMDB</a></p> <p class="sub-meta"><a href="https://themoviedb.org/tv/{{ show.tmdb_id }}" title="View {{ show.title | escape }} on TMDB">View on TMDB</a></p>
</div> </div>
{% if show.review %} {% if show.review %}