From 5bc0c97537eb5ac08eb1e82e7b281e09d883435d Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Sat, 20 Apr 2024 14:05:40 -0700 Subject: [PATCH] feat: movie tags --- config/collections/index.js | 10 ++++++++++ config/data/tag-aliases.js | 5 +++++ config/filters/index.js | 6 +++--- package.json | 2 +- src/_data/movies.js | 4 ++-- src/_data/tv.js | 1 - 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/config/collections/index.js b/config/collections/index.js index 95755658..63ecc56a 100644 --- a/config/collections/index.js +++ b/config/collections/index.js @@ -51,6 +51,7 @@ export const tagMap = (collection) => { const posts = collectionData.data.collections.posts const links = collectionData.data.collections.links const books = collectionData.data.books + const movies = collectionData.data.movies if (posts) { posts.forEach((post) => { @@ -81,6 +82,15 @@ export const tagMap = (collection) => { }) } + if (movies) { + movies.forEach((movie) => { + const tagString = movie['tags']?.map((tag) => tagAliases[tag.toLowerCase()]) + .join(' ') + .trim() + if (tagString) tags[movie.url] = tagString.replace(/\s+/g,' ') + }) + } + return tags } diff --git a/config/data/tag-aliases.js b/config/data/tag-aliases.js index 22f66cf4..14d88578 100644 --- a/config/data/tag-aliases.js +++ b/config/data/tag-aliases.js @@ -1,6 +1,8 @@ export default { '11ty': '#Eleventy', accessibility: '#Accessibility', + action: '#Action', + adventure: '#Adventure', ai: '#AI', 'black metal': '#BlackMetal', blogging: '#Blogging', @@ -19,6 +21,7 @@ export default { grindcore: '#Grindcore', health: '#Health', 'indie web': '#IndieWeb #SmallWeb', + 'horror': '#Horror', ios: '#iOS #Apple', javascript: '#JavaScript', 'last.fm': '#Music', @@ -36,6 +39,7 @@ export default { rss: '#RSS', shoegaze: '#Shoegaze', scifi: '#SciFi', + 'science-fiction': '#SciFi', 'social media': '#SocialMedia', spotify: '#Music', 'surveillance capitalism': '#SurveillanceCapitalism', @@ -43,6 +47,7 @@ export default { tech: '#Tech', television: '#TV', technology: '#Tech', + thriller: '#Thriller', tv: '#TV', 'web components': '#WebComponents' } \ No newline at end of file diff --git a/config/filters/index.js b/config/filters/index.js index 170d9ee7..d21b2ab6 100644 --- a/config/filters/index.js +++ b/config/filters/index.js @@ -60,11 +60,11 @@ export default { return visitors(b) - visitors(a) }) }, - + tagLookup: (url, tagMap) => { if (!url) return - if (url.includes('openlibrary.org')) return `#Books #NowReading ${tagMap[url]}` - if (url.includes('trakt.tv')) return '#Movies #Watching #Trakt' + if (url.includes('openlibrary.org')) return `#Books #NowReading ${tagMap[url]}`.trim() + if (url.includes('trakt.tv')) return `#Movies #Watching ${tagMap[url]}`.trim() return tagMap[url] || '' }, diff --git a/package.json b/package.json index a455c557..11d48e55 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "12.4.0", + "version": "12.5.0", "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 c9f391a4..757d0a33 100644 --- a/src/_data/movies.js +++ b/src/_data/movies.js @@ -12,9 +12,9 @@ export default async function () { id: item['movie']['ids']['trakt'], tmdbId: item['movie']['ids']['tmdb'], description: `${item['movie']['overview']}

`, + tags: item['movie']['genres'], type: 'movie', } - if (process.env.ELEVENTY_PRODUCTION === 'false') movie.image = 'https://cd-movies.b-cdn.net' return movie; }) @@ -41,7 +41,7 @@ export default async function () { }) const tmdbData = await tmdbRes const posterPath = tmdbData['poster_path'] - movie.image = `https://cd-movies.b-cdn.net/t/p/w500${posterPath}` + movie.image = `https://image.tmdb.org/t/p/w500/${posterPath}` } return movies; } diff --git a/src/_data/tv.js b/src/_data/tv.js index 0c5fb51a..e1ebf4a5 100644 --- a/src/_data/tv.js +++ b/src/_data/tv.js @@ -53,7 +53,6 @@ export default async function () { type: 'tv', }) } - if (process.env.ELEVENTY_PRODUCTION === 'false') episodeData[episodeData.length - 1].image = 'https://cd-movies.b-cdn.net' }) return episodeData.reverse()