diff --git a/package.json b/package.json index 41c61e35..6555a92d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "14.6.0", + "version": "14.6.1", "description": "The source for my personal site. Built using 11ty.", "type": "module", "scripts": { diff --git a/src/_data/movies.js b/src/_data/movies.js index d2f86fb8..6b62da50 100644 --- a/src/_data/movies.js +++ b/src/_data/movies.js @@ -22,7 +22,6 @@ export default async function () { if (error) return [] - const formatMovieData = (movies) => movies.map((item) => { const movie = { title: item['title'], @@ -31,6 +30,7 @@ export default async function () { description: `

${item['title']} (${item['year']})

Watched at: ${DateTime.fromISO(item['last_watched'], { zone: 'utc' }).setZone('America/Los_Angeles').toFormat('MMMM d, yyyy, h:mma')}

`, type: 'movie', image: `https://coryd.dev/media/movies/poster-${item['tmdb_id']}.jpg`, + backdrop: `https://coryd.dev/media/movies/backdrops/backdrop-${item['tmdb_id']}.jpg`, plays: item['plays'], collected: item['collected'], favorite: item['favorite'], @@ -38,9 +38,14 @@ export default async function () { return movie; }) + const favoriteMovies = movies.filter(movie => movie['favorite']) + const collectedMovies = movies.filter(movie => movie['collected']) + return { movies, watchHistory: formatMovieData(movies), recentlyWatched: formatMovieData(movies.slice(0, 6)), + favorites: formatMovieData(favoriteMovies), + collection: formatMovieData(collectedMovies), } } \ No newline at end of file diff --git a/src/_data/tv.js b/src/_data/tv.js index 794e2699..2a4c3058 100644 --- a/src/_data/tv.js +++ b/src/_data/tv.js @@ -26,15 +26,15 @@ export default async function () { show.episodes.forEach(episode => { episodes.push({ ...episode, - show_title: show.title, - show_tmdb_id: show.tmdb_id, - collected: show.collected, - favorite: show.favorite + show_title: show['title'], + show_tmdb_id: show['tmdb_id'], + collected: show['collected'], + favorite: show['favorite'] }) }) }) - episodes.sort((a, b) => new Date(b.last_watched_at) - new Date(a.last_watched_at)) + episodes.sort((a, b) => new Date(b['last_watched_at']) - new Date(a['last_watched_at'])) const allEpisodes = episodes episodes = episodes.slice(0, 75) @@ -43,13 +43,13 @@ export default async function () { const showEpisodesMap = {} episodes.forEach((episode) => { - const showTitle = episode.show_title - const showTmdbId = episode.show_tmdb_id - const episodeNumber = episode.episode_number - const seasonNumber = episode.season_number - const lastWatchedAt = episode.last_watched_at - const collected = episode.collected - const favorite = episode.favorite + const showTitle = episode['show_title'] + const showTmdbId = episode['show_tmdb_id'] + const episodeNumber = episode['episode_number'] + const seasonNumber = episode['season_number'] + const lastWatchedAt = episode['last_watched_at'] + const collected = episode['collected'] + const favorite = episode['favorite'] if (!showEpisodesMap[showTmdbId]) { showEpisodesMap[showTmdbId] = { @@ -70,37 +70,39 @@ export default async function () { tmdbId: showTmdbId, type: 'tv', image: `https://coryd.dev/media/shows/poster-${showTmdbId}.jpg`, + backdrop: `https://coryd.dev/media/shows/backdrops/backdrop-${showTmdbId}.jpg`, lastWatchedAt: lastWatchedAt }) }) - const sortedShows = Object.values(showEpisodesMap).sort((a, b) => new Date(b.episodes[0].lastWatchedAt) - new Date(a.episodes[0].lastWatchedAt)) + const sortedShows = Object.values(showEpisodesMap).sort((a, b) => new Date(b['episodes'][0]['lastWatchedAt']) - new Date(a['episodes'][0]['lastWatchedAt'])) sortedShows.forEach((show) => { - const startingEpisode = show.episodes[show.episodes.length - 1].episode - const startingSeason = show.episodes[show.episodes.length - 1].season - const endingEpisode = show.episodes[0].episode - const endingSeason = show.episodes[0].season + const startingEpisode = show['episodes'][show['episodes'].length - 1]['episode'] + const startingSeason = show['episodes'][show['episodes'].length - 1]['season'] + const endingEpisode = show['episodes'][0]['episode'] + const endingSeason = show['episodes'][0]['season'] if (show.episodes.length > 1) { episodeData.push({ name: show.title, - url: `https://www.themoviedb.org/tv/${show.tmdbId}`, + url: `https://www.themoviedb.org/tv/${show['tmdbId']}`, subtext: `S${startingSeason}E${startingEpisode} - S${endingSeason}E${endingEpisode}`, startingEpisode, startingSeason, episode: endingEpisode, season: endingSeason, - tmdbId: show.tmdbId, - collected: show.collected, - favorite: show.favorite, + tmdbId: show['tmdbId'], + collected: show['collected'], + favorite: show['favorite'], type: 'tv-range', - image: `https://coryd.dev/media/shows/poster-${show.tmdbId}.jpg`, + image: `https://coryd.dev/media/shows/poster-${show['tmdbId']}.jpg`, + backdrop: `https://coryd.dev/media/shows/backdrops/backdrop-${show['tmdbId']}.jpg`, }) } else { - const singleEpisode = show.episodes[0] - singleEpisode.collected = show.collected - singleEpisode.favorite = show.favorite + const singleEpisode = show['episodes'][0] + singleEpisode.collected = show['collected'] + singleEpisode.favorite = show['favorite'] episodeData.push(singleEpisode) } }) @@ -108,9 +110,26 @@ export default async function () { return episodeData } + const favoriteShows = shows.filter(show => show['favorite']) + const collectedShows = shows.filter(show => show['collected']) + return { shows, watchHistory: formatEpisodeData(allEpisodes), - recentlyWatched: formatEpisodeData(episodes) + recentlyWatched: formatEpisodeData(episodes), + favorites: formatEpisodeData(favoriteShows.flatMap(show => show['episodes'].map(episode => ({ + ...episode, + show_title: show['title'], + show_tmdb_id: show['tmdb_id'], + collected: show['collected'], + favorite: show['favorite'] + })))), + collection: formatEpisodeData(collectedShows.flatMap(show => show['episodes'].map(episode => ({ + ...episode, + show_title: show['title'], + show_tmdb_id: show['tmdb_id'], + collected: show['collected'], + favorite: show['favorite'] + })))) } -} \ No newline at end of file +}