This commit is contained in:
2026-02-09 14:12:44 +04:00
parent 6727d7391f
commit 431fe2dd55
13 changed files with 375 additions and 166 deletions

View File

@@ -1,25 +1,96 @@
---
import { getCollection } from "astro:content";
import GameLayout from "../layouts/GameLayout.astro";
import Timeline from "../components/Timeline.astro";
import ContentSearch from "../components/ContentSearch.astro";
// 1. Récupère TOUS les articles et les trie.
const allPosts = await getCollection("journal");
const sortedPosts = allPosts.sort(
// On récupère les Ères
const eras = allPosts
.filter((p) => p.data.isEra)
.sort((a, b) => a.data.publishDate.valueOf() - b.data.publishDate.valueOf())
.map((p) => ({ id: p.id, title: p.data.title }));
const chroniclesOnly = allPosts.filter((post) => !post.data.isEra);
const sortedPosts = chroniclesOnly.sort(
(a, b) => b.data.publishDate.valueOf() - a.data.publishDate.valueOf(),
);
// 2. Extrait toutes les balises uniques
const allTags = [...new Set(allPosts.flatMap((post) => post.data.tags || []))];
const allTags = [
...new Set(chroniclesOnly.flatMap((post) => post.data.tags || [])),
];
---
<GameLayout title="Journal d'Aventure">
<h1>📖 Journal d'Aventure</h1>
<p style="text-align: center; margin-bottom: 3rem;">
Les chroniques de nos voyages. Utilisez la barre de recherche pour
trouver un récit.
</p>
<div class="index-container">
<header class="dnd-header">
<h1 class="dnd-title">Sweeties Journey</h1>
<div class="dnd-bar"></div>
<p class="dnd-intro">
Chroniques des aventures d'une portion de nouilles de la
communauté, idée originale de Orson Pattes Givrées
</p>
</header>
<!-- 2. On passe tous les articles au composant client -->
<ContentSearch posts={sortedPosts} tags={allTags} basePath="journal" />
<Timeline eras={eras} />
<ContentSearch posts={sortedPosts} tags={allTags} basePath="journal" />
</div>
</GameLayout>
<style is:global>
.index-container {
max-width: 1000px;
margin: 0 auto;
padding: 0 1rem;
}
/* Le style du titre DnD reste le même que précédemment */
.dnd-header {
margin: 2rem 0;
}
.dnd-title {
font-family: "Playfair Display", serif;
font-size: 3.5rem;
color: #c89b3c;
margin: 0;
}
.dnd-bar {
height: 4px;
background: linear-gradient(to right, #c89b3c 0%, transparent 100%);
margin-top: 4px;
}
.dnd-intro {
font-family: "Cinzel", serif;
font-size: 0.9rem;
margin-top: 1rem;
opacity: 0.8;
}
</style>
<script>
function setupEraFiltering() {
const eraButtons = document.querySelectorAll(".era-chip");
const posts = document.querySelectorAll(".gold-button");
eraButtons.forEach((button) => {
button.addEventListener("click", () => {
const selectedEra = button.getAttribute("data-era");
// Toggle active class
eraButtons.forEach((btn) => btn.classList.remove("active"));
button.classList.add("active");
posts.forEach((post) => {
const postEra = post.getAttribute("data-era");
if (selectedEra === "all" || postEra === selectedEra) {
(post as HTMLElement).style.display = "block";
} else {
(post as HTMLElement).style.display = "none";
}
});
});
});
}
document.addEventListener("astro:page-load", setupEraFiltering);
</script>

View File

@@ -2,7 +2,6 @@
// [tag].astro
import { getCollection } from "astro:content";
import GameLayout from "../../../layouts/GameLayout.astro";
import GoldButton from "../../../components/ui/GoldButton.astro";
export async function getStaticPaths() {
const allPosts = await getCollection("journal");
@@ -37,11 +36,15 @@ const { posts, originalTag } = Astro.props;
<div class="card-grid">
{
posts.map((post) => (
<GoldButton
href={`/journal/${post.id}/`}
title={post.data.title}
body={`Chronique du ${new Date(post.data.publishDate).toLocaleDateString("fr-FR")}`}
/>
<a href={`/journal/${post.id}/`} class="gold-button">
<div class="title">{post.data.title}</div>
<p class="body">
Chronique du{" "}
{new Date(post.data.publishDate).toLocaleDateString(
"fr-FR",
)}
</p>
</a>
))
}
</div>
@@ -49,6 +52,7 @@ const { posts, originalTag } = Astro.props;
</GameLayout>
<style>
/* Tes styles spécifiques au conteneur restent inchangés */
.tag-page-container {
max-width: 1000px;
margin: 0 auto;
@@ -61,7 +65,7 @@ const { posts, originalTag } = Astro.props;
font-size: 0.9rem;
}
.tag-header h1 {
font-size: 1.8rem; /* Titre réduit */
font-size: 1.8rem;
margin: 1.5rem 0 3rem;
}
.tag-header span {