chore: some refactoring and added phosphor icons
This commit is contained in:
@@ -8,27 +8,21 @@ import macchinisti from '@/data/macchinisti.yaml'
|
||||
macchinisti.sort((a, b) => b.entranceDate - a.entranceDate)
|
||||
|
||||
// Import all images from assets folder
|
||||
const images: Record<string, ImageMetadata> = Object.fromEntries(
|
||||
await Promise.all(
|
||||
Object.entries(import.meta.glob('@/assets/macchinisti/*')).map(async ([path, module]) => [
|
||||
path.split('/').pop()!.split('.')[0],
|
||||
// @ts-ignore
|
||||
(await module()).default,
|
||||
])
|
||||
)
|
||||
const images = Object.fromEntries(
|
||||
Object.entries(
|
||||
import.meta.glob<{ default: ImageMetadata }>('@/assets/macchinisti/*', {
|
||||
eager: true,
|
||||
})
|
||||
).map(([path, module]) => [path.split('/').pop()!.split('.')[0], module])
|
||||
)
|
||||
|
||||
console.log(macchinisti)
|
||||
console.log(images)
|
||||
|
||||
const currentMacchinisti = macchinisti.filter(macchinista => !macchinista.exitDate)
|
||||
const pastMacchinisti = macchinisti.filter(macchinista => macchinista.exitDate)
|
||||
|
||||
const getMacchinistaPicture = (fullName: string): ImageMetadata => {
|
||||
const getMacchinistaPicture = (fullName: string) => {
|
||||
const macchinistaId = fullName.toLowerCase().replace(/\s+/g, '-')
|
||||
console.log(macchinistaId)
|
||||
|
||||
return images[macchinistaId] ?? images['fallback']
|
||||
const { default: image } = images[macchinistaId] ?? images['fallback']
|
||||
return image
|
||||
}
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user