getImage.ts
330 Bytes
const getImage = (name: string, path = '') => {
if (typeof name === 'undefined') return 'error.png'
const fullPath = path === '' ? `/src/assets/images/${name}` : `/src/assets/images${path}/${name}`
const modules = import.meta.globEager('/src/assets/images/*/*')
return modules[fullPath]?.default
}
export default getImage