--- import type { ImageMetadata } from 'astro'; import { methodSteps } from '../../data/method'; import T from '../content/T.astro'; import TImg from '../content/TImg.astro'; const images = import.meta.glob<{ default: ImageMetadata }>('../../assets/img/method-*.{jpg,png}', { eager: true }); const imgOf = (name: string) => Object.entries(images).find(([p]) => p.includes(name))?.[1].default; --- {methodSteps.map((s, i) => ( {imgOf(s.image) && } {s.n} ))}