diff --git a/.eleventy.js b/.eleventy.js index 39b66d8f..c3251fac 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -34,18 +34,21 @@ export default async function (eleventyConfig) { eleventyConfig.addPassthroughCopy('src/assets') eleventyConfig.addPassthroughCopy('_redirects') eleventyConfig.addPassthroughCopy('_headers') - eleventyConfig.addPassthroughCopy({ - 'node_modules/minisearch/dist/umd/index.js': 'assets/scripts/components/minisearch.js', - }) eleventyConfig.addPassthroughCopy({ 'node_modules/@cdransf/api-text/api-text.js': 'assets/scripts/components/api-text.js', }) eleventyConfig.addPassthroughCopy({ - 'node_modules/@cdransf/theme-toggle/theme-toggle.js': 'assets/scripts/components/theme-toggle.js', + 'node_modules/@daviddarnes/mastodon-post/mastodon-post.js': 'assets/scripts/components/mastodon-post.js' + }) + eleventyConfig.addPassthroughCopy({ + 'node_modules/minisearch/dist/umd/index.js': 'assets/scripts/components/minisearch.js', }) eleventyConfig.addPassthroughCopy({ 'node_modules/@cdransf/select-pagination/select-pagination.js': 'assets/scripts/components/select-pagination.js', }) + eleventyConfig.addPassthroughCopy({ + 'node_modules/@cdransf/theme-toggle/theme-toggle.js': 'assets/scripts/components/theme-toggle.js', + }) eleventyConfig.addPassthroughCopy({ 'node_modules/youtube-video-element/youtube-video-element.js': 'assets/scripts/components/youtube-video-element.js' }) diff --git a/config/filters/general.js b/config/filters/general.js index cb394bc3..ce74d5e6 100644 --- a/config/filters/general.js +++ b/config/filters/general.js @@ -1,5 +1,5 @@ import sanitizeHtml from 'sanitize-html' -import { shuffleArray, sanitizeMediaString } from '../utilities/index.js' +import { shuffleArray } from '../utilities/index.js' const BASE_URL = 'https://coryd.dev' @@ -12,7 +12,6 @@ export default { }, formatNumber: (number) => number.toLocaleString('en-US'), shuffleArray, - sanitizeMediaString, sanitizeHtml: (html) => sanitizeHtml(html, { textFilter: (text) => text.replace(/"/g, '') }), diff --git a/config/filters/media.js b/config/filters/media.js index c86981fc..1a9dadae 100644 --- a/config/filters/media.js +++ b/config/filters/media.js @@ -1,5 +1,5 @@ import { DateTime } from 'luxon' -import { shuffleArray, sanitizeMediaString } from '../utilities/index.js' +import { shuffleArray } from '../utilities/index.js' export default { featuredWatching: (watching, count) => { @@ -81,7 +81,6 @@ export default { }, getLastWatched: (show) => show?.['episodes'][show['episodes']?.length - 1]?.['last_watched_at'], sortByPlaysDescending: (data, key) => data.sort((a, b) => b[key] - a[key]), - genreStrings: (genres, key) => genres.map(genre => genre[key]), mediaLinks: (data, type, count = 10) => { if (!data || !type) return '' @@ -90,25 +89,17 @@ export default { if (dataSlice.length === 0) return null if (dataSlice.length === 1) { const item = dataSlice[0] - if (type === 'genre') { - return `${item}` - } else if (type === 'artist') { - return `${item['name_string']}` + if (type === 'genre' || type === 'artist') { + return `${item['name']}` } else if (type === 'book') { - return `${item['title']}` - } else if (type === 'movie') { return `${item['title']}` } } const allButLast = dataSlice.slice(0, -1).map(item => { - if (type === 'genre') { - return `${item}` - } else if (type === 'artist') { - return `${item['name_string']}` + if (type === 'genre' || type === 'artist') { + return `${item['name']}` } else if (type === 'book') { - return `${item['title']}` - } else if (type === 'movie') { return `${item['title']}` } }).join(', ') @@ -116,15 +107,12 @@ export default { let last const lastItem = dataSlice[dataSlice.length - 1] - if (type === 'genre') { - last = `${lastItem}` - } else if (type === 'artist') { - last = `${lastItem['name_string']}` + if (type === 'genre' || type === 'artist') { + last = `${lastItem['name']}` } else if (type === 'book') { - last = `${lastItem['title']}` - } else if (type === 'movie') { last = `${lastItem['title']}` } + return `${allButLast} and ${last}` }, formatVenue: (venue) => venue.split(',')[0].trim(), diff --git a/config/utilities/index.js b/config/utilities/index.js index fdec5302..8dbc3b10 100644 --- a/config/utilities/index.js +++ b/config/utilities/index.js @@ -1,5 +1,3 @@ -import slugify from 'slugify' - export const shuffleArray = array => { for (let i = array.length - 1; i > 0; i--) { let j = Math.floor(Math.random() * (i + 1)) @@ -10,17 +8,6 @@ export const shuffleArray = array => { return array } -export const sanitizeMediaString = (str) => { - if (!str) return null - const sanitizedString = str.normalize('NFD').replace(/[\u0300-\u036f\u2010—\.\?\(\)\[\]\{\}]/g, '').replace(/\.{3}/g, '') - - return slugify(sanitizedString, { - replacement: '-', - remove: /[#,&,+()$~%.'":*?<>{}]/g, - lower: true, - }) -} - export const regionNames = new Intl.DisplayNames(['en'], { type: 'region' }) export const getCountryName = (countryCode) => regionNames.of(countryCode.trim()) || countryCode.trim() diff --git a/package-lock.json b/package-lock.json index 0cfb504f..532ff51c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@cdransf/api-text": "^1.5.0", "@cdransf/select-pagination": "^1.3.1", "@cdransf/theme-toggle": "^2.0.0", + "@daviddarnes/mastodon-post": "^1.3.0", "minisearch": "^7.1.0", "youtube-video-element": "^1.1.6" }, @@ -393,6 +394,12 @@ "integrity": "sha512-cB1/xUStNF3UzAL8E6DD5IDbegyLqncZUyiZkFfv/jkEU5OJquZnjLSg6zjHOQeMcCew3tapKfYDLTtEDkzHLA==", "license": "MIT" }, + "node_modules/@daviddarnes/mastodon-post": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@daviddarnes/mastodon-post/-/mastodon-post-1.3.0.tgz", + "integrity": "sha512-6AMQ/tl6uI3wXknv8exYJguym/bPHxIW5XOYg7aWCQtMbP4XUDAsWp2pv4o9wtesIF8K7CssNPR93qFOh7D8lw==", + "license": "MIT" + }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", diff --git a/package.json b/package.json index c19723dc..569656d4 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "@cdransf/api-text": "^1.5.0", "@cdransf/select-pagination": "^1.3.1", "@cdransf/theme-toggle": "^2.0.0", + "@daviddarnes/mastodon-post": "^1.3.0", "minisearch": "^7.1.0", "youtube-video-element": "^1.1.6" }, diff --git a/src/assets/styles/components/mastodon-post.css b/src/assets/styles/components/mastodon-post.css new file mode 100644 index 00000000..8a5454f2 --- /dev/null +++ b/src/assets/styles/components/mastodon-post.css @@ -0,0 +1,21 @@ +.mastodon-post-wrapper { + margin: var(--spacing-base) 0; + border-top: var(--border-gray); + padding-top: var(--sizing-base); + + & dl, dt { + display: flex; + } + + & dl { + align-items: center; + + & dd { + margin-left: var(--spacing-xs);; + + &:not(:last-child) { + margin-right: var(--spacing-lg); + } + } + } +} \ No newline at end of file diff --git a/src/assets/styles/index.css b/src/assets/styles/index.css index e4120c71..1d18aca8 100644 --- a/src/assets/styles/index.css +++ b/src/assets/styles/index.css @@ -30,6 +30,7 @@ @import url('./components/banners.css') layer(components); @import url('./components/buttons.css') layer(components); @import url('./components/forms.css') layer(components); +@import url('./components/mastodon-post.css') layer(components); @import url('./components/media-grid.css') layer(components); @import url('./components/menu.css') layer(components); @import url('./components/modal.css') layer(components); diff --git a/src/assets/styles/pages/post.css b/src/assets/styles/pages/post.css index 809a4467..ed55fa62 100644 --- a/src/assets/styles/pages/post.css +++ b/src/assets/styles/pages/post.css @@ -5,6 +5,7 @@ article.standalone .associated-media:last-of-type > hr { p + .associated-media, img + .associated-media, .banner + .associated-media, +.client-side + .associated-media, youtube-video + .associated-media { margin-top: var(--spacing-base); border-top: var(--border-gray); @@ -23,6 +24,10 @@ youtube-video + .associated-media { } } + &:has(+ .client-side > div) { + border-bottom: var(--border-gray); + } + & ~ youtube-video { margin-top: var(--spacing-base); } diff --git a/src/data/albumReleases.js b/src/data/albumReleases.js index 7ad04c10..b61c8f3e 100644 --- a/src/data/albumReleases.js +++ b/src/data/albumReleases.js @@ -1,5 +1,4 @@ import { createClient } from '@supabase/supabase-js' -import { sanitizeMediaString, parseCountryField } from '../../config/utilities/index.js' import { DateTime } from 'luxon' const SUPABASE_URL = process.env.SUPABASE_URL @@ -38,7 +37,7 @@ const fetchAlbumReleases = async () => { total_plays: album['artist_total_plays'], country: album['artist_country'], favorite: album['artist_favorite'], - url: `/music/artists/${sanitizeMediaString(album['artist_name'])}-${sanitizeMediaString(parseCountryField(album['artist_country']))}`, + url: album['artist_url'], }, title: album['name'], date: releaseDate.toLocaleString(DateTime.DATE_FULL), diff --git a/src/data/artists.js b/src/data/artists.js index 9fea5d1c..31c4b6a7 100644 --- a/src/data/artists.js +++ b/src/data/artists.js @@ -1,5 +1,5 @@ import { createClient } from '@supabase/supabase-js' -import { sanitizeMediaString, parseCountryField } from '../../config/utilities/index.js' +import { parseCountryField } from '../../config/utilities/index.js' const SUPABASE_URL = process.env.SUPABASE_URL const SUPABASE_KEY = process.env.SUPABASE_KEY @@ -15,8 +15,8 @@ const fetchAllArtists = async () => { .from('optimized_artists') .select(` id, - mbid, name_string, + url, tentative, total_plays, country, @@ -51,57 +51,49 @@ const fetchAllArtists = async () => { const processArtists = (artists) => { return artists.map(artist => ({ - id: artist['id'], - mbid: artist['mbid'], name: artist['name_string'], tentative: artist['tentative'], totalPlays: artist['total_plays'], country: parseCountryField(artist['country']), description: artist['description'], favorite: artist['favorite'], - genre: artist['genre'], + genre: { + name: artist['genre']['name'], + url: artist['genre']['url'], + }, emoji: artist['emoji'], tattoo: artist['tattoo'], image: artist['art'] ? `/${artist['art']}` : '', - url: `/music/artists/${sanitizeMediaString(artist['name_string'])}-${sanitizeMediaString(parseCountryField(artist['country']))}`, + url: artist['url'], albums: (artist['albums'] || []).map(album => ({ - id: album['id'], name: album['name'], releaseYear: album['release_year'], totalPlays: album['total_plays'], art: album.art ? `/${album['art']}` : '' })).sort((a, b) => a['release_year'] - b['release_year']), - concerts: artist['concerts']?.[0]?.['id'] ? artist['concerts'].sort((a, b) => new Date(b['date']) - new Date(a['date'])) : null, - books: artist['books']?.[0]?.['id'] ? artist['books'].map(book => ({ + concerts: artist['concerts'] ? artist['concerts'].sort((a, b) => new Date(b['date']) - new Date(a['date'])) : null, + books: artist['books'] ? artist['books'].map(book => ({ title: book['title'], author: book['author'], - isbn: book['isbn'], description: book['description'], url: `/books/${book['isbn']}`, })).sort((a, b) => a['title'].localeCompare(b['title'])) : null, - movies: artist['movies']?.[0]?.['id'] ? artist['movies'].map(movie => ({ + movies: artist['movies'] ? artist['movies'].map(movie => ({ title: movie['title'], year: movie['year'], - 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 => ({ + shows: artist['shows'] ? 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'], + posts: artist['posts'] ? artist['posts'].map(post => ({ title: post['title'], date: post['date'], - slug: post['slug'], - url: post['slug'], + url: post['url'], })).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, + relatedArtists: artist['related_artists'] ? artist['related_artists'].sort((a, b) => a['name'].localeCompare(b['name'])) : null, })) } diff --git a/src/data/books.js b/src/data/books.js index a2f5a767..d3860a86 100644 --- a/src/data/books.js +++ b/src/data/books.js @@ -1,6 +1,4 @@ import { createClient } from '@supabase/supabase-js' -import slugify from 'slugify' -import { sanitizeMediaString, parseCountryField } from '../../config/utilities/index.js' const SUPABASE_URL = process.env.SUPABASE_URL const SUPABASE_KEY = process.env.SUPABASE_KEY @@ -71,35 +69,25 @@ const processBooks = (books) => { status: book['read_status'], progress: book['progress'], tags: Array.isArray(book['tags']) ? book['tags'] : book['tags']?.split(',') || [], - isbn: book['isbn'], type: 'book', - artists: book['artists']?.[0]?.['id'] ? book['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, - movies: book['movies']?.[0]?.['id'] ? book['movies'].map(movie => { + artists: book['artists'] ? book['artists'].sort((a, b) => a['name'].localeCompare(b['name'])) : null, + movies: book['movies'] ? book['movies'].map(movie => { 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 => { - genre['url'] = `/music/genres/${slugify(genre['name'].replace('/', '-').toLowerCase())}` - return genre - }).sort((a, b) => a['name'].localeCompare(b['name'])) : null, - shows: book['shows']?.[0]?.['id'] ? book['shows'].map(show => { + genres: book['genres'] ? book['genres'].sort((a, b) => a['name'].localeCompare(b['name'])) : null, + shows: book['shows'] ? book['shows'].map(show => { show['url'] = `/watching/shows/${show['tmdb_id']}` return show }).sort((a, b) => b['year'] - a['year']) : null, - posts: book['posts']?.[0]?.['id'] ? book['posts'].map(post => ({ - id: post['id'], + posts: book['posts'] ? book['posts'].map(post => ({ title: post['title'], date: post['date'], - slug: post['slug'], - url: post['slug'], + url: post['url'], })).sort((a, b) => new Date(b['date']) - new Date(a['date'])) : null, - relatedBooks: book['related_books']?.[0]?.['id'] ? book['related_books'].map(relatedBook => ({ + relatedBooks: book['related_books'] ? 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 diff --git a/src/data/concerts.js b/src/data/concerts.js index f9d58dcb..a0b0b66a 100644 --- a/src/data/concerts.js +++ b/src/data/concerts.js @@ -1,5 +1,5 @@ import { createClient } from '@supabase/supabase-js' -import { sanitizeMediaString, parseCountryField } from '../../config/utilities/index.js' +import { parseCountryField } from '../../config/utilities/index.js' const SUPABASE_URL = process.env.SUPABASE_URL const SUPABASE_KEY = process.env.SUPABASE_KEY @@ -26,7 +26,6 @@ const fetchAllConcerts = async () => { bounding_box, venue_notes, artist_name, - artist_mbid, artist_country `) .range(rangeStart, rangeStart + PAGE_SIZE - 1) @@ -61,11 +60,9 @@ const processConcerts = (concerts) => { notes: concert['concert_notes'], artist: concert['artist'] ? { name: concert['artist_name'], - mbid: concert['artist_mbid'], - country: parseCountryField(concert['artist_country']) } : null, url: `/music/concerts?id=${concert['id']}`, - artistUrl: concert['artist'] ? `/music/artists/${sanitizeMediaString(concert['artist_name'])}-${sanitizeMediaString(parseCountryField(concert['artist_country']))}` : null + artistUrl: concert['artist'] ? concert['artist_url'] : null })).sort((a, b) => new Date(b['date']) - new Date(a['date'])) } diff --git a/src/data/genres.js b/src/data/genres.js index 293b9001..9d641ab8 100644 --- a/src/data/genres.js +++ b/src/data/genres.js @@ -1,6 +1,4 @@ import { createClient } from '@supabase/supabase-js' -import slugify from 'slugify' -import { parseCountryField } from '../../config/utilities/index.js' const SUPABASE_URL = process.env.SUPABASE_URL const SUPABASE_KEY = process.env.SUPABASE_KEY @@ -14,14 +12,8 @@ const fetchGenresWithArtists = async () => { description, total_plays, wiki_link, - artists ( - mbid, - name_string, - total_plays, - country, - description, - favorite - ), + url, + artists, books, movies, posts @@ -35,30 +27,23 @@ const fetchGenresWithArtists = async () => { return data.map(genre => ({ ...genre, - artists: genre['artists'].map(artist => ({ - ...artist, - country: parseCountryField(artist['country']) - })), - url: `/music/genres/${slugify(genre['name'].replace('/', '-').toLowerCase())}`, - books: genre['books']?.[0]?.['id'] ? genre['books'].map(book => ({ + artists: genre['artists'], + url: genre['url'], + books: genre['books'] ? genre['books'].map(book => ({ title: book['title'], author: book['author'], - isbn: book['isbn'], description: book['description'], url: `/books/${book['isbn']}`, })).sort((a, b) => a['title'].localeCompare(b['title'])) : null, - movies: genre['movies']?.[0]?.['id'] ? genre['movies'].map(movie => ({ + movies: genre['movies'] ? genre['movies'].map(movie => ({ title: movie['title'], year: movie['year'], - tmdb_id: movie['tmdb_id'], url: `/watching/movies/${movie['tmdb_id']}`, })).sort((a, b) => b['year'] - a['year']) : null, - posts: genre['posts']?.[0]?.['id'] ? genre['posts'].map(post => ({ - id: post['id'], + posts: genre['posts'] ? genre['posts'].map(post => ({ title: post['title'], date: post['date'], - slug: post['slug'], - url: post['slug'], + url: post['url'], })).sort((a, b) => new Date(b['date']) - new Date(a['date'])) : null, })) } diff --git a/src/data/movies.js b/src/data/movies.js index 628267e2..4a0c5855 100644 --- a/src/data/movies.js +++ b/src/data/movies.js @@ -1,7 +1,5 @@ import { createClient } from '@supabase/supabase-js' import { DateTime } from 'luxon' -import slugify from 'slugify' -import { sanitizeMediaString, parseCountryField } from '../../config/utilities/index.js' const SUPABASE_URL = process.env.SUPABASE_URL const SUPABASE_KEY = process.env.SUPABASE_KEY @@ -71,33 +69,24 @@ const processMovies = (movies) => { tattoo: item['tattoo'], rating: item['star_rating'], review: item['review'], - id: item['tmdb_id'], type: 'movie', tags: item['tags'] ? item['tags'].split(',') : [], - artists: item['artists']?.[0]?.['id'] ? item['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, - books: item['books']?.[0]?.['id'] ? item['books'].map(book => { + artists: item['artists'] ? item['artists'].sort((a, b) => a['name'].localeCompare(b['name'])) : null, + books: item['books'] ? item['books'].map(book => { book['url'] = `/books/${book['isbn']}` return book }).sort((a, b) => a['title'].localeCompare(b['title'])) : null, - genres: item['genres']?.[0]?.['id'] ? item['genres'].map(genre => { - genre['url'] = `/music/genres/${slugify(genre['name'].replace('/', '-').toLowerCase())}` - return genre - }).sort((a, b) => a['title'].localeCompare(b['title'])) : null, - shows: item['shows']?.[0]?.['id'] ? item['shows'].map(show => { + genres: item['genres'] ? item['genres'].sort((a, b) => a['title'].localeCompare(b['title'])) : null, + shows: item['shows'] ? item['shows'].map(show => { show['url'] = `/watching/shows/${show['tmdb_id']}` return show }).sort((a, b) => b['year'] - a['year']) : null, - posts: item['posts']?.[0]?.['id'] ? item['posts'].map(post => ({ - id: post['id'], + posts: item['posts'] ? item['posts'].map(post => ({ title: post['title'], date: post['date'], - slug: post['slug'], - url: post['slug'], + url: post['url'], })).sort((a, b) => new Date(b['date']) - new Date(a['date'])) : null, - relatedMovies: item['related_movies']?.[0]?.['id'] ? item['related_movies'].map(movie => { + relatedMovies: item['related_movies'] ? item['related_movies'].map(movie => { movie['url'] = `/watching/movies/${movie['tmdb_id']}` return movie }).sort((a, b) => b['year'] - a['year']) : null, diff --git a/src/data/music.js b/src/data/music.js index c6536653..f0391a8f 100644 --- a/src/data/music.js +++ b/src/data/music.js @@ -1,5 +1,4 @@ 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 @@ -56,8 +55,7 @@ const aggregateData = (data, groupByField, groupByType, genreMapping) => { aggregation[key] = { title: item[groupByField], plays: 0, - mbid: item[groupByType]?.['mbid'] || '', - url: `/music/artists/${sanitizeMediaString(item['artist_name'])}-${sanitizeMediaString(parseCountryField(item['artist_country']))}`, + url: item['artist_url'], image: `/${item[groupByType]}`, type: groupByType === 'artist_art' ? 'artist' : groupByType === 'album_art' ? 'album' : groupByType, genre: genreMapping[item['artist_genres']] || '' @@ -74,7 +72,7 @@ const buildRecents = (data) => { return data.map(listen => ({ title: listen['track_name'], artist: listen['artist_name'], - url: `/music/artists/${sanitizeMediaString(listen['artist_name'])}-${sanitizeMediaString(parseCountryField(listen['artist_country']))}`, + url: listen['artist_url'], timestamp: listen['listened_at'], image: `/${listen['album_art']}` })).sort((a, b) => b.timestamp - a.timestamp) @@ -85,8 +83,7 @@ const aggregateGenres = (data, genreMapping) => { data.forEach(item => { const genre = genreMapping[item['artist_genres']] || '' - - if (!genreAggregation[genre]) genreAggregation[genre] = { genre, plays: 0 } + if (!genreAggregation[genre]) genreAggregation[genre] = { name: genre, url: item['genre_url'], plays: 0 } genreAggregation[genre]['plays']++ }) return Object.values(genreAggregation).sort((a, b) => b['plays'] - a['plays']) @@ -99,12 +96,12 @@ export default async function () { artist_name, album_name, album_key, - artist_mbid, artist_art, artist_genres, artist_country, - album_mbid, - album_art + album_art, + artist_url, + genre_url ` try { diff --git a/src/data/posts.js b/src/data/posts.js index 9960fe43..fff4d180 100644 --- a/src/data/posts.js +++ b/src/data/posts.js @@ -1,6 +1,4 @@ import { createClient } from '@supabase/supabase-js' -import slugify from 'slugify' -import { sanitizeMediaString, parseCountryField } from '../../config/utilities/index.js' const SUPABASE_URL = process.env['SUPABASE_URL'] const SUPABASE_KEY = process.env['SUPABASE_KEY'] @@ -110,34 +108,27 @@ const processPosts = async (posts, tagsByPostId, blocksByPostId) => { })).then(blocks => blocks.filter(block => block !== null)) // artists - post['artists'] = post['artists']?.[0]?.['id'] ? post['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 + post['artists'] = post['artists'] ? post['artists'].sort((a, b) => a['name'].localeCompare(b['name'])) : null // books - post['books'] = post['books']?.[0]?.['id'] ? post['books'].map(book => ({ + post['books'] = post['books'] ? post['books'].map(book => ({ title: book['title'], author: book['author'], - isbn: book['isbn'], description: book['description'], url: `/books/${book['isbn']}`, })).sort((a, b) => a['title'].localeCompare(b['title'])) : null // movies - post['movies'] = post['movies']?.[0]?.['id'] ? post['movies'].map(movie => { + post['movies'] = post['movies'] ? post['movies'].map(movie => { movie['url'] = `/watching/movies/${movie['tmdb_id']}` return movie }).sort((a, b) => b['year'] - a['year']) : null // genres - post['genres'] = post['genres']?.[0]?.['id'] ? post['genres'].map(genre => { - genre['url'] = `/music/genres/${slugify(genre['name'].replace('/', '-').toLowerCase())}` - return genre - }).sort((a, b) => a['name'].localeCompare(b['name'])) : null + post['genres'] = post['genres'] ? post['genres'].sort((a, b) => a['name'].localeCompare(b['name'])) : null // shows - post['shows'] = post['shows']?.[0]?.['id'] ? post['shows'].map(show => { + post['shows'] = post['shows'] ? post['shows'].map(show => { show['url'] = `/watching/shows/${show['tmdb_id']}` return show }).sort((a, b) => b['year'] - a['year']) : null diff --git a/src/data/tv.js b/src/data/tv.js index b1fa02a8..7957611d 100644 --- a/src/data/tv.js +++ b/src/data/tv.js @@ -1,5 +1,4 @@ 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 @@ -56,35 +55,27 @@ const prepareShowData = (show) => ({ episodes: show['episodes'] || [], tattoo: show['tattoo'], tags: Array.isArray(show['tags']) ? show['tags'] : show['tags']?.split(',') || [], - movies: show['movies']?.[0]?.['id'] ? show['movies'].map(movie => { + movies: show['movies'] ? show['movies'].map(movie => { movie['url'] = `/watching/movies/${movie['tmdb_id']}` return movie }).sort((a, b) => b['year'] - a['year']) : null, - books: show['books']?.[0]?.['id'] ? show['books'].map(book => ({ + books: show['books'] ? show['books'].map(book => ({ title: book['title'], author: book['author'], - isbn: book['isbn'], description: book['description'], url: `/books/${book['isbn']}`, })).sort((a, b) => a['title'].localeCompare(b['title'])) : null, - posts: show['posts']?.[0]?.['id'] ? show['posts'].map(post => ({ - id: post['id'], + posts: show['posts'] ? show['posts'].map(post => ({ title: post['title'], date: post['date'], - slug: post['slug'], - url: post['slug'], + url: post['url'], })).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'], + relatedShows: show['related_shows'] ? show['related_shows'].map(relatedShow => ({ 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 + artists: show['artists'] ? show['artists'].sort((a, b) => a['name'].localeCompare(b['name'])) : null }) const prepareEpisodeData = (show) => show['episodes'].map(episode => ({ diff --git a/src/includes/partials/blocks/avatar.liquid b/src/includes/partials/blocks/avatar.liquid deleted file mode 100644 index dda934f4..00000000 --- a/src/includes/partials/blocks/avatar.liquid +++ /dev/null @@ -1,22 +0,0 @@ -
I've listened to {{ music.threeMonth.artists.size }} artists, {{ music.threeMonth.albums.size }} albums and {{ music.threeMonth.totalTracks }} tracks over the last 3 months. Most of that has been {{ music.threeMonth.genres | sortByPlaysDescending: "plays" | genreStrings: "genre" | mediaLinks: "genre", 5 }}.
+I've listened to {{ music.threeMonth.artists.size }} artists, {{ music.threeMonth.albums.size }} albums and {{ music.threeMonth.totalTracks }} tracks over the last 3 months. Most of that has been {{ music.threeMonth.genres | sortByPlaysDescending: "plays" | mediaLinks: "genre", 5 }}.
See the artists or tracks I've listened to over the last 3 months. Or take a look at what I've listened to this week or this month.
You can also take a look at the concerts I've been to.
I've listened to {{ music.month.artists.size }} artists, {{ music.month.albums.size }} albums and {{ music.month.totalTracks }} tracks this month. Most of that has been {{ music.month.genres | sortByPlaysDescending: "plays" | genreStrings: "genre" | mediaLinks: "genre", 5 }}.
+I've listened to {{ music.month.artists.size }} artists, {{ music.month.albums.size }} albums and {{ music.month.totalTracks }} tracks this month. Most of that has been {{ music.month.genres | sortByPlaysDescending: "plays" | mediaLinks: "genre", 5 }}.
See the artists or tracks I've listened to this month. Or take a look at what I've listened to this week or over the last 3 months.
You can also take a look at the concerts I've been to.
I've listened to {{ music.week.artists.size }} artists, {{ music.week.albums.size }} albums and {{ music.week.totalTracks }} tracks this week. Most of that has been {{ music.week.genres | sortByPlaysDescending: "plays" | genreStrings: "genre" | mediaLinks: "genre", 5 }}.
+I've listened to {{ music.week.artists.size }} artists, {{ music.week.albums.size }} albums and {{ music.week.totalTracks }} tracks this week. Most of that has been {{ music.week.genres | sortByPlaysDescending: "plays" | mediaLinks: "genre", 5 }}.
See the artists or tracks I've listened to this week. Or take a look at what I've listened to this month or over the last 3 months.
You can also take a look at the concerts I've been to.
I've listened to {{ music.threeMonth.artists.size }} artists, {{ music.threeMonth.albums.size }} albums and {{ music.threeMonth.totalTracks }} tracks over the last 3 months. Most of that has been {{ music.threeMonth.genres | sortByPlaysDescending: "plays" | genreStrings: "genre" | mediaLinks: "genre", 5 }}.
+I've listened to {{ music.threeMonth.artists.size }} artists, {{ music.threeMonth.albums.size }} albums and {{ music.threeMonth.totalTracks }} tracks over the last 3 months. Most of that has been {{ music.threeMonth.genres | sortByPlaysDescending: "plays" | mediaLinks: "genre", 5 }}.
See the albums or tracks I've listened to over the last 3 months. Or take a look at what I've listened to this week or this month.
You can also take a look at the concerts I've been to.
I've listened to {{ music.month.artists.size }} artists, {{ music.month.albums.size }} albums and {{ music.month.totalTracks }} tracks this month. Most of that has been {{ music.month.genres | sortByPlaysDescending: "plays" | genreStrings: "genre" | mediaLinks: "genre", 5 }}.
+I've listened to {{ music.month.artists.size }} artists, {{ music.month.albums.size }} albums and {{ music.month.totalTracks }} tracks this month. Most of that has been {{ music.month.genres | sortByPlaysDescending: "plays" | mediaLinks: "genre", 5 }}.
See the albums or tracks I've listened to this month. Or take a look at what I've listened to this week or over the last 3 months.
You can also take a look at the concerts I've been to.
I've listened to {{ music.week.artists.size }} artists, {{ music.week.albums.size }} albums and {{ music.week.totalTracks }} tracks this week. Most of that has been {{ music.week.genres | sortByPlaysDescending: "plays" | genreStrings: "genre" | mediaLinks: "genre", 5 }}.
+I've listened to {{ music.week.artists.size }} artists, {{ music.week.albums.size }} albums and {{ music.week.totalTracks }} tracks this week. Most of that has been {{ music.week.genres | sortByPlaysDescending: "plays" | mediaLinks: "genre", 5 }}.
See the albums or tracks I've listened to this week. Or take a look at what I've listened to this month or over the last 3 months.
You can also take a look at the concerts I've been to.
I've listened to {{ music.week.artists.size }} artists, {{ music.week.albums.size }} albums and {{ music.week.totalTracks }} tracks this week. Most of that has been {{ music.week.genres | sortByPlaysDescending: "plays" | genreStrings: "genre" | mediaLinks: "genre", 5 }}.
+I've listened to {{ music.week.artists.size }} artists, {{ music.week.albums.size }} albums and {{ music.week.totalTracks }} tracks this week. Most of that has been {{ music.week.genres | sortByPlaysDescending: "plays" | mediaLinks: "genre", 5 }}.
See more of the artists, albums or tracks I've listened to this week. Or take a look at what I've listened to this month or over the last 3 months.
You can also take a look at the concerts I've been to.
{% render "partials/blocks/now-playing.liquid", music:music %} diff --git a/src/pages/dynamic/music/periods/3-months.html b/src/pages/dynamic/music/periods/3-months.html index e9d264e9..d7be1a8d 100644 --- a/src/pages/dynamic/music/periods/3-months.html +++ b/src/pages/dynamic/music/periods/3-months.html @@ -8,7 +8,7 @@ image: music.threeMonth.artists[0].image schema: music-period ---I've listened to {{ music.threeMonth.artists.size }} artists, {{ music.threeMonth.albums.size }} albums and {{ music.threeMonth.totalTracks }} tracks over the last 3 months. Most of that has been {{ music.threeMonth.genres | sortByPlaysDescending: "plays" | genreStrings: "genre" | mediaLinks: "genre", 5 }}.
+I've listened to {{ music.threeMonth.artists.size }} artists, {{ music.threeMonth.albums.size }} albums and {{ music.threeMonth.totalTracks }} tracks over the last 3 months. Most of that has been {{ music.threeMonth.genres | sortByPlaysDescending: "plays" | mediaLinks: "genre", 5 }}.
See more of the artists, albums or tracks I've listened to over the last 3 months. Or take a look at what I've listened to this week or this month.
You can also take a look at the concerts I've been to.
I've listened to {{ music.month.artists.size }} artists, {{ music.month.albums.size }} albums and {{ music.month.totalTracks }} tracks this month. Most of that has been {{ music.month.genres | sortByPlaysDescending: "plays" | genreStrings: "genre" | mediaLinks: "genre", 5 }}.
+I've listened to {{ music.month.artists.size }} artists, {{ music.month.albums.size }} albums and {{ music.month.totalTracks }} tracks this month. Most of that has been {{ music.month.genres | sortByPlaysDescending: "plays" | mediaLinks: "genre", 5 }}.
See more of the artists, albums or tracks I've listened to this month. Or take a look at what I've listened to this week or over the last 3 months.
You can also take a look at the concerts I've been to.
I've listened to {{ music.threeMonth.artists.size }} artists, {{ music.threeMonth.albums.size }} albums and {{ music.threeMonth.totalTracks }} tracks over the last 3 months. Most of that has been {{ music.threeMonth.genres | sortByPlaysDescending: "plays" | genreStrings: "genre" | mediaLinks: "genre", 5 }}.
+I've listened to {{ music.threeMonth.artists.size }} artists, {{ music.threeMonth.albums.size }} albums and {{ music.threeMonth.totalTracks }} tracks over the last 3 months. Most of that has been {{ music.threeMonth.genres | sortByPlaysDescending: "plays" | mediaLinks: "genre", 5 }}.
See the artists or albums I've listened to over the last 3 months. Or take a look at what I've listened to this week or this month.
You can also take a look at the concerts I've been to.
I've listened to {{ music.month.artists.size }} artists, {{ music.month.albums.size }} albums and {{ music.month.totalTracks }} tracks this month. Most of that has been {{ music.month.genres | sortByPlaysDescending: "plays" | genreStrings: "genre" | mediaLinks: "genre", 5 }}.
+I've listened to {{ music.month.artists.size }} artists, {{ music.month.albums.size }} albums and {{ music.month.totalTracks }} tracks this month. Most of that has been {{ music.month.genres | sortByPlaysDescending: "plays" | mediaLinks: "genre", 5 }}.
See the artists or albums this month. Or take a look at what I've listened to this week or over the last 3 months.
You can also take a look at the concerts I've been to.
I've listened to {{ music.week.artists.size }} artists, {{ music.week.albums.size }} albums and {{ music.week.totalTracks }} tracks this week. Most of that has been {{ music.week.genres | sortByPlaysDescending: "plays" | genreStrings: "genre" | mediaLinks: "genre", 5 }}.
+I've listened to {{ music.week.artists.size }} artists, {{ music.week.albums.size }} albums and {{ music.week.totalTracks }} tracks this week. Most of that has been {{ music.week.genres | sortByPlaysDescending: "plays" | mediaLinks: "genre", 5 }}.
See the artists or albums I've listened to this week. Or take a look at what I've listened to this month or over the last 3 months.
You can also take a look at the concerts I've been to.
{{ post.description | markdown }}
diff --git a/src/pages/dynamic/posts/post.html b/src/pages/dynamic/posts/post.html index af2ede49..429e4c69 100644 --- a/src/pages/dynamic/posts/post.html +++ b/src/pages/dynamic/posts/post.html @@ -4,7 +4,7 @@ pagination: data: posts size: 1 alias: post -permalink: "{{ post.slug }}/index.html" +permalink: "{{ post.url }}/index.html" schema: blog ---