--- import SectionContainer from '../../components/SectionContainer.astro'; import biblioteca from '../../data/bookshelf.json' let booksRead = []; let booksShelf = []; let booksReading = []; let booksWant = []; biblioteca.lists.forEach(list => { switch (list.name) { case "Read": booksRead = list.books; break; case "On the shelf": booksShelf = list.books; break; case "Currently reading": booksReading = list.books; break; case "Want to read": booksWant = list.books; break; } }); const booksByYear = booksRead.reduce((acc, book) => { const year = new Date(book.date.string).getFullYear(); if (!acc[year]) { acc[year] = []; } acc[year].push(book); return acc; }, {}); const sortedYears = Object.keys(booksByYear).sort((a: any, b: any) => b - a); ---

[ Bookshelf ]

on the shelf

on the nightstand

{sortedYears.map(year => (
{year} ({booksByYear[year].length} entries)
    {booksByYear[year].map((book) => (

    {book.title}

    {book.rating === 5 ? "❤️" : ""}

    ))}
))}
want to read
    {booksWant.map((book) => (
  • {book.title}
  • ))}