feat: dedicated music page

This commit is contained in:
Cory Dransfeldt 2024-05-18 08:02:57 -07:00
parent 3d08ecfa7a
commit a43598263b
No known key found for this signature in database
38 changed files with 475 additions and 103 deletions

View file

@ -64,7 +64,7 @@ export const allContent = (collection) => {
addContent(posts, '📝', item => item.data.title, item => item.data.date)
addContent(links, '🔗', item => item.data.title, item => item.data.date)
addContent(books.filter(book => book.status === 'finished'), '📖', item => item.title, item => item.date)
addContent(books.filter(book => book.status === 'finished'), '📖', item => `${item.title}${item.rating ? ' (' + item.rating + ')' : ''}`, item => item.date)
addContent(movies, '🎥', item => `${item.title}${item.rating ? ' (' + item.rating + ')' : ''}`, item => item.lastWatched)
addContent(weeklyArtistChart, '🎧', item => item.title, item => item.date)

View file

@ -222,6 +222,14 @@ export default {
return normalized
}),
calculatePlayPercentage: (plays, mostPlayed) => `${plays/mostPlayed * 100}%`,
genresToString: (genres, count = 10) => {
const genreData = genres.slice(0, count)
if (genreData.length === 0) return ''
if (genreData.length === 1) return genreData[0].genre
const allButLast = genreData.slice(0, -1).map(g => g.genre).join(', ')
const last = genreData[genreData.length - 1].genre
return `${allButLast} and ${last}`
},
bookStatus: (books, status) => books.filter(book => book.status === status),
bookSortDescending: (books) => books.sort((a, b) => {
const dateA = DateTime.fromISO(a.date)