diff --git a/config/filters/index.js b/config/filters/index.js index 4f3b6a0a..df429c49 100644 --- a/config/filters/index.js +++ b/config/filters/index.js @@ -188,6 +188,7 @@ export default { } return normalized }), + calculatePlayPercentage: (plays, mostPlayed) => `${plays/mostPlayed * 100}%`, // tags filterTags: (tags) => { diff --git a/package.json b/package.json index c55a1b8c..41594a35 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "9.5.1", + "version": "9.6.0", "description": "The source for my personal site. Built using 11ty.", "type": "module", "scripts": { diff --git a/src/_data/helpers/music.js b/src/_data/helpers/music.js index 71f6d2a6..2a689a9e 100644 --- a/src/_data/helpers/music.js +++ b/src/_data/helpers/music.js @@ -16,9 +16,14 @@ export const buildChart = (tracks, artists, albums, nowPlaying = {}) => { tracks.forEach(track => { if (!tracksData[track['track']]) { tracksData[track['track']] = { + artist: artistCapitalization(track['artist']), title: track['track'], plays: 1, - type: 'track' + type: 'track', + url: (artists[artistSanitizedKey(track['artist'])]?.['mbid'] && artists[artistSanitizedKey(track['artist'])]?.['mbid'] !== '') ? `http://musicbrainz.org/artist/${artists[artistSanitizedKey(track['artist'])]?.['mbid']}` : `https://musicbrainz.org/search?query=${track['artist'].replace( + /\s+/g, + '+' + )}&type=artist`, } } else { tracksData[track['track']]['plays']++ @@ -56,10 +61,17 @@ export const buildChart = (tracks, artists, albums, nowPlaying = {}) => { } }) + const topTracks = objectToArraySorted(tracksData).splice(0, 10) + const topTracksData = { + data: topTracks, + mostPlayed: Math.max(...topTracks.map(track => track.plays)) + } + return { artists: objectToArraySorted(artistsData), albums: objectToArraySorted(albumsData), tracks: objectToArraySorted(tracksData), + topTracks: topTracksData, nowPlaying } } \ No newline at end of file diff --git a/src/_includes/now.liquid b/src/_includes/now.liquid index 5c8a2023..ce586543 100644 --- a/src/_includes/now.liquid +++ b/src/_includes/now.liquid @@ -53,6 +53,26 @@ layout: default