@@ -38,6 +38,10 @@ const episodesBySeasons = Object.fromEntries(
38
38
);
39
39
40
40
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
+
41
45
---
42
46
43
47
<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)
74
78
<h2 class = " text-2xl font-bold text-his-green" >Season { season } </h2 >
75
79
)}
76
80
<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" >
79
88
<a href = { ` /${episode .slug } ` } class = " block group" >
80
89
<h3 class = " text-xl font-semibold group-hover:text-his-green transition-colors" >
81
90
{ episode .data .title }
@@ -89,8 +98,13 @@ const seasons = Object.keys(episodesBySeasons).map(Number).sort((a, b) => b - a)
89
98
</div >
90
99
<p class = " mt-2 text-his-text-secondary" >{ episode .data .description } </p >
91
100
</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 >
92
105
</article >
93
- ))}
106
+ );
107
+ })}
94
108
</div >
95
109
</section >
96
110
))}
0 commit comments