2023-12-09 23:48:53 +01:00
|
|
|
---
|
|
|
|
import SectionContainer from '../../components/SectionContainer.astro';
|
|
|
|
import books from '../../data/biblioteca.json'
|
|
|
|
|
2023-12-10 01:14:17 +01:00
|
|
|
const booksByYear = books.reduce((acc:any, book) => {
|
2023-12-09 23:48:53 +01:00
|
|
|
const year = new Date(book.date.string).getFullYear();
|
|
|
|
if (!acc[year]) {
|
|
|
|
acc[year] = [];
|
|
|
|
}
|
|
|
|
acc[year].push(book);
|
|
|
|
return acc;
|
|
|
|
}, {});
|
|
|
|
|
2023-12-10 01:14:17 +01:00
|
|
|
const sortedYears = Object.keys(booksByYear).sort((a:any, b:any) => b - a);
|
2023-12-09 23:48:53 +01:00
|
|
|
|
2024-02-14 23:28:29 +01:00
|
|
|
/*
|
2023-12-10 01:14:17 +01:00
|
|
|
function getEmojiStars(rating:any) {
|
2023-12-09 23:48:53 +01:00
|
|
|
let stars = '';
|
|
|
|
for (let i = 0; i < rating; i++) {
|
|
|
|
stars += '⭐';
|
|
|
|
}
|
|
|
|
return stars;
|
|
|
|
}
|
2024-02-14 23:28:29 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
function getHeartEmoji(rating:any) {
|
|
|
|
let heart = '';
|
|
|
|
if (rating == 5) heart = "❤️";
|
|
|
|
return heart;
|
|
|
|
}
|
2024-01-06 21:35:20 +01:00
|
|
|
|
|
|
|
const today = new Date();
|
2023-12-09 23:48:53 +01:00
|
|
|
---
|
|
|
|
<SectionContainer>
|
2023-12-29 16:59:13 +01:00
|
|
|
<main class="flex flex-col gap-4 mt-4">
|
2023-12-09 23:48:53 +01:00
|
|
|
<h1 class="text-3xl font-extrabold">📚 ¿Dónde está la biblioteca?</h1>
|
2024-05-09 23:04:58 +02:00
|
|
|
<h2 class="text-xl font-semibold">on the shelf</h2>
|
|
|
|
<ul class="flex flex-col text-s gap-2 text-l">
|
|
|
|
<li class="borderbottom">📚 Dune</li>
|
|
|
|
<li class="borderbottom">📚 The Summit of The Gods: Vol.3 - Vol.5</li>
|
|
|
|
<li class="borderbottom">📚 Star Wars: The Tales of Kenobi</li>
|
|
|
|
</ul>
|
|
|
|
<h2 class="text-xl font-semibold">on the nightstand</h2>
|
2024-05-12 12:15:08 +02:00
|
|
|
<p class="borderbottom">📖 The Intelligent Investor (NO)</p>
|
2024-05-09 23:04:58 +02:00
|
|
|
{sortedYears.map(year => (
|
2023-12-09 23:48:53 +01:00
|
|
|
<section>
|
2024-05-09 23:04:58 +02:00
|
|
|
<div class="flex items-center gap-2 text-xl font-semibold mb-2">{year}<p class="text-xs">({booksByYear[year].length} entries)</p></div>
|
2023-12-09 23:48:53 +01:00
|
|
|
<ul>
|
|
|
|
{
|
2023-12-28 21:59:58 +01:00
|
|
|
booksByYear[year].map((book) => (
|
2023-12-09 23:48:53 +01:00
|
|
|
<div class="flex justify-between mb-2 break-words gap-2 borderbottom">
|
2023-12-29 17:04:56 +01:00
|
|
|
<p class="text-s">{book.title}</p>
|
2024-02-14 23:28:29 +01:00
|
|
|
<p>{getHeartEmoji(book.my_rating)}</p>
|
2023-12-09 23:48:53 +01:00
|
|
|
</div>
|
|
|
|
))
|
|
|
|
}
|
|
|
|
</ul>
|
|
|
|
</section>
|
|
|
|
))
|
|
|
|
}
|
|
|
|
</main>
|
2024-02-14 23:28:29 +01:00
|
|
|
</SectionContainer>
|