diff --git a/package.json b/package.json index 3201b0ec..deee3a58 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "14.0.6", + "version": "14.0.7", "description": "The source for my personal site. Built using 11ty.", "type": "module", "scripts": { diff --git a/src/_data/music.js b/src/_data/music.js index 251b3350..b1da8b61 100644 --- a/src/_data/music.js +++ b/src/_data/music.js @@ -32,7 +32,7 @@ const fetchDataForPeriod = async (startPeriod, fields, table) => { return rows } -const aggregateData = (data, groupByField, groupByType) => { +const aggregateData = (data, groupByField, groupByType, sort = true) => { const aggregation = {} data.forEach(item => { const key = item[groupByField] @@ -64,7 +64,8 @@ const aggregateData = (data, groupByField, groupByType) => { } aggregation[key].plays++ }) - return Object.values(aggregation).sort((a, b) => b.plays - a.plays) + const aggregatedData = sort ? Object.values(aggregation).sort((a, b) => b.plays - a.plays) : Object.values(aggregation) + return aggregatedData } @@ -101,9 +102,9 @@ export default async function() { results.recent = { artists: aggregateData(recentData, 'artist_name', 'artists'), albums: aggregateData(recentData, 'album_name', 'albums'), - tracks: aggregateData(recentData, 'track_name', 'track') + tracks: aggregateData(recentData, 'track_name', 'track'), + trackChart: aggregateData(recentData, 'track_name', 'track', false), } - results.nowPlaying = results.recent.tracks[0] return results diff --git a/src/_includes/now.liquid b/src/_includes/now.liquid index 0169c5c0..f339382a 100644 --- a/src/_includes/now.liquid +++ b/src/_includes/now.liquid @@ -68,7 +68,7 @@ layout: default
- {% render "partials/now/tracks-recent.liquid", data:music.recent.tracks %} + {% render "partials/now/tracks-recent.liquid", data:music.recent.trackChart %}