This commit is contained in:
@@ -25,15 +25,21 @@ type GameMap = Record<
|
||||
}
|
||||
>
|
||||
|
||||
const globEager = (pattern: string) =>
|
||||
(import.meta.glob(pattern, { eager: true, import: 'default' } as any) as unknown) as Record<
|
||||
string,
|
||||
string
|
||||
>
|
||||
|
||||
const songFiles = {
|
||||
...import.meta.globEager('./Data/*/*/Songs/*.mp3'),
|
||||
...import.meta.globEager('./Data/*/*/songs/*.mp3')
|
||||
} as Record<string, { default: string }>
|
||||
...globEager('./Data/*/*/Songs/*.mp3'),
|
||||
...globEager('./Data/*/*/songs/*.mp3')
|
||||
}
|
||||
|
||||
const answerFiles = {
|
||||
...import.meta.globEager('./Data/*/*/Answers/*.mp3'),
|
||||
...import.meta.globEager('./Data/*/*/answers/*.mp3')
|
||||
} as Record<string, { default: string }>
|
||||
...globEager('./Data/*/*/Answers/*.mp3'),
|
||||
...globEager('./Data/*/*/answers/*.mp3')
|
||||
}
|
||||
|
||||
const getParts = (path: string) => {
|
||||
const normalized = path.replace(/\\/g, '/')
|
||||
@@ -75,11 +81,11 @@ const addEntry = (target: GameMap, info: ReturnType<typeof getParts>, url: strin
|
||||
|
||||
const buildGameData = (): Game[] => {
|
||||
const games: GameMap = {}
|
||||
Object.entries(songFiles).forEach(([path, module]) => {
|
||||
addEntry(games, getParts(path), module.default)
|
||||
Object.entries(songFiles).forEach(([path, url]) => {
|
||||
addEntry(games, getParts(path), url)
|
||||
})
|
||||
Object.entries(answerFiles).forEach(([path, module]) => {
|
||||
addEntry(games, getParts(path), module.default)
|
||||
Object.entries(answerFiles).forEach(([path, url]) => {
|
||||
addEntry(games, getParts(path), url)
|
||||
})
|
||||
|
||||
return Object.values(games).map((game) => {
|
||||
|
||||
Reference in New Issue
Block a user