From 8da88d97b49654466d08f23afed481fcdfa94745 Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Mon, 5 Aug 2024 18:29:06 -0700 Subject: [PATCH] chore: metadata display consistency --- config/filters/index.js | 10 ++++++---- package-lock.json | 4 ++-- package.json | 2 +- src/includes/partials/media/grid.liquid | 4 ++-- src/includes/partials/media/watching/grid.liquid | 4 ++-- src/pages/dynamic/watching/movie.html | 9 ++++++++- src/pages/dynamic/watching/show.html | 4 ++-- 7 files changed, 23 insertions(+), 14 deletions(-) diff --git a/config/filters/index.js b/config/filters/index.js index 53a46712..ada9c993 100644 --- a/config/filters/index.js +++ b/config/filters/index.js @@ -149,8 +149,9 @@ export default { }, // media - normalizeMedia: (media) => - media.map((item) => { + normalizeMedia: (media, limit) => { + const mediaData = limit ? media.slice(0, limit) : media + return mediaData.map((item) => { let normalized = { image: item['image'], url: item['url'], @@ -176,7 +177,7 @@ export default { normalized['alt'] = item['title'] normalized['rating'] = item['rating'] normalized['favorite'] = item['favorite'] - normalized['subtext'] = item['rating'] + normalized['subtext'] = `${item['rating']} (${item['year']})` } if (item.type === 'book') { normalized['title'] = `${item['title']} by ${item['author']}` @@ -194,7 +195,8 @@ export default { normalized['subtext'] = item['subtext'] } return normalized - }), + }) + }, calculatePlayPercentage: (plays, mostPlayed) => `${plays/mostPlayed * 100}%`, listToString: (items, key, count = 10) => { const itemData = items.slice(0, count) diff --git a/package-lock.json b/package-lock.json index 023ca992..c8a4fa3f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "coryd.dev", - "version": "21.4.7", + "version": "21.4.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "coryd.dev", - "version": "21.4.7", + "version": "21.4.8", "license": "MIT", "dependencies": { "@cdransf/api-text": "^1.4.0", diff --git a/package.json b/package.json index e05bdff4..c908fc81 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "21.4.7", + "version": "21.4.8", "description": "The source for my personal site. Built using 11ty (and other tools).", "type": "module", "scripts": { diff --git a/src/includes/partials/media/grid.liquid b/src/includes/partials/media/grid.liquid index cf5dc58a..67b3a9b7 100644 --- a/src/includes/partials/media/grid.liquid +++ b/src/includes/partials/media/grid.liquid @@ -1,7 +1,7 @@ {%- assign hidePagination = count or data.pages.size <= 1 -%} -{%- assign media = data.items | default: data | normalizeMedia -%} +{%- assign media = data.items | default: data | normalizeMedia: count -%}
- {%- for item in media limit: count | default: media.size -%} + {%- for item in media | default: media.size -%} {%- capture alt -%}{{ item.title | escape }} ({{ item.year }}){% endcapture %} {%- assign alt = item.alt | strip | escape -%} diff --git a/src/includes/partials/media/watching/grid.liquid b/src/includes/partials/media/watching/grid.liquid index 5af817a9..b0a74a4b 100644 --- a/src/includes/partials/media/watching/grid.liquid +++ b/src/includes/partials/media/watching/grid.liquid @@ -9,10 +9,10 @@ {%- if item.type == 'movie' -%}
{{ item.title }}
- {{ item.year }} {%- if item.rating -%} - ({{ item.rating }}) + {{ item.rating }} {%- endif -%} + ({{ item.year }})
{%- else -%}
{{ item.name }}
diff --git a/src/pages/dynamic/watching/movie.html b/src/pages/dynamic/watching/movie.html index 1149f8c8..c8cbf031 100644 --- a/src/pages/dynamic/watching/movie.html +++ b/src/pages/dynamic/watching/movie.html @@ -33,7 +33,14 @@ schema: movie />
diff --git a/src/pages/dynamic/watching/show.html b/src/pages/dynamic/watching/show.html index 7c54b033..49069c4b 100644 --- a/src/pages/dynamic/watching/show.html +++ b/src/pages/dynamic/watching/show.html @@ -33,8 +33,8 @@ schema: show height="720" />
-

{{ show.title }}

- {% if lastWatched %}

Last watched on {{ lastWatched | date: "%B %e, %Y" }}

{% endif %} +

{{ show.title }}{%- if show.year %} ({{ show.year }}){%- endif -%}

+ {%- if lastWatched -%}

Last watched on {{ lastWatched | date: "%B %e, %Y" }}

{%- endif -%}

View on TMDB

{% if show.review %}