✨ added la biblioteca
This commit is contained in:
parent
bfdc04e02f
commit
c26c1da4ed
4 changed files with 172 additions and 1 deletions
46
src/pages/logs/books.astro
Normal file
46
src/pages/logs/books.astro
Normal file
|
@ -0,0 +1,46 @@
|
|||
---
|
||||
import SectionContainer from '../../components/SectionContainer.astro';
|
||||
import books from '../../data/biblioteca.json'
|
||||
|
||||
const postsByYear = books.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(postsByYear).sort((a, b) => b - a);
|
||||
|
||||
function getEmojiStars(rating) {
|
||||
let stars = '';
|
||||
for (let i = 0; i < rating; i++) {
|
||||
stars += '⭐';
|
||||
}
|
||||
return stars;
|
||||
}
|
||||
---
|
||||
<SectionContainer>
|
||||
<main class="flex flex-col h-screen gap-4 mt-4">
|
||||
<h1 class="text-3xl font-extrabold">📚 ¿Dónde está la biblioteca?</h1>
|
||||
<h2 class="text-xl font-semibold">2023 - Currently Reading:</h2>
|
||||
<p>📖 Barack Obama: A Promised Land</p>
|
||||
{sortedYears.map(year => (
|
||||
<section>
|
||||
<div class="text-xl font-semibold mb-2">{year} - Finished</div>
|
||||
<ul>
|
||||
{
|
||||
books.map((book) => (
|
||||
<div class="flex justify-between mb-2 break-words gap-2 borderbottom">
|
||||
<p class="text-s">{book.title} - {book.author}</p>
|
||||
<p>{getEmojiStars(book.my_rating)}</p>
|
||||
</div>
|
||||
))
|
||||
}
|
||||
</ul>
|
||||
</section>
|
||||
))
|
||||
}
|
||||
</main>
|
||||
</SectionContainer>
|
|
@ -5,6 +5,10 @@ layout: "../../layouts/Layout.astro"
|
|||
---
|
||||
All my logs where I keep track of movies/TV-shows I’ve watched and books I’ve read.
|
||||
|
||||
I don’t use any third-party services for my logs, I store everything in a JSON-format for this website.
|
||||
|
||||
[***📚 Book log***](/logs/books)
|
||||
|
||||
I don’t use any third-party services for my logs, I store everything in a JSON-format for this website.
|
||||
[***📺 Movie log***](/logs/movies)
|
||||
|
||||
[***📺 Serie log***](/logs/series)
|
Loading…
Add table
Add a link
Reference in a new issue