Skip to content

Commit

Permalink
feat: useAssetsFile
Browse files Browse the repository at this point in the history
  • Loading branch information
ming committed Feb 14, 2024
1 parent 4b7ee09 commit b041ff8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/hooks/useAssetsFile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

export default function useAssetsFile () {
const getImageFile = (url) => {
const path = `/src/assets/images/${url}`
const modules = import.meta.glob('@/assets/images/**/*.{png,svg,jpg,jpeg}', { eager: true })
return modules[path].default
}

return {
getImageFile,
}
}

0 comments on commit b041ff8

Please sign in to comment.