import fs from "fs"; import path from "path"; const IMAGES_ROOT = path.join(process.cwd(), "src/assets/images"); const IMAGE_EXT = /\.(jpe?g|png|webp|gif|avif|svg)$/i; export type Slide = { id: string; image: string; href: string; }; function listImages(subdir: string) { const dir = path.join(IMAGES_ROOT, subdir); if (!fs.existsSync(dir)) return []; return fs .readdirSync(dir) .filter((name) => IMAGE_EXT.test(name) && !name.startsWith(".")) .sort((a, b) => a.localeCompare(b, undefined, { numeric: true })) .map((file) => `/assets/images/${subdir}/${encodeURIComponent(file)}`); } export function getSlides(): Slide[] { return listImages("slides").map((image, index) => ({ id: `slide-${index + 1}`, image, href: "#", })); } export function getLogoSrc() { return listImages("logo")[0] ?? "/placeholders/logo.svg"; }