📚 add "want to read" section

Signed-off-by: SindreKjelsrud <sindre@kjelsrud.dev>
This commit is contained in:
Sid 2024-07-08 23:50:04 +02:00
parent eec80aafaa
commit 7170c0254b
Signed by: sidski
GPG key ID: D2BBDF3EDE6BA9A6
2 changed files with 177 additions and 11 deletions

View file

@ -5,6 +5,7 @@ import biblioteca from '../../data/bookshelf.json'
let booksRead = [];
let booksShelf = [];
let booksReading = [];
let booksWant = [];
biblioteca.lists.forEach(list => {
switch (list.name) {
@ -17,6 +18,9 @@ biblioteca.lists.forEach(list => {
case "Currently reading":
booksReading = list.books;
break;
case "Want to read":
booksWant = list.books;
break;
}
});
@ -50,17 +54,26 @@ const sortedYears = Object.keys(booksByYear).sort((a: any, b: any) => b - a);
</ul>
{sortedYears.map(year => (
<details>
<summary class="text-xl font-semibold cursor-pointer">{year} <span class="text-xs">({booksByYear[year].length} entries)</span></summary>
<ul class="mt-2">
{booksByYear[year].map((book) => (
<div class="flex justify-between mb-2 break-words gap-2 borderbottom">
<p class="text-s">{book.title}</p>
<p>{book.rating === 5 ? "❤️" : ""}</p>
</div>
))}
</ul>
</details>
<details>
<summary class="text-xl font-semibold cursor-pointer">{year} <span class="text-xs">({booksByYear[year].length} entries)</span></summary>
<ul class="mt-2">
{booksByYear[year].map((book) => (
<div class="flex justify-between mb-2 break-words gap-2 borderbottom">
<p class="text-s">{book.title}</p>
<p>{book.rating === 5 ? "❤️" : ""}</p>
</div>
))}
</ul>
</details>
))}
<details>
<summary class="text-xl font-semibold cursor-pointer">want to read</summary>
<ul>
{booksWant.map((book) => (
<li class="borderbottom">{book.title}</li>
))}
</ul>
</details>
</main>
</SectionContainer>