From 162448faa9396e691cd85549bf0e1efe5a75c312 Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Sun, 13 Aug 2023 16:58:54 -0700 Subject: [PATCH] chore: normalize movie data --- src/_data/movies.js | 16 ++++++++++++---- src/_data/site.js | 2 -- src/_includes/partials/now/movies.liquid | 10 +++++----- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/_data/movies.js b/src/_data/movies.js index f1a495ff..5c0cec52 100644 --- a/src/_data/movies.js +++ b/src/_data/movies.js @@ -12,10 +12,18 @@ module.exports = async function () { const data = res.items .map((item) => { const images = item['content']?.match(/]*src="[^"]*"[^>]*>/gm) || [] - item.image = images.length - ? images.map((image) => image.replace(/.*src="([^"]*)".*/, '$1'))[0] - : 'https://cdn.coryd.dev/movies/missing-movie.jpg' - return item + return { + name: item['title'], + date: item['pubDate'], + summary: item['contentSnippet'], + image: images.length + ? images + .map((image) => image.replace(/.*src="([^"]*)".*/, '$1'))[0] + .replace('https://a.ltrbxd.com', 'https://movies.coryd.dev') + : 'https://cdn.coryd.dev/movies/missing-movie.jpg', + url: item['link'], + id: item['guid'], + } }) .splice(0, 6) await asset.save(data, 'json') diff --git a/src/_data/site.js b/src/_data/site.js index dd085e90..84ca0e04 100644 --- a/src/_data/site.js +++ b/src/_data/site.js @@ -7,7 +7,5 @@ module.exports = async function () { title: 'Cory Dransfeldt', description: "I'm a software developer in Camarillo, California. I enjoy hanging out with my beautiful family and 4 rescue dogs, technology, automation, music, writing, reading and tv and movies.", - 'letterboxd-host': 'https://a.ltrbxd.com', - 'cdn-movies': 'https://movies.coryd.dev', } } diff --git a/src/_includes/partials/now/movies.liquid b/src/_includes/partials/now/movies.liquid index 14660051..0b93ce2e 100644 --- a/src/_includes/partials/now/movies.liquid +++ b/src/_includes/partials/now/movies.liquid @@ -5,15 +5,15 @@
{% for movie in movies %} - +
-
{{ movie.title }}
+
{{ movie.name }}
- {%- capture movieImg %}{{movie.image | cdn: site.letterboxd-host, site.cdn-movies}}{% endcapture -%} - {%- capture movieName %}{{movie.title | escape}} - {{ movie.contentSnippet }}{% endcapture -%} - {% image movieImg, movieName, 'rounded-lg w-full', '180px' %} + {%- capture movieImg %}{{ movie.image }}{% endcapture -%} + {%- capture movieSummary %}{{ movie.summary }}{% endcapture -%} + {% image movieImg, movieSummary, 'rounded-lg w-full', '180px' %}
{% endfor %}