import type { ImageMetadata } from 'astro';

const modules = import.meta.glob<{ default: ImageMetadata }>(
  '../content/find/*/hero.{png,jpg,jpeg,gif,webp}',
  { eager: true }
);

const heroes = new Map<string, ImageMetadata>();
for (const [path, mod] of Object.entries(modules)) {
  const match = path.match(/find\/([^/]+)\/hero\./);
  if (match) heroes.set(match[1], mod.default);
}

export function findHero(slug: string): ImageMetadata | undefined {
  return heroes.get(slug);
}
