@@ -131,15 +131,16 @@ export async function fetchHomePageContent() {
131131 fetchWithTimeout ( `${ Config . apiUrl } /wp-json/wp/v2/posts?_embed&per_page=3&tags=${ TAG_IDS . kTAGID } &${ Config . articleCardFields } ` ) ,
132132 fetchWithTimeout ( `${ Config . apiUrl } /wp-json/wp/v2/posts?_embed&per_page=3&tags=${ TAG_IDS . lTAGID } &${ Config . articleCardFields } ` ) ,
133133 fetchWithTimeout ( `${ Config . apiUrl } /wp-json/wp/v2/posts?_embed&per_page=3&tags=${ TAG_IDS . hTAGID } &${ Config . articleCardFields } ` ) ,
134- fetchWithTimeout ( `${ Config . apiUrl } /wp-json/wp/v2/classifieds?_embed&Featured=3` )
134+ fetchWithTimeout ( `${ Config . apiUrl } /wp-json/wp/v2/classifieds?_embed&Featured=3` ) ,
135+ fetchWithTimeout ( `${ Config . apiUrl } /wp-json/wp/v2/categories?slug=podcasts` )
135136 ] ;
136137
137138 const results = await Promise . allSettled ( fetchPromises ) ;
138139
139140 const [
140141 aStoryRes , bStoryRes , c1StoryRes , c2StoryRes , d1StoryRes , d2StoryRes , gStoryRes , mmStoryRes ,
141142 f1StoryRes , f2StoryRes , iStoryRes , jStoryRes , kStoryRes , lStoryRes , hStoryRes ,
142- classifiedsRes
143+ classifiedsRes , podcastCatRes
143144 ] = results . map ( ( res , i ) => {
144145 if ( res . status === "fulfilled" && res . value . ok ) return res . value ;
145146
@@ -190,7 +191,33 @@ export async function fetchHomePageContent() {
190191
191192 const classifieds = await safeJsonArray ( classifiedsRes ) ;
192193
194+ // Fetch latest podcast post (two-step: category slug → latest post)
195+ let latestPodcast = null ;
196+ try {
197+ const podcastCats = await safeJsonArray ( podcastCatRes ) ;
198+ if ( podcastCats . length > 0 ) {
199+ const podcastCatId = podcastCats [ 0 ] . id ;
200+ const podcastPostRes = await fetchWithTimeout (
201+ `${ Config . apiUrl } /wp-json/wp/v2/posts?_embed&per_page=1&categories=${ podcastCatId } `
202+ ) ;
203+ const podcastPosts = await safeJsonArray ( podcastPostRes ) ;
204+ if ( podcastPosts . length > 0 ) {
205+ const post = podcastPosts [ 0 ] ;
206+ latestPodcast = {
207+ id : post . id ?? null ,
208+ title : post . title ?. rendered ?? "" ,
209+ content : post . content ?. rendered ?? "" ,
210+ link : post . link ?? "" ,
211+ date : post . date ?? null ,
212+ _embedded : filterEmbeddedData ( post )
213+ } ;
214+ }
215+ }
216+ } catch ( err ) {
217+ console . error ( "Non-critical: failed to fetch latest podcast:" , err . message ) ;
218+ }
219+
193220 const filteredPosts = filterPostsData ( posts ) ;
194221
195- return { posts : filteredPosts , multimediaPosts, classifieds } ;
222+ return { posts : filteredPosts , multimediaPosts, classifieds, latestPodcast } ;
196223}
0 commit comments