From 54e5e67643cd14ad8ed05d1e2e1252da5c8c4be3 Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Wed, 26 Apr 2023 13:42:45 -0700 Subject: [PATCH] feat: add movie posters to now page --- src/_data/movies.js | 11 +++++++++-- src/_includes/base.liquid | 6 ++---- src/_includes/now.liquid | 29 ++++++++++++++++++++--------- src/assets/img/media/404-movie.jpg | Bin 0 -> 1971 bytes src/assets/img/media/404-music.jpg | Bin 0 -> 4146 bytes src/assets/img/media/404.jpg | Bin 6927 -> 0 bytes 6 files changed, 31 insertions(+), 15 deletions(-) create mode 100644 src/assets/img/media/404-movie.jpg create mode 100644 src/assets/img/media/404-music.jpg delete mode 100644 src/assets/img/media/404.jpg diff --git a/src/_data/movies.js b/src/_data/movies.js index f0bc7a81..4f70a411 100644 --- a/src/_data/movies.js +++ b/src/_data/movies.js @@ -5,10 +5,17 @@ module.exports = async function () { const url = 'https://letterboxd.com/cdme/rss' const asset = new AssetCache('movies_data') if (asset.isCacheValid('1h')) return await asset.getCachedValue() - const res = await extract(url).catch((error) => { + const res = await extract(url, { + getExtraEntryFields: (feedEntry) => { + const images = feedEntry['description']?.match(/]*src="[^"]*"[^>]*>/gm) || [] + return { + image: images.length ? images.map((x) => x.replace(/.*src="([^"]*)".*/, '$1'))[0] : '', + } + }, + }).catch((error) => { console.log(error.message) }) - const data = res.entries.splice(0, 5) + const data = res.entries.splice(0, 6) await asset.save(data, 'json') return data } diff --git a/src/_includes/base.liquid b/src/_includes/base.liquid index 616f44cd..c3884a2e 100644 --- a/src/_includes/base.liquid +++ b/src/_includes/base.liquid @@ -33,9 +33,7 @@ src="https://breezy-restored.coryd.dev/script.js" data-site="RHNGSUXO" defer> - + - + {{ content }}