correction config.ts et evolution
This commit is contained in:
@@ -3,26 +3,35 @@ import { getCollection } from "astro:content";
|
||||
import Layout from "../layouts/Layout.astro";
|
||||
import Card from "../components/Card.astro";
|
||||
import EventCard from "../components/EventCard.astro";
|
||||
import BankCard from "../components/BankCard.astro"; // Import du nouveau composant
|
||||
|
||||
const allHumans = await getCollection("humans");
|
||||
const myHumans = allHumans.filter((entry: any) => entry.id.startsWith("latchimynicolas/"));
|
||||
|
||||
|
||||
const allEvents = await getCollection("events");
|
||||
const allBanks = await getCollection("banks"); // Récupération des cartes banques/objets
|
||||
|
||||
// 1. Tri chronologique global
|
||||
const sortedEntries = allHumans.sort(
|
||||
(a, b) => new Date(b.data.date).getTime() - new Date(a.data.date).getTime(),
|
||||
(a: any, b: any) => new Date(b.data.date).getTime() - new Date(a.data.date).getTime()
|
||||
);
|
||||
|
||||
const sortedEvents = allEvents.sort(
|
||||
(a, b) => new Date(a.data.date).getTime() - new Date(b.data.date).getTime(),
|
||||
(a: any, b: any) => new Date(a.data.date).getTime() - new Date(b.data.date).getTime(),
|
||||
);
|
||||
|
||||
// 2. Groupement par utilisateur [cite: 80]
|
||||
const groupedHumans = sortedEntries.reduce((acc, entry) => {
|
||||
const sortedBanks = allBanks.sort(
|
||||
(a: any, b: any) => a.data.name.localeCompare(b.data.name));
|
||||
|
||||
// 2. Groupement par utilisateur
|
||||
const groupedHumans = sortedEntries.reduce((acc: any, entry: any) => {
|
||||
const userName = entry.data.name;
|
||||
if (!acc[userName]) acc[userName] = [];
|
||||
acc[userName].push(entry);
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
---
|
||||
|
||||
<Layout title="Collection">
|
||||
@@ -38,27 +47,28 @@ const groupedHumans = sortedEntries.reduce((acc, entry) => {
|
||||
Object.entries(groupedHumans).map(([userName, cards]) => (
|
||||
<section class="user-collection">
|
||||
<h2 class="user-title">
|
||||
{userName} <span>({cards.length} souffles)</span>
|
||||
{userName}
|
||||
<span>({(cards as any[]).length} souffles)</span>
|
||||
</h2>
|
||||
|
||||
<div class="user-flex-row">
|
||||
{cards.map((entry) => (
|
||||
<a
|
||||
href={`/${entry.id.replace(/\.md$/, "")}`}
|
||||
class="card-link"
|
||||
>
|
||||
<div class="card-scaler">
|
||||
<Card frontmatter={entry.data} />
|
||||
<div class="entry-meta">
|
||||
<p>
|
||||
{new Date(
|
||||
entry.data.date,
|
||||
).toLocaleDateString("fr-FR")}
|
||||
</p>
|
||||
{
|
||||
(cards as any[]).map((entry) => (
|
||||
<a
|
||||
href={`/${entry.id.replace(/\.md$/, "")}`}
|
||||
class="card-link"
|
||||
>
|
||||
<div class="card-scaler">
|
||||
<Card frontmatter={entry.data} />
|
||||
<div class="entry-meta">
|
||||
<p>
|
||||
{new Date(entry.data.date).toLocaleDateString("fr-FR")}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
))}
|
||||
</a>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
<hr class="separator" />
|
||||
</section>
|
||||
@@ -90,8 +100,28 @@ const groupedHumans = sortedEntries.reduce((acc, entry) => {
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
<hr class="separator" />
|
||||
<hr class="separator" />
|
||||
</section>
|
||||
|
||||
<section class="user-collection">
|
||||
<h2 class="user-title">Trésoreries <span>(Sources de Flux)</span></h2>
|
||||
<div class="user-flex-row">
|
||||
{
|
||||
sortedBanks.map((bank) => (
|
||||
<div class="card-link">
|
||||
<div class="card-scaler">
|
||||
{bank.data.sub_category === "finances" ? (
|
||||
<BankCard frontmatter={bank.data} allHumans={myHumans} />
|
||||
) : (
|
||||
/* Autre type de stuff si nécessaire */
|
||||
<div class="tcg-card">Objet: {bank.data.name}</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
</main>
|
||||
@@ -139,6 +169,7 @@ const groupedHumans = sortedEntries.reduce((acc, entry) => {
|
||||
flex-wrap: wrap;
|
||||
gap: 45px; /* Gap simple comme demandé */
|
||||
justify-content: flex-start;
|
||||
padding: 20px 0;
|
||||
margin-bottom: 100px;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user