Skip to content

Commit 4ebb7bc

Browse files
implement the tutorials page (#15)
* get the structure right * fix issue with opening the tutorial * make filtering work * Added auto resizing of the image assets The images were loading very slowly because they were 1900+ pixels wide but only rendered at 330px. I converted the astro component to load the images from assets, resize them and pass those to the React component. * make cards clickable --------- Co-authored-by: Brian Rinaldi <[email protected]>
1 parent c909536 commit 4ebb7bc

File tree

10 files changed

+1467
-12
lines changed

10 files changed

+1467
-12
lines changed

public/images/aws/elb-load-balancing-featured-image.png renamed to src/assets/images/aws/tutorials/elb-load-balancing-featured-image.png

File renamed without changes.
1.18 MB
Loading
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
import { getCollection } from 'astro:content';
3+
import { TutorialsShowcase } from './tutorials/TutorialsShowcase';
4+
import type { ImageMetadata } from 'astro';
5+
import { getImage } from 'astro:assets';
6+
7+
// Import data for filters
8+
import services from '../data/developerhub/services.json';
9+
import platforms from '../data/developerhub/platforms.json';
10+
import deployments from '../data/developerhub/deployments.json';
11+
12+
const images = import.meta.glob<{ default: ImageMetadata }>(
13+
'/src/assets/images/aws/tutorials/*.{jpeg,jpg,png,gif}'
14+
);
15+
16+
const allTutorials = await getCollection('docs', ({ id }) => {
17+
return id.startsWith('aws/tutorials/') && !id.includes('/index');
18+
});
19+
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+
);
44+
---
45+
46+
<TutorialsShowcase
47+
tutorials={tutorialData}
48+
services={services}
49+
platforms={platforms}
50+
deployments={deployments}
51+
client:load
52+
/>

0 commit comments

Comments
 (0)