feat: shows related to artists; related artists; books etc

This commit is contained in:
Cory Dransfeldt 2024-08-26 07:03:54 -07:00
parent 5376095860
commit 8e47d3cea9
No known key found for this signature in database
11 changed files with 56 additions and 16 deletions

View file

@ -179,7 +179,7 @@ export const albumReleasesCalendar = (collection) => {
url: album.url,
uid: `${date.toFormat('yyyyMMdd')}-${album.artist}-${album.title}@coryd.dev`,
timestamp: DateTime.now().toUTC().toFormat("yyyyMMdd'T'HHmmss'Z'")
};
}
}).filter(event => event !== null)
const { error, value } = ics.createEvents(events)

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "coryd.dev",
"version": "24.0.2",
"version": "24.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "coryd.dev",
"version": "24.0.2",
"version": "24.1.0",
"license": "MIT",
"dependencies": {
"@cdransf/api-text": "^1.5.0",

View file

@ -1,6 +1,6 @@
{
"name": "coryd.dev",
"version": "24.0.3",
"version": "24.1.0",
"description": "The source for my personal site. Built using 11ty (and other tools).",
"type": "module",
"scripts": {

View file

@ -30,7 +30,9 @@ const fetchAllArtists = async () => {
concerts,
books,
movies,
posts
posts,
related_artists,
shows
`)
.range(rangeStart, rangeStart + PAGE_SIZE - 1)
@ -83,6 +85,12 @@ const processArtists = (artists) => {
tmdb_id: movie['tmdb_id'],
url: `/watching/movies/${movie['tmdb_id']}`,
})).sort((a, b) => b['year'] - a['year']) : null,
shows: artist['shows']?.[0]?.['id'] ? artist['shows'].map(show => ({
title: show['title'],
year: show['year'],
tmdb_id: show['tmdb_id'],
url: `/watching/shows/${show['tmdb_id']}`,
})).sort((a, b) => b['year'] - a['year']) : null,
posts: artist['posts']?.[0]?.['id'] ? artist['posts'].map(post => ({
id: post['id'],
title: post['title'],
@ -90,6 +98,10 @@ const processArtists = (artists) => {
slug: post['slug'],
url: post['slug'],
})).sort((a, b) => new Date(b['date']) - new Date(a['date'])) : null,
relatedArtists: artist['related_artists']?.[0]?.['id'] ? artist['related_artists'].map(relatedArtist => {
relatedArtist['url'] = `/music/artists/${sanitizeMediaString(relatedArtist['name'])}-${sanitizeMediaString(parseCountryField(relatedArtist['country']))}`
return relatedArtist
}).sort((a, b) => a['name'].localeCompare(b['name'])) : null,
}))
}

View file

@ -30,10 +30,11 @@ const fetchAllBooks = async () => {
tattoo,
tags,
artists,
movies,
genres,
movies,
posts,
shows,
posts
related_books
`)
.order('date_finished', { ascending: false })
.range(rangeStart, rangeStart + PAGE_SIZE - 1)
@ -77,7 +78,7 @@ const processBooks = (books) => {
return artist
}).sort((a, b) => a['name'].localeCompare(b['name'])) : null,
movies: book['movies']?.[0]?.['id'] ? book['movies'].map(movie => {
movie['url'] =`/watching/movies/${movie['tmdb_id']}`
movie['url'] = `/watching/movies/${movie['tmdb_id']}`
return movie
}).sort((a, b) => b['year'] - a['year']) : null,
genres: book['genres']?.[0]?.['id'] ? book['genres'].map(genre => {
@ -95,6 +96,13 @@ const processBooks = (books) => {
slug: post['slug'],
url: post['slug'],
})).sort((a, b) => new Date(b['date']) - new Date(a['date'])) : null,
relatedBooks: book['related_books']?.[0]?.['id'] ? book['related_books'].map(relatedBook => ({
title: relatedBook['title'],
author: relatedBook['author'],
isbn: relatedBook['isbn'],
description: relatedBook['description'],
url: `/books/${relatedBook['isbn']}`,
})).sort((a, b) => a['title'].localeCompare(b['title'])) : null, // Add related books processing
year,
}
})

View file

@ -35,7 +35,8 @@ const fetchAllMovies = async () => {
books,
genres,
shows,
posts
posts,
related_movies
`)
.order('last_watched', { ascending: false })
.range(rangeStart, rangeStart + PAGE_SIZE - 1)
@ -96,6 +97,10 @@ const processMovies = (movies) => {
slug: post['slug'],
url: post['slug'],
})).sort((a, b) => new Date(b['date']) - new Date(a['date'])) : null,
relatedMovies: item['related_movies']?.[0]?.['id'] ? item['related_movies'].map(movie => {
movie['url'] = `/watching/movies/${movie['tmdb_id']}`
return movie
}).sort((a, b) => b['year'] - a['year']) : null,
}))
}
@ -105,19 +110,15 @@ export default async function () {
try {
const movies = await fetchAllMovies()
const processedMovies = processMovies(movies)
const filterMovies = (condition) => processedMovies.filter(condition)
const formatMovieData = (movies) => movies.map(movie => movie)
const favoriteMovies = filterMovies(movie => movie['favorite'])
const collectedMovies = filterMovies(movie => movie['collected'])
const recentlyWatchedMovies = filterMovies(movie => movie['lastWatched'] && year - DateTime.fromISO(movie['lastWatched']).year <= 3).sort((a, b) => new Date(b['lastWatched']) - new Date(a['lastWatched']))
return {
watchHistory: formatMovieData(filterMovies(movie => movie['lastWatched'])),
recentlyWatched: formatMovieData(recentlyWatchedMovies),
favorites: formatMovieData(favoriteMovies).sort((a, b) => a['title'].localeCompare(b['title'])),
collection: formatMovieData(collectedMovies),
}
} catch (error) {
console.error('Error fetching and processing movies data:', error)
@ -125,7 +126,6 @@ export default async function () {
watchHistory: [],
recentlyWatched: [],
favorites: [],
collection: [],
}
}
}

View file

@ -1,4 +1,5 @@
import { createClient } from '@supabase/supabase-js'
import { sanitizeMediaString, parseCountryField } from '../../config/utilities/index.js'
const SUPABASE_URL = process.env.SUPABASE_URL
const SUPABASE_KEY = process.env.SUPABASE_KEY
@ -27,9 +28,11 @@ const fetchAllShows = async () => {
backdrop,
tags,
episodes,
movies,
artists,
books,
posts
movies,
posts,
related_shows
`)
.range(rangeStart, rangeStart + PAGE_SIZE - 1)
@ -72,6 +75,17 @@ const prepareShowData = (show) => ({
slug: post['slug'],
url: post['slug'],
})).sort((a, b) => new Date(b['date']) - new Date(a['date'])) : null,
relatedShows: show['related_shows']?.[0]?.['id'] ? show['related_shows'].map(relatedShow => ({
id: relatedShow['id'],
title: relatedShow['title'],
year: relatedShow['year'],
tmdb_id: relatedShow['tmdb_id'],
url: `/watching/shows/${relatedShow['tmdb_id']}`,
})).sort((a, b) => b['year'] - a['year']) : null,
artists: show['artists']?.[0]?.['id'] ? show['artists'].map(artist => {
artist['url'] = `/music/artists/${sanitizeMediaString(artist['name'])}-${sanitizeMediaString(parseCountryField(artist['country']))}`
return artist
}).sort((a, b) => a['name'].localeCompare(b['name'])) : null, // Add artists processing
})
const prepareEpisodeData = (show) => show['episodes'].map(episode => ({

View file

@ -61,6 +61,7 @@ schema: book
<hr />
{% endif %}
{% render "partials/blocks/associated-media.liquid", posts:book.posts %}
{% render "partials/blocks/associated-media.liquid", books:book.relatedBooks %}
{% render "partials/blocks/associated-media.liquid", artists:book.artists %}
{% render "partials/blocks/associated-media.liquid", movies:book.movies %}
{% render "partials/blocks/associated-media.liquid", shows:book.shows %}

View file

@ -59,8 +59,10 @@ schema: artist
</div>
</div>
{% render "partials/blocks/associated-media.liquid", posts:artist.posts %}
{% render "partials/blocks/associated-media.liquid", posts:artist.relatedArtists %}
{% render "partials/blocks/associated-media.liquid", books:artist.books %}
{% render "partials/blocks/associated-media.liquid", movies:artist.movies %}
{% render "partials/blocks/associated-media.liquid", shows:artist.shows %}
{%- if artist.description -%}
<h3>Overview</h3>
<div data-toggle-content class="text-toggle-hidden">{{ artist.description | markdown }}</div>

View file

@ -57,6 +57,7 @@ schema: movie
<hr />
{% endif %}
{% render "partials/blocks/associated-media.liquid", posts:movie.posts %}
{% render "partials/blocks/associated-media.liquid", posts:movie.relatedMovies %}
{% render "partials/blocks/associated-media.liquid", shows:movie.shows %}
{% render "partials/blocks/associated-media.liquid", artists:movie.artists %}
{% render "partials/blocks/associated-media.liquid", books:movie.books %}

View file

@ -59,6 +59,8 @@ schema: show
<hr />
{% endif %}
{% render "partials/blocks/associated-media.liquid", posts:show.posts %}
{% render "partials/blocks/associated-media.liquid", artists:show.artists %}
{% render "partials/blocks/associated-media.liquid", shows:show.relatedShows %}
{% render "partials/blocks/associated-media.liquid", movies:show.movies %}
{% render "partials/blocks/associated-media.liquid", books:show.books %}
{% if show.description %}