fix: accessor patter
This commit is contained in:
parent
2420479402
commit
b40986256a
3 changed files with 14 additions and 14 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "coryd.dev",
|
||||
"version": "20.8.4",
|
||||
"version": "20.8.5",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "coryd.dev",
|
||||
"version": "20.8.4",
|
||||
"version": "20.8.5",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@cdransf/api-text": "^1.4.0",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "coryd.dev",
|
||||
"version": "20.8.4",
|
||||
"version": "20.8.5",
|
||||
"description": "The source for my personal site. Built using 11ty (and other tools).",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
|
|
@ -47,7 +47,7 @@ const fetchGenreMapping = async () => {
|
|||
}
|
||||
|
||||
return data.reduce((acc, genre) => {
|
||||
acc[genre.id] = genre.name
|
||||
acc[genre['id']] = genre['name']
|
||||
return acc
|
||||
}, {})
|
||||
}
|
||||
|
@ -57,21 +57,21 @@ export default async function () {
|
|||
const artists = await fetchPaginatedData('artists', 'id, mbid, name_string, art(filename_disk), total_plays, country, description, favorite, tattoo, genres')
|
||||
const albums = await fetchPaginatedData('albums', 'mbid, name, release_year, total_plays, artist')
|
||||
const albumsByArtist = albums.reduce((acc, album) => {
|
||||
if (!acc[album.artist]) acc[album.artist] = []
|
||||
acc[album.artist].push({
|
||||
id: album.id,
|
||||
name: album.name,
|
||||
release_year: album.release_year,
|
||||
total_plays: album.total_plays > 0 ? album.total_plays : '-'
|
||||
if (!acc[album['artist']]) acc[album['artist']] = []
|
||||
acc[album['artist']].push({
|
||||
id: album['id'],
|
||||
name: album['name'],
|
||||
release_year: album['release_year'],
|
||||
total_plays: album['total_plays'] > 0 ? album['total_plays'] : '-'
|
||||
})
|
||||
return acc
|
||||
}, {})
|
||||
|
||||
for (const artist of artists) {
|
||||
artist.albums = albumsByArtist[artist['id']]?.sort((a, b) => a['release_year'] - b['release_year']) || []
|
||||
artist.image = `/${artist['art']['filename_disk']}`
|
||||
artist.country = parseCountryField(artist['country'])
|
||||
artist.genres = genreMapping[artist['genres']] || ''
|
||||
artist['albums'] = albumsByArtist[artist['id']]?.sort((a, b) => a['release_year'] - b['release_year']) || []
|
||||
artist['image'] = `/${artist['art']['filename_disk']}`
|
||||
artist['country'] = parseCountryField(artist['country'])
|
||||
artist['genres'] = genreMapping[artist['genres']] || ''
|
||||
}
|
||||
|
||||
return artists
|
||||
|
|
Reference in a new issue