🚚 rename paths for logs "watched" and "books"
Signed-off-by: SindreKjelsrud <sindre@kjelsrud.dev>
This commit is contained in:
parent
be1565be69
commit
ef3ff3ef31
6 changed files with 11 additions and 11 deletions
66
src/pages/logs/bookshelf.astro
Normal file
66
src/pages/logs/bookshelf.astro
Normal file
|
@ -0,0 +1,66 @@
|
|||
---
|
||||
import SectionContainer from '../../components/SectionContainer.astro';
|
||||
import biblioteca from '../../data/bookshelf.json'
|
||||
|
||||
let booksRead = [];
|
||||
let booksShelf = [];
|
||||
let booksReading = [];
|
||||
|
||||
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;
|
||||
}
|
||||
});
|
||||
|
||||
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);
|
||||
---
|
||||
|
||||
<SectionContainer>
|
||||
<main class="flex flex-col flex-1 gap-4 mt-4">
|
||||
<h1 class="text-3xl font-extrabold">📚 ¿Dónde está la biblioteca?</h1>
|
||||
<h2 class="text-xl font-semibold">on the shelf</h2>
|
||||
<ul class="flex flex-col text-s gap-2 text-l">
|
||||
{booksShelf.map((book) => (
|
||||
<li class="borderbottom">📚 {book.title}</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
<h2 class="text-xl font-semibold">on the nightstand</h2>
|
||||
<ul>
|
||||
{booksReading.map((book) => (
|
||||
<li class="borderbottom">📖 {book.title}</li>
|
||||
))}
|
||||
</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>
|
||||
))}
|
||||
</main>
|
||||
</SectionContainer>
|
Loading…
Add table
Add a link
Reference in a new issue