Add media carousel section to homepage

Display past event photos in an auto-playing carousel between the
"What is Spanglish?" and "Stay Updated" sections. Images are loaded
dynamically from /images/carrousel/ folder with support for jpg, png,
and webp formats.
This commit is contained in:
Michilis
2026-02-01 06:07:58 +00:00
parent 6df3baf0be
commit b0cbaa60f0
15 changed files with 255 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import fs from 'fs';
import path from 'path';
export interface CarouselImage {
src: string;
alt: string;
}
/**
* Reads all images from the carrousel folder at build/request time.
* Supports jpg, jpeg, png, webp, and gif formats.
*/
export function getCarouselImages(): CarouselImage[] {
const carrouselDir = path.join(process.cwd(), 'public', 'images', 'carrousel');
try {
const files = fs.readdirSync(carrouselDir);
// Filter for supported image formats
const supportedExtensions = ['.jpg', '.jpeg', '.png', '.webp', '.gif'];
const imageFiles = files.filter((file) => {
const ext = path.extname(file).toLowerCase();
return supportedExtensions.includes(ext);
});
// Sort by filename (which includes date) for consistent ordering
imageFiles.sort();
return imageFiles.map((file) => ({
src: `/images/carrousel/${file}`,
alt: 'Spanglish language exchange event moment',
}));
} catch (error) {
console.error('Error reading carrousel directory:', error);
return [];
}
}