2023-12-10 01:15:15 +01:00
|
|
|
---
|
|
|
|
|
import SectionContainer from '../../components/SectionContainer.astro';
|
2024-06-02 11:51:08 +02:00
|
|
|
import tv from '../../data/watched.json'
|
2023-12-10 01:15:15 +01:00
|
|
|
|
2024-06-02 11:51:08 +02:00
|
|
|
let watched = [];
|
|
|
|
|
let currently = [];
|
|
|
|
|
|
|
|
|
|
tv.lists.forEach(list => {
|
|
|
|
|
switch (list.name) {
|
|
|
|
|
case "Watched":
|
|
|
|
|
watched = list.tv;
|
|
|
|
|
break;
|
|
|
|
|
case "Currently watching":
|
|
|
|
|
currently = list.tv;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const tvByYear = watched.reduce((acc, tv) => {
|
2023-12-10 01:15:15 +01:00
|
|
|
const year = new Date(tv.date.string).getFullYear();
|
|
|
|
|
if (!acc[year]) {
|
|
|
|
|
acc[year] = [];
|
|
|
|
|
}
|
|
|
|
|
acc[year].push(tv);
|
|
|
|
|
return acc;
|
|
|
|
|
}, {});
|
|
|
|
|
|
2024-06-02 11:51:08 +02:00
|
|
|
const sortedYears = Object.keys(tvByYear).sort((a: any, b: any) => b - a);
|
2023-12-10 01:15:15 +01:00
|
|
|
---
|
|
|
|
|
<SectionContainer>
|
2024-06-02 11:51:08 +02:00
|
|
|
<main class="flex flex-col flex-1 gap-4 mt-4">
|
2023-12-10 01:15:15 +01:00
|
|
|
<h1 class="text-3xl font-extrabold">📺 La télévision</h1>
|
2024-06-02 11:51:08 +02:00
|
|
|
|
|
|
|
|
<h2 class="text-xl font-semibold">on the screen</h2>
|
|
|
|
|
<ul>
|
|
|
|
|
{currently.map((tv) => (
|
|
|
|
|
<li class="borderbottom mb-3">👀 {tv.title}</li>
|
|
|
|
|
))}
|
|
|
|
|
</ul>
|
|
|
|
|
|
2023-12-10 01:15:15 +01:00
|
|
|
{sortedYears.map(year => (
|
2024-06-02 11:51:08 +02:00
|
|
|
<details>
|
|
|
|
|
<summary class="text-xl font-semibold cursor-pointer">{year} <span class="text-xs">({tvByYear[year].length} entries)</span></summary>
|
2023-12-28 21:59:58 +01:00
|
|
|
<ul>
|
2023-12-10 01:15:15 +01:00
|
|
|
{
|
2023-12-28 21:59:58 +01:00
|
|
|
tvByYear[year].map(tv => (
|
|
|
|
|
<li class="flex mb-2 break-words gap-2 borderbottom">
|
|
|
|
|
<p class="text-s w-1/3">{tv.title}</p>
|
|
|
|
|
<p class="w-1/3 text-center">{tv.type}</p>
|
2024-06-02 11:51:08 +02:00
|
|
|
<p class="w-1/3 text-end">{tv.rating === 5 ? "❤️" : ""}</p>
|
2023-12-28 21:59:58 +01:00
|
|
|
</li>
|
2023-12-10 01:15:15 +01:00
|
|
|
))
|
|
|
|
|
}
|
|
|
|
|
</ul>
|
2024-06-02 11:51:08 +02:00
|
|
|
</details>
|
2023-12-28 21:59:58 +01:00
|
|
|
))}
|
2023-12-10 01:15:15 +01:00
|
|
|
</main>
|
2024-01-28 23:15:24 +01:00
|
|
|
</SectionContainer>
|