feat: add movie posters to now page

This commit is contained in:
Cory Dransfeldt 2023-04-26 13:42:45 -07:00
parent 4158faac60
commit 54e5e67643
No known key found for this signature in database
6 changed files with 31 additions and 15 deletions

View file

@ -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(/<img [^>]*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
}

View file

@ -33,9 +33,7 @@
src="https://breezy-restored.coryd.dev/script.js"
data-site="RHNGSUXO"
defer></script>
<script
src="/_vercel/insights/script.js"
defer></script>
<script src="/_vercel/insights/script.js" defer></script>
<link rel="webmention" href="https://webmention.io/coryd.dev/webmention" />
<link rel="pingback" href="https://webmention.io/coryd.dev/xmlrpc" />
<link
@ -62,7 +60,7 @@
}
</script>
</head>
<body class="dark:text-white dark:bg-gray-900 font-sans text-gray-800">
<body class="dark:text-white bg-white dark:bg-gray-900 font-sans text-gray-800">
{{ content }}
<script>
document.getElementById("toggleDarkMode").addEventListener("click", function() {

View file

@ -57,7 +57,7 @@ layout: main
</div>
<img
src="{{artist.name | artist}}"
onerror="this.onerror=null; this.src='/assets/img/media/404.jpg'"
onerror="this.onerror=null; this.src='/assets/img/media/404-music.jpg'"
width="350"
height="350"
class="rounded-lg"
@ -87,7 +87,7 @@ layout: main
</div>
<img
src="{{album | album}}"
onerror="this.onerror=null; this.src='/assets/img/media/404.jpg'"
onerror="this.onerror=null; this.src='/assets/img/media/404-music.jpg'"
width="350"
height="350"
class="rounded-lg"
@ -120,15 +120,26 @@ layout: main
Watching: movies
</h2>
<div>
<ul class="list-inside list-disc pl-5 md:pl-10">
<div class="grid grid-cols-3 gap-2 md:grid-cols-6 not-prose">
{% for movie in movies %}
<li class="mt-1.5 mb-2">
<a href="{{movie.link}}" title="{{movie.title | escape}}">
{{ movie.title }}
<div class="relative block" style="max-width:226px">
<div class="absolute left-0 top-0 h-full w-full rounded-lg border border-primary-500 bg-cover-gradient dark:border-gray-500"></div>
<div class="absolute left-1 bottom-2 drop-shadow-md">
<div class="px-1 text-xs font-bold text-white">{{ movie.title }}</div>
</div>
<img
src="{{movie.image}}"
onerror="this.onerror=null; this.src='/assets/img/media/404-movie.jpg'"
width="226"
height="337"
class="rounded-lg"
alt="{{movie.title | escape}}"
loading="lazy" />
</div>
</a>
</li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
{% if tv %}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB