Skip to content

Commit 878e670

Browse files
committed
add ep #
1 parent 8e55c5a commit 878e670

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/components/Main.astro

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ const episodesBySeasons = Object.fromEntries(
3838
);
3939
4040
const seasons = Object.keys(episodesBySeasons).map(Number).sort((a, b) => b - a);
41+
42+
// Calculate the total number of episodes
43+
const totalEpisodes = posts.length;
44+
4145
---
4246

4347
<div class="mx-auto px-5 py-7 flex flex-col lg:flex-row lg:max-w-6xl">
@@ -74,8 +78,13 @@ const seasons = Object.keys(episodesBySeasons).map(Number).sort((a, b) => b - a)
7478
<h2 class="text-2xl font-bold text-his-green">Season {season}</h2>
7579
)}
7680
<div class="space-y-1">
77-
{episodesBySeasons[season].map((episode) => (
78-
<article class="hover:bg-his-hover px-2 rounded-lg transition-colors">
81+
{episodesBySeasons[season].map((episode, index) => {
82+
// Find the index of the current episode in the overall sorted posts array
83+
const overallIndex = posts.findIndex(p => p.slug === episode.slug);
84+
// Calculate the episode number (total - overallIndex)
85+
const epNumber = totalEpisodes - overallIndex;
86+
return (
87+
<article class="hover:bg-his-hover px-2 rounded-lg transition-colors relative">
7988
<a href={`/${episode.slug}`} class="block group">
8089
<h3 class="text-xl font-semibold group-hover:text-his-green transition-colors">
8190
{episode.data.title}
@@ -89,8 +98,13 @@ const seasons = Object.keys(episodesBySeasons).map(Number).sort((a, b) => b - a)
8998
</div>
9099
<p class="mt-2 text-his-text-secondary">{episode.data.description}</p>
91100
</a>
101+
{/* Episode number at top right */}
102+
<span class="absolute top-2 right-2 text-xs font-bold text-his-text-secondary">
103+
#{epNumber}
104+
</span>
92105
</article>
93-
))}
106+
);
107+
})}
94108
</div>
95109
</section>
96110
))}

0 commit comments

Comments
 (0)