chore: normalize movie data
This commit is contained in:
parent
b5223a5923
commit
162448faa9
3 changed files with 17 additions and 11 deletions
|
@ -12,10 +12,18 @@ module.exports = async function () {
|
||||||
const data = res.items
|
const data = res.items
|
||||||
.map((item) => {
|
.map((item) => {
|
||||||
const images = item['content']?.match(/<img [^>]*src="[^"]*"[^>]*>/gm) || []
|
const images = item['content']?.match(/<img [^>]*src="[^"]*"[^>]*>/gm) || []
|
||||||
item.image = images.length
|
return {
|
||||||
? images.map((image) => image.replace(/.*src="([^"]*)".*/, '$1'))[0]
|
name: item['title'],
|
||||||
: 'https://cdn.coryd.dev/movies/missing-movie.jpg'
|
date: item['pubDate'],
|
||||||
return item
|
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)
|
.splice(0, 6)
|
||||||
await asset.save(data, 'json')
|
await asset.save(data, 'json')
|
||||||
|
|
|
@ -7,7 +7,5 @@ module.exports = async function () {
|
||||||
title: 'Cory Dransfeldt',
|
title: 'Cory Dransfeldt',
|
||||||
description:
|
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.",
|
"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',
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,15 +5,15 @@
|
||||||
</h2>
|
</h2>
|
||||||
<div class="grid grid-cols-3 gap-2 md:grid-cols-6 not-prose">
|
<div class="grid grid-cols-3 gap-2 md:grid-cols-6 not-prose">
|
||||||
{% for movie in movies %}
|
{% for movie in movies %}
|
||||||
<a href="{{movie.link}}" title="{{movie.title | escape}}">
|
<a href="{{movie.url}}" title="{{movie.name | escape}}">
|
||||||
<div class="relative block" style="max-width:226px">
|
<div class="relative block" style="max-width:226px">
|
||||||
<div class="absolute left-0 top-0 h-full w-full rounded-lg border border-purple-600 hover:border-pink-500 bg-cover-gradient dark:border-purple-400 dark:hover:border-pink-500 ease-in-out duration-300"></div>
|
<div class="absolute left-0 top-0 h-full w-full rounded-lg border border-purple-600 hover:border-pink-500 bg-cover-gradient dark:border-purple-400 dark:hover:border-pink-500 ease-in-out duration-300"></div>
|
||||||
<div class="absolute left-1 bottom-2 drop-shadow-md">
|
<div class="absolute left-1 bottom-2 drop-shadow-md">
|
||||||
<div class="px-1 text-xs font-bold text-white">{{ movie.title }}</div>
|
<div class="px-1 text-xs font-bold text-white">{{ movie.name }}</div>
|
||||||
</div>
|
</div>
|
||||||
{%- capture movieImg %}{{movie.image | cdn: site.letterboxd-host, site.cdn-movies}}{% endcapture -%}
|
{%- capture movieImg %}{{ movie.image }}{% endcapture -%}
|
||||||
{%- capture movieName %}{{movie.title | escape}} - {{ movie.contentSnippet }}{% endcapture -%}
|
{%- capture movieSummary %}{{ movie.summary }}{% endcapture -%}
|
||||||
{% image movieImg, movieName, 'rounded-lg w-full', '180px' %}
|
{% image movieImg, movieSummary, 'rounded-lg w-full', '180px' %}
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
Reference in a new issue