diff --git a/package.json b/package.json index 697c6262..1e9f748c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "14.0.10", + "version": "14.0.11", "description": "The source for my personal site. Built using 11ty.", "type": "module", "scripts": { diff --git a/src/_data/artists.js b/src/_data/artists.js deleted file mode 100644 index b36b48ec..00000000 --- a/src/_data/artists.js +++ /dev/null @@ -1,91 +0,0 @@ -import { createClient } from '@supabase/supabase-js' -import { DateTime } from 'luxon' - -const SUPABASE_URL = process.env.SUPABASE_URL -const SUPABASE_KEY = process.env.SUPABASE_KEY -const supabase = createClient(SUPABASE_URL, SUPABASE_KEY) - -const fetchDataForPeriod = async (startPeriod, fields, table, allTime = false) => { - let query = supabase.from(table).select(fields).order('listened_at', { ascending: false }) - - if (!allTime) query = query.gte('listened_at', startPeriod.toUTC().toSeconds()) - - const { data, error } = await query - if (error) { - console.error('Error fetching data:', error) - return [] - } - - return data -} - -const aggregateData = (data, groupByField, groupByType) => { - const aggregation = {} - data.forEach(item => { - const key = item[groupByField] - if (!aggregation[key]) { - if (groupByType === 'track') { - aggregation[key] = { - title: item[groupByField], - plays: 0, - mbid: item['albums']?.mbid || '', - url: item['albums']?.mbid ? `https://musicbrainz.org/release/${item['albums'].mbid}` : `https://musicbrainz.org/search?query=${encodeURIComponent(item['album_name'])}&type=release`, - image: item['albums']?.image || '', - type: groupByType - } - } else { - aggregation[key] = { - title: item[groupByField], - plays: 0, - mbid: item[groupByType]?.mbid || '', - url: item[groupByType]?.mbid ? `https://musicbrainz.org/${groupByType === 'albums' ? 'release' : 'artist'}/${item[groupByType].mbid}` : `https://musicbrainz.org/search?query=${encodeURIComponent(item[groupByField])}&type=${groupByType === 'albums' ? 'release' : 'artist'}`, - image: item[groupByType]?.image || '', - type: groupByType - } - } - } - aggregation[key].plays++ - }) - return Object.values(aggregation).sort((a, b) => b.plays - a.plays) -} - - -export default async function() { - const periods = { - week: DateTime.now().minus({ days: 7 }).startOf('day'), // Last week - month: DateTime.now().minus({ days: 30 }).startOf('day'), // Last 30 days - threeMonth: DateTime.now().minus({ months: 3 }).startOf('day'), // Last three months - year: DateTime.now().minus({ years: 1 }).startOf('day'), // Last 365 days - allTime: null // Null indicates no start period constraint - } - - const results = {} - const selectFields = ` - track_name, - artist_name, - album_name, - album_key, - artists (mbid, image), - albums (mbid, image) - ` - - for (const [period, startPeriod] of Object.entries(periods)) { - const isAllTime = period === 'allTime' - const periodData = await fetchDataForPeriod(startPeriod, selectFields, 'listens', isAllTime) - results[period] = { - artists: aggregateData(periodData, 'artist_name', 'artists'), - albums: aggregateData(periodData, 'album_name', 'albums'), - tracks: aggregateData(periodData, 'track_name', 'track') - } - } - - const recentData = await fetchDataForPeriod(DateTime.now().minus({ days: 7 }), selectFields, 'listens') - - results.recent = { - artists: aggregateData(recentData, 'artist_name', 'artists'), - albums: aggregateData(recentData, 'album_name', 'albums'), - tracks: aggregateData(recentData, 'track_name', 'track') - } - - return results -} diff --git a/src/assets/styles/components/media-grid.css b/src/assets/styles/components/media-grid.css index 8ca01eeb..1a748255 100644 --- a/src/assets/styles/components/media-grid.css +++ b/src/assets/styles/components/media-grid.css @@ -30,6 +30,7 @@ height: 100%; position: relative; display: flex; + overflow: hidden; &.shadow::after { position: absolute; diff --git a/src/assets/styles/components/music-chart.css b/src/assets/styles/components/music-chart.css index 66bd818a..53d5dcfe 100644 --- a/src/assets/styles/components/music-chart.css +++ b/src/assets/styles/components/music-chart.css @@ -23,7 +23,7 @@ & .meta { justify-content: start; gap: var(--sizing-md); - max-width: calc(70% - var(--sizing-lg)); + width: calc(55% - var(--sizing-lg)); } & .meta-text { @@ -65,7 +65,7 @@ & .presentation { display: flex; flex-direction: row; - max-width: calc(60% - var(--sizing-lg)); + width: calc(55% - var(--sizing-lg)); } & .count { @@ -109,6 +109,11 @@ @media screen and (min-width: 768px) { .music-chart { + & .meta, + & .presentation { + width: calc(80% - var(--sizing-lg)); + } + & .item .meta-text { max-width: 85%; } diff --git a/src/assets/styles/pages/about.css b/src/assets/styles/pages/about.css index 69caae7e..8614d691 100644 --- a/src/assets/styles/pages/about.css +++ b/src/assets/styles/pages/about.css @@ -3,7 +3,7 @@ } .avatar-wrapper { - margin-bottom: var(--sizing-md); + margin-bottom: var(--sizing-sm); width: 100%; justify-content: center; overflow: hidden;