11---
22import { getCollection } from ' astro:content' ;
33import { TutorialsShowcase } from ' ./tutorials/TutorialsShowcase' ;
4+ import type { ImageMetadata } from ' astro' ;
5+ import { getImage } from ' astro:assets' ;
46
57// Import data for filters
68import services from ' ../data/developerhub/services.json' ;
79import platforms from ' ../data/developerhub/platforms.json' ;
810import deployments from ' ../data/developerhub/deployments.json' ;
911
12+ const images = import .meta .glob <{ default: ImageMetadata }>(
13+ ' /src/assets/images/aws/tutorials/*.{jpeg,jpg,png,gif}'
14+ );
15+
1016const allTutorials = await getCollection (' docs' , ({ id }) => {
1117 return id .startsWith (' aws/tutorials/' ) && ! id .includes (' /index' );
1218});
1319
14- const tutorialData = allTutorials .map (tutorial => {
15- const title = tutorial .data .title || ' Unknown Tutorial' ;
16- const description = tutorial .data .description || ` Tutorial: ${title } ` ;
17- const slug = tutorial .id ; // Use id instead of slug for proper path
18-
19- return {
20- title ,
21- description ,
22- slug ,
23- leadimage: tutorial .data .leadimage ,
24- services: tutorial .data .services || [],
25- platform: tutorial .data .platform || [],
26- deployment: tutorial .data .deployment || [],
27- pro: tutorial .data .pro || false ,
28- };
29- });
20+ const tutorialData = await Promise .all (
21+ allTutorials .map (async (tutorial ) => {
22+ const title = tutorial .data .title || ' Unknown Tutorial' ;
23+ const description = tutorial .data .description || ` Tutorial: ${title } ` ;
24+ const slug = tutorial .id ; // Use id instead of slug for proper path
25+ const imagePath = ` /src/assets/images/aws/tutorials/${tutorial .data .leadimage } ` ;
26+ const optimizedLeadImage = await getImage ({
27+ src: images [imagePath ](),
28+ format: ' png' ,
29+ width: 330 ,
30+ });
31+
32+ return {
33+ title ,
34+ description ,
35+ slug ,
36+ leadimage: optimizedLeadImage .src ,
37+ services: tutorial .data .services || [],
38+ platform: tutorial .data .platform || [],
39+ deployment: tutorial .data .deployment || [],
40+ pro: tutorial .data .pro || false ,
41+ };
42+ })
43+ );
3044---
3145
3246<TutorialsShowcase
@@ -35,4 +49,4 @@ const tutorialData = allTutorials.map(tutorial => {
3549 platforms ={ platforms }
3650 deployments ={ deployments }
3751 client:load
38- />
52+ />
0 commit comments