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",
|
"name": "coryd.dev",
|
||||||
"version": "20.8.4",
|
"version": "20.8.5",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "coryd.dev",
|
"name": "coryd.dev",
|
||||||
"version": "20.8.4",
|
"version": "20.8.5",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cdransf/api-text": "^1.4.0",
|
"@cdransf/api-text": "^1.4.0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "coryd.dev",
|
"name": "coryd.dev",
|
||||||
"version": "20.8.4",
|
"version": "20.8.5",
|
||||||
"description": "The source for my personal site. Built using 11ty (and other tools).",
|
"description": "The source for my personal site. Built using 11ty (and other tools).",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -47,7 +47,7 @@ const fetchGenreMapping = async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return data.reduce((acc, genre) => {
|
return data.reduce((acc, genre) => {
|
||||||
acc[genre.id] = genre.name
|
acc[genre['id']] = genre['name']
|
||||||
return acc
|
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 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 albums = await fetchPaginatedData('albums', 'mbid, name, release_year, total_plays, artist')
|
||||||
const albumsByArtist = albums.reduce((acc, album) => {
|
const albumsByArtist = albums.reduce((acc, album) => {
|
||||||
if (!acc[album.artist]) acc[album.artist] = []
|
if (!acc[album['artist']]) acc[album['artist']] = []
|
||||||
acc[album.artist].push({
|
acc[album['artist']].push({
|
||||||
id: album.id,
|
id: album['id'],
|
||||||
name: album.name,
|
name: album['name'],
|
||||||
release_year: album.release_year,
|
release_year: album['release_year'],
|
||||||
total_plays: album.total_plays > 0 ? album.total_plays : '-'
|
total_plays: album['total_plays'] > 0 ? album['total_plays'] : '-'
|
||||||
})
|
})
|
||||||
return acc
|
return acc
|
||||||
}, {})
|
}, {})
|
||||||
|
|
||||||
for (const artist of artists) {
|
for (const artist of artists) {
|
||||||
artist.albums = albumsByArtist[artist['id']]?.sort((a, b) => a['release_year'] - b['release_year']) || []
|
artist['albums'] = albumsByArtist[artist['id']]?.sort((a, b) => a['release_year'] - b['release_year']) || []
|
||||||
artist.image = `/${artist['art']['filename_disk']}`
|
artist['image'] = `/${artist['art']['filename_disk']}`
|
||||||
artist.country = parseCountryField(artist['country'])
|
artist['country'] = parseCountryField(artist['country'])
|
||||||
artist.genres = genreMapping[artist['genres']] || ''
|
artist['genres'] = genreMapping[artist['genres']] || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
return artists
|
return artists
|
||||||
|
|
Reference in a new issue