diff --git a/README.md b/README.md index 4a941030..7c0f3f59 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,6 @@ Hi! I'm Cory. 👋🏻 This is the code for my personal website and portfolio. Built using [11ty](https://www.11ty.dev). -[![Follow @cory@social.lol on Mastodon](https://cdn.coryd.dev/assets/badges/mastodon.png?class=w200)](https://social.lol/@cory) [![Buy me a Coffee](https://cdn.coryd.dev/assets/badges/buymeacoffee.png?class=w200)](https://www.buymeacoffee.com/cory) [![Made with 11ty](https://cdn.coryd.dev/assets/badges/eleventy.png?class=w200)](https://eleventy.dev) +[![Follow @cory@social.lol on Mastodon](https://cdn.coryd.dev/aec0ea1d-5234-40b3-b7c4-9705fd9cd0e4.png?class=w200)](https://social.lol/@cory) [![Buy me a Coffee](https://cdn.coryd.dev/f5b2cae1-331a-4ea0-9962-58ac429cac4a.png?class=w200)](https://www.buymeacoffee.com/cory) [![Made with 11ty](https://cdn.coryd.dev/03c57479-cfa6-423f-8f60-87f3bbef156c.png?class=w200)](https://eleventy.dev) [Music](https://coryd.dev/music) / [Watching](https://coryd.dev/watching) / [Books](https://coryd.dev/books) / [Now](https://coryd.dev/now) diff --git a/_redirects b/_redirects index bc77c08c..cd0ccd9c 100644 --- a/_redirects +++ b/_redirects @@ -60,21 +60,6 @@ robotx.txt /robots.txt 301 /watching/movies-to-watch /watching 301 /blog/digital-privacy-tools /posts/2021/digital-privacy-tools/ 301 -# assets -/favicon.ico https://cdn.coryd.dev/assets/icons/favicon.ico 301 -/assets/icons/favicon.ico https://cdn.coryd.dev/assets/icons/favicon.ico 301 -/apple-touch-icon.png https://cdn.coryd.dev/assets/icons/apple-touch-icon.png 301 -/apple-touch-icon https://cdn.coryd.dev/assets/icons/apple-touch-icon.png 301 -/apple-touch-icon-precomposed.png https://cdn.coryd.dev/assets/icons/apple-touch-icon.png 301 -/assets/icons/apple-touch-icon.png https://cdn.coryd.dev/assets/icons/apple-touch-icon.png 301 -/assets/img/feed-icon.png https://cdn.coryd.dev/assets/icons/apple-touch-icon.png 301 -/assets/img/logo.webp https://cdn.coryd.dev/assets/avatar.webp 301 -/static/favicons/apple-touch-icon.png https://cdn.coryd.dev/assets/icons/apple-touch-icon.png 301 -/static/images/avatar.png https://cdn.coryd.dev/assets/avatar.png 301 -/static/images/avatar.webp https://cdn.coryd.dev/assets/avatar.webp 301 -/assets/img/favicon/favicon-32x32.png https://cdn.coryd.dev/assets/icons/favicon.ico 301 -/assets/img/favicon/favicon-16x16.png https://cdn.coryd.dev/assets/icons/favicon.ico 301 - # feeds /rss https://feedpress.me/coryd 301 /atom https://feedpress.me/coryd 301 @@ -98,4 +83,5 @@ robotx.txt /robots.txt 301 /coffee https://www.buymeacoffee.com/cory 301 /tags /search 301 /tags/* /search 301 -/music/genre/* /music/genres/:splat 301 \ No newline at end of file +/music/genre/* /music/genres/:splat 301 +/reading /books \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 604743be..4f5b054f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "coryd.dev", - "version": "19.10.11", + "version": "20.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "coryd.dev", - "version": "19.10.11", + "version": "20.0.0", "license": "MIT", "dependencies": { "@cdransf/api-text": "^1.4.0", @@ -24,14 +24,14 @@ "@supabase/supabase-js": "^2.44.3", "dotenv-flow": "^4.1.0", "html-minifier-terser": "^7.2.0", - "liquidjs": "^10.14.0", + "liquidjs": "^10.15.0", "luxon": "^3.4.4", "markdown-it": "^14.1.0", "markdown-it-anchor": "^9.0.1", "markdown-it-footnote": "^4.0.0", "sanitize-html": "^2.13.0", "slugify": "^1.6.6", - "terser": "^5.31.1" + "terser": "^5.31.2" } }, "node_modules/@11ty/dependency-tree": { @@ -335,9 +335,9 @@ } }, "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.15", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", - "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", "dev": true, "license": "MIT" }, @@ -755,9 +755,9 @@ } }, "node_modules/browserslist": { - "version": "4.23.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.1.tgz", - "integrity": "sha512-TUfofFo/KsK/bWZ9TWQ5O26tsWW4Uhmt8IYklbnUa70udB6P2wA7w7o4PY4muaEPBQaAX+CEnmmIA41NVHtPVw==", + "version": "4.23.2", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.2.tgz", + "integrity": "sha512-qkqSyistMYdxAcw+CzbZwlBy8AGmS/eEWs+sEV5TnLRGDOL+C5M2EnH6tlZyg0YoAxGJAFKh61En9BR941GnHA==", "dev": true, "funding": [ { @@ -775,10 +775,10 @@ ], "license": "MIT", "dependencies": { - "caniuse-lite": "^1.0.30001629", - "electron-to-chromium": "^1.4.796", + "caniuse-lite": "^1.0.30001640", + "electron-to-chromium": "^1.4.820", "node-releases": "^2.0.14", - "update-browserslist-db": "^1.0.16" + "update-browserslist-db": "^1.1.0" }, "bin": { "browserslist": "cli.js" @@ -826,9 +826,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001640", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001640.tgz", - "integrity": "sha512-lA4VMpW0PSUrFnkmVuEKBUovSWKhj7puyCg8StBChgu298N1AtuF1sKWEvfDuimSEDbhlb/KqPKC3fs1HbuQUA==", + "version": "1.0.30001641", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001641.tgz", + "integrity": "sha512-Phv5thgl67bHYo1TtMY/MurjkHhV4EDaCosezRXgZ8jzA/Ub+wjxAvbGvjoFENStinwi5kCyOYV3mi5tOGykwA==", "dev": true, "funding": [ { @@ -1157,9 +1157,9 @@ "license": "MIT" }, "node_modules/electron-to-chromium": { - "version": "1.4.818", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.818.tgz", - "integrity": "sha512-eGvIk2V0dGImV9gWLq8fDfTTsCAeMDwZqEPMr+jMInxZdnp9Us8UpovYpRCf9NQ7VOFgrN2doNSgvISbsbNpxA==", + "version": "1.4.823", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.823.tgz", + "integrity": "sha512-4h+oPeAiGQOHFyUJOqpoEcPj/xxlicxBzOErVeYVMMmAiXUXsGpsFd0QXBMaUUbnD8hhSfLf9uw+MlsoIA7j5w==", "dev": true, "license": "ISC" }, @@ -2153,9 +2153,9 @@ } }, "node_modules/liquidjs": { - "version": "10.14.0", - "resolved": "https://registry.npmjs.org/liquidjs/-/liquidjs-10.14.0.tgz", - "integrity": "sha512-Zjg35Yo3L/2aNy7QkICha/ulbXRtZS7oRenWyDDfw+J34Xy3fOKWWHxASC9r0gbxN661nrwmG/kOIKHfYcVk4Q==", + "version": "10.15.0", + "resolved": "https://registry.npmjs.org/liquidjs/-/liquidjs-10.15.0.tgz", + "integrity": "sha512-u5lYWhW8ioT+O3FdCcp5U+hiPEGNO4xASCFlCHA+k5rMTJwDIa2c2KF111ZDKc2xGM7LXPvMoNRIrBfbLNpRBg==", "dev": true, "license": "MIT", "dependencies": { @@ -3321,9 +3321,9 @@ } }, "node_modules/terser": { - "version": "5.31.1", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.31.1.tgz", - "integrity": "sha512-37upzU1+viGvuFtBo9NPufCb9dwM0+l9hMxYyWfBA+fbwrPqNJAhbZ6W47bBFnZHKHTUBnMvi87434qq+qnxOg==", + "version": "5.31.2", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.31.2.tgz", + "integrity": "sha512-LGyRZVFm/QElZHy/CPr/O4eNZOZIzsrQ92y4v9UJe/pFJjypje2yI3C2FmPtvUEnhadlSbmG2nXtdcjHOjCfxw==", "dev": true, "license": "BSD-2-Clause", "dependencies": { diff --git a/package.json b/package.json index d0a124b4..7f716747 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "19.10.11", + "version": "20.0.0", "description": "The source for my personal site. Built using 11ty.", "type": "module", "scripts": { @@ -34,13 +34,13 @@ "@supabase/supabase-js": "^2.44.3", "dotenv-flow": "^4.1.0", "html-minifier-terser": "^7.2.0", - "liquidjs": "^10.14.0", + "liquidjs": "^10.15.0", "luxon": "^3.4.4", "markdown-it": "^14.1.0", "markdown-it-anchor": "^9.0.1", "markdown-it-footnote": "^4.0.0", "sanitize-html": "^2.13.0", "slugify": "^1.6.6", - "terser": "^5.31.1" + "terser": "^5.31.2" } } diff --git a/src/_data/artists.js b/src/_data/artists.js index f68d5aa2..212895e1 100644 --- a/src/_data/artists.js +++ b/src/_data/artists.js @@ -54,7 +54,7 @@ const fetchGenreMapping = async () => { export default async function () { const genreMapping = await fetchGenreMapping() - const artists = await fetchPaginatedData('artists', 'id, mbid, name_string, image, total_plays, country, description, favorite, tattoo, genres') + const artists = await fetchPaginatedData('artists', 'id, mbid, name_string, art(filename_disk), total_plays, country, description, favorite, tattoo, genres') const albums = await fetchPaginatedData('albums', 'mbid, name, release_year, total_plays, artist') const albumsByArtist = albums.reduce((acc, album) => { if (!acc[album.artist]) acc[album.artist] = [] @@ -68,9 +68,10 @@ export default async function () { }, {}) for (const artist of artists) { - artist.albums = albumsByArtist[artist.id]?.sort((a, b) => a['release_year'] - b['release_year']) || [] - artist.country = parseCountryField(artist.country) - artist.genres = genreMapping[artist.genres] || '' + artist.albums = albumsByArtist[artist['id']]?.sort((a, b) => a['release_year'] - b['release_year']) || [] + artist.image = `/${artist['art']['filename_disk']}` + artist.country = parseCountryField(artist['country']) + artist.genres = genreMapping[artist['genres']] || '' } return artists diff --git a/src/_data/badges.js b/src/_data/badges.js new file mode 100644 index 00000000..5fec133a --- /dev/null +++ b/src/_data/badges.js @@ -0,0 +1,30 @@ +import { createClient } from '@supabase/supabase-js' + +const SUPABASE_URL = process.env.SUPABASE_URL +const SUPABASE_KEY = process.env.SUPABASE_KEY +const supabase = createClient(SUPABASE_URL, SUPABASE_KEY) + +const fetchAllBadges = async () => { + const { data, error } = await supabase + .from('badges') + .select(` + *, + image(filename_disk) + `) + + if (error) { + console.error('Error fetching badge data:', error) + return null + } + + const transformedData = data.map(badge => ({ + ...badge, + image: badge['image']['filename_disk'], + })) + + return transformedData +} + +export default async function () { + return await fetchAllBadges() +} \ No newline at end of file diff --git a/src/_data/books.js b/src/_data/books.js index 05e355a2..4a738a56 100644 --- a/src/_data/books.js +++ b/src/_data/books.js @@ -28,7 +28,7 @@ async function fetchAllBooks() { while (true) { const { data, error } = await supabase .from('books') - .select('*') + .select(`*, art(filename_disk)`) .range(from, to) if (error) { @@ -60,7 +60,7 @@ export default async function () { review: book['review'], rating: book['star_rating'] !== 'unrated' ? book['star_rating'] : '', description: book['description'], - image: book['thumbnail'], + image: `/${book?.['art']?.['filename_disk']}`, url: `/books/${book['isbn']}`, date: book['date_finished'], status: book['read_status'], diff --git a/src/_data/globals.js b/src/_data/globals.js new file mode 100644 index 00000000..30e3c89a --- /dev/null +++ b/src/_data/globals.js @@ -0,0 +1,52 @@ +import { createClient } from '@supabase/supabase-js' + +const SUPABASE_URL = process.env['SUPABASE_URL'] +const SUPABASE_KEY = process.env['SUPABASE_KEY'] +const supabase = createClient(SUPABASE_URL, SUPABASE_KEY) + +export default async function () { + const { data, error } = await supabase + .from('globals') + .select(` + *, + favicon_ico(filename_disk), + favicon_svg(filename_disk), + opengraph_default(filename_disk), + feed_image(filename_disk), + apple_touch_icon(filename_disk), + about(filename_disk), + page_404(filename_disk), + page_broken(filename_disk), + page_not_allowed(filename_disk), + page_stop(filename_disk), + logo_the_claw(filename_disk) + `) + + if (error) { + console.error('Error fetching globals:', error) + return {} + } + + const globalData = data.pop() + const keysToProcess = [ + 'favicon_ico', + 'favicon_svg', + 'opengraph_default', + 'feed_image', + 'apple_touch_icon', + 'about', + 'page_404', + 'page_broken', + 'page_not_allowed', + 'page_stop', + 'logo_the_claw' + ] + + keysToProcess.forEach(key => { + if (globalData[key] && globalData[key].filename_disk) { + globalData[key] = globalData[key].filename_disk + } + }) + + return globalData +} \ No newline at end of file diff --git a/src/_data/meta.js b/src/_data/meta.js deleted file mode 100644 index 5dfc3973..00000000 --- a/src/_data/meta.js +++ /dev/null @@ -1,16 +0,0 @@ -export default async function () { - return { - "siteName": "Cory Dransfeldt", - "siteDescription": "I'm a software developer in Camarillo, California. I write about software development, technology and music.", - "author": "Cory Dransfeldt", - "email": "hi@coryd.dev", - "url": "https://coryd.dev", - "themeColor": "#3b82f6", - "siteType": "Person", - "locale": "en_US", - "lang": "en", - "meta_data": { - "opengraph_default": "https://cdn.coryd.dev/assets/avatar.png" - } - } -} diff --git a/src/_data/movies.js b/src/_data/movies.js index 8d68cc92..5aa1e9a1 100644 --- a/src/_data/movies.js +++ b/src/_data/movies.js @@ -30,7 +30,6 @@ const fetchAllMovies = async () => { .select(` id, tmdb_id, - slug, last_watched, title, year, @@ -39,7 +38,9 @@ const fetchAllMovies = async () => { favorite, star_rating, description, - review + review, + art(filename_disk), + backdrop(filename_disk) `) .order('last_watched', { ascending: false }) .range(rangeStart, rangeStart + PAGE_SIZE - 1) @@ -73,8 +74,8 @@ export default async function () { year: item['year'], url: `/watching/movies/${item['tmdb_id']}`, description: `${item['title']} (${item['year']})
Watched at: ${DateTime.fromISO(item['last_watched'], { zone: 'utc' }).setZone('America/Los_Angeles').toFormat('MMMM d, yyyy, h:mma')}`, - image: `/movies/poster-${item['tmdb_id']}.jpg`, - backdrop: `/movies/backdrops/backdrop-${item['tmdb_id']}.jpg`, + image: `/${item?.['art']?.['filename_disk']}`, + backdrop: `/${item?.['backdrop']?.['filename_disk']}`, plays: item['plays'], collected: item['collected'], favorite: item['favorite'], diff --git a/src/_data/music.js b/src/_data/music.js index 968cf818..373c4603 100644 --- a/src/_data/music.js +++ b/src/_data/music.js @@ -61,7 +61,7 @@ const aggregateData = async (data, groupByField, groupByType) => { plays: 0, mbid: item['albums']['mbid'], url: `/music/artists/${sanitizeMediaString(item['artist_name'])}-${sanitizeMediaString(parseCountryField(item['artists']['country']))}`, - image: item['albums']?.['image'] || '', + image: `/${item['albums']?.['art']?.['filename_disk']}` || '', timestamp: item['listened_at'], type: groupByType, genre: genreMapping[item['artists']['genres']] || '' @@ -72,7 +72,7 @@ const aggregateData = async (data, groupByField, groupByType) => { plays: 0, mbid: item[groupByType]?.['mbid'] || '', url: `/music/artists/${sanitizeMediaString(item['artist_name'])}-${sanitizeMediaString(parseCountryField(item['artists']['country']))}`, - image: item[groupByType]?.image || '', + image: `/${item[groupByType]?.['art']?.['filename_disk']}` || '', type: groupByType, genre: genreMapping[item['artists']['genres']] || '' } @@ -97,7 +97,7 @@ const buildRecents = async (data) => { artist: listen['artist_name'], url: `/music/artists/${sanitizeMediaString(listen['artist_name'])}-${sanitizeMediaString(parseCountryField(listen['artists']['country']))}`, timestamp: listen['listened_at'], - image: listen['albums']?.['image'] || '' + image: `/${listen['albums']?.['art']?.['filename_disk']}` || '' })) } @@ -128,8 +128,8 @@ export default async function() { album_name, album_key, listened_at, - artists (mbid, image, genres, country), - albums (mbid, image) + artists (mbid, art(filename_disk), genres, country), + albums (mbid, art(filename_disk)) ` for (const [period, startPeriod] of Object.entries(periods)) { diff --git a/src/_data/posts.js b/src/_data/posts.js index eef98114..adaa4c10 100644 --- a/src/_data/posts.js +++ b/src/_data/posts.js @@ -66,7 +66,10 @@ const fetchAllPosts = async () => { while (fetchMore) { const { data, error } = await supabase .from('posts') - .select('*') + .select(` + *, + image(filename_disk) + `) .order('date', { ascending: false }) .range(page * PAGE_SIZE, (page + 1) * PAGE_SIZE - 1) @@ -78,17 +81,17 @@ const fetchAllPosts = async () => { if (data.length < PAGE_SIZE) fetchMore = false for (const post of data) { - if (uniqueSlugs.has(post.slug)) continue + if (uniqueSlugs.has(post['slug'])) continue uniqueSlugs.add(post.slug) - post.tags = await fetchTagsForPost(post.id) - post.blocks = await fetchBlocksForPost(post.id) + post['tags'] = await fetchTagsForPost(post['id']) + post['blocks'] = await fetchBlocksForPost(post['id']) + if (post?.['image']?.['filename_disk']) post['image'] = post['image']['filename_disk'] posts.push(post) } page++ } - return posts } diff --git a/src/_data/tv.js b/src/_data/tv.js index 7ed20d9d..284c046c 100644 --- a/src/_data/tv.js +++ b/src/_data/tv.js @@ -1,7 +1,7 @@ import { createClient } from '@supabase/supabase-js' -const SUPABASE_URL = process.env.SUPABASE_URL -const SUPABASE_KEY = process.env.SUPABASE_KEY +const SUPABASE_URL = process.env['SUPABASE_URL'] +const SUPABASE_KEY = process.env['SUPABASE_KEY'] const supabase = createClient(SUPABASE_URL, SUPABASE_KEY) const PAGE_SIZE = 1000 @@ -21,6 +21,8 @@ const fetchAllShows = async () => { year, description, review, + art(filename_disk), + backdrop(filename_disk), episodes ( episode_number, season_number, @@ -35,7 +37,6 @@ const fetchAllShows = async () => { } shows = shows.concat(data) - if (data.length < PAGE_SIZE) break rangeStart += PAGE_SIZE } @@ -43,38 +44,47 @@ const fetchAllShows = async () => { return shows } +const prepareShowData = (show) => { + return { + ...show, + image: show.art?.filename_disk ? show.art.filename_disk : '', + backdrop: show.backdrop?.filename_disk ? show.backdrop.filename_disk : '' + } +} + +const prepareEpisodeData = (show) => { + return show.episodes.map(episode => ({ + ...episode, + show_title: show.title, + show_tmdb_id: show.tmdb_id, + collected: show.collected, + favorite: show.favorite, + image: show.image, + backdrop: show.backdrop + })) +} + export default async function () { - const shows = await fetchAllShows() + const rawShows = await fetchAllShows() + const shows = rawShows.map(prepareShowData) - let episodes = [] - shows.forEach(show => { - show.episodes.forEach(episode => { - episodes.push({ - ...episode, - show_title: show['title'], - show_tmdb_id: show['tmdb_id'], - collected: show['collected'], - favorite: show['favorite'], - year: show['year'] - }) - }) - }) + const episodes = shows.flatMap(prepareEpisodeData) + + 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 - const recentlyWatchedEpisodes = episodes.slice(0, 225) const formatEpisodeData = (episodes) => { - const episodeData = [] 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'] + 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 image = episode.image + const backdrop = episode.backdrop if (!showEpisodesMap[showTmdbId]) { showEpisodesMap[showTmdbId] = { @@ -84,7 +94,9 @@ export default async function () { favorite, dateAdded: lastWatchedAt, lastWatchedAt, - episodes: [] + episodes: [], + image, + backdrop } } @@ -96,41 +108,44 @@ export default async function () { season: seasonNumber, tmdbId: showTmdbId, type: 'tv', - image: `/shows/poster-${showTmdbId}.jpg`, - backdrop: `/shows/backdrops/backdrop-${showTmdbId}.jpg`, dateAdded: lastWatchedAt, - lastWatchedAt + lastWatchedAt, + image, + backdrop }) }) - 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 episodeData = [] + 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 if (show.episodes.length > 1) { episodeData.push({ - name: show['title'], - url: `/watching/shows/${show['tmdbId']}`, + name: show.title, + url: `/watching/shows/${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: `/shows/poster-${show['tmdbId']}.jpg`, - backdrop: `/shows/backdrops/backdrop-${show['tmdbId']}.jpg`, + image: show.image, + backdrop: show.backdrop }) } 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 + singleEpisode.image = show.image + singleEpisode.backdrop = show.backdrop episodeData.push(singleEpisode) } }) @@ -138,20 +153,12 @@ export default async function () { return episodeData } - const favoriteShows = shows.filter(show => show['favorite']) - const collectedShows = shows.filter(show => show['collected']) - const toWatch = shows.map(show => ({...show, url: `/watching/shows/${show['tmdb_id']}`})).filter(show => !show.episodes.some(episode => episode.last_watched_at)).sort((a, b) => a['title'].localeCompare(b['title'])) + const favoriteShows = shows.filter(show => show.favorite) return { shows, - watchHistory: formatEpisodeData(allEpisodes), - recentlyWatched: formatEpisodeData(recentlyWatchedEpisodes), - 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'] - })))).sort((a, b) => a['name'].localeCompare(b['name'])) + watchHistory: formatEpisodeData(episodes), + recentlyWatched: formatEpisodeData(episodes.slice(0, 225)), + favorites: formatEpisodeData(favoriteShows.flatMap(prepareEpisodeData)).sort((a, b) => a.name.localeCompare(b.name)) } } \ No newline at end of file diff --git a/src/_includes/base.liquid b/src/_includes/base.liquid index e68dfc3b..576bb734 100644 --- a/src/_includes/base.liquid +++ b/src/_includes/base.liquid @@ -1,31 +1,31 @@ -{%- assign fullUrl = meta.url | append: page.url -%} +{%- assign fullUrl = globals.url | append: page.url -%} -{%- assign pageTitle = meta.siteName -%} +{%- assign pageTitle = globals.site_name -%} {%- if schema == 'blog' -%} {%- assign pageTitle = post.title -%} {%- elsif title -%} - {%- assign pageTitle = title | append: ' / ' | append: meta.siteName -%} + {%- assign pageTitle = title | append: ' / ' | append: globals.site_name -%} {%- elsif artist.name_string -%} - {%- assign pageTitle = 'Artists / ' | append: artist.name_string | append: ' / ' | append: meta.siteName -%} + {%- assign pageTitle = 'Artists / ' | append: artist.name_string | append: ' / ' | append: globals.site_name -%} {%- elsif schema == 'music-index' -%} - {%- assign pageTitle = 'Music / ' | append: meta.siteName -%} + {%- assign pageTitle = 'Music / ' | append: globals.site_name -%} {%- elsif schema == 'music-period' -%} - {%- assign pageTitle = 'Music / ' | append: page.title | append: meta.siteName -%} + {%- assign pageTitle = 'Music / ' | append: page.title | append: globals.site_name -%} {%- elsif genre.name -%} - {%- assign pageTitle = 'Music / ' | append: genre.name | append: ' / ' | append: meta.siteName -%} + {%- assign pageTitle = 'Music / ' | append: genre.name | append: ' / ' | append: globals.site_name -%} {%- elsif book.title -%} - {%- assign pageTitle = 'Books / ' | append: book.title | append: ' / ' | append: meta.siteName -%} + {%- assign pageTitle = 'Books / ' | append: book.title | append: ' / ' | append: globals.site_name -%} {%- elsif movie.title -%} {%- assign pageTitle = 'Movies / ' | append: movie.title -%} {%- if movie.rating -%} {%- assign pageTitle = pageTitle | append: ' (' | append: movie.rating | append: ')' -%} {%- endif -%} - {%- assign pageTitle = pageTitle | append: ' / ' | append: meta.siteName -%} + {%- assign pageTitle = pageTitle | append: ' / ' | append: globals.site_name -%} {%- elsif show.title -%} - {%- assign pageTitle = 'Shows / ' | append: show.title | append: ' / ' | append: meta.siteName -%} + {%- assign pageTitle = 'Shows / ' | append: show.title | append: ' / ' | append: globals.site_name -%} {%- endif -%} -{%- assign pageDescription = meta.siteDescription -%} +{%- assign pageDescription = globals.site_description -%} {%- if schema == 'blog' -%} {%- assign pageDescription = post.description | markdown | strip_html -%} {%- elsif artist.description -%} @@ -42,7 +42,7 @@ {%- assign pageDescription = description -%} {%- endif -%} -{%- assign ogImage = meta.meta_data.opengraph_default -%} +{%- assign ogImage = globals.opengraph_default -%} {%- case schema -%} {%- when 'music' -%} {%- assign ogImage = 'https://cdn.coryd.dev' | append: page.image -%} @@ -64,7 +64,7 @@ {%- when 'movie' -%} {%- assign ogImage = 'https://cdn.coryd.dev' | append: movie.backdrop -%} {%- when 'show' -%} - {%- assign ogImage = 'https://cdn.coryd.dev/shows/backdrops/backdrop-' | append: show.tmdb_id | append: '.jpg' -%} + {%- assign ogImage = 'https://cdn.coryd.dev/shows/backdrops/backdrop-' | append: show.backdrop -%} {%- when 'genre' -%} {%- assign genreArtist = genre.artists | shuffleArray | first -%} {%- assign ogImage = 'https://cdn.coryd.dev' | append: genreArtist.image -%} @@ -85,21 +85,21 @@ - + - - - + + + - - - - - - + + + + + +