This commit is contained in:
@@ -25,15 +25,15 @@ type GameMap = Record<
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|
||||||
const songFiles = import.meta.globEager('./Data/*/*/songs/*.mp3') as Record<
|
const songFiles = {
|
||||||
string,
|
...import.meta.globEager('./Data/*/*/Songs/*.mp3'),
|
||||||
{ default: string }
|
...import.meta.globEager('./Data/*/*/songs/*.mp3')
|
||||||
>
|
} as Record<string, { default: string }>
|
||||||
|
|
||||||
const answerFiles = import.meta.globEager('./Data/*/*/answers/*.mp3') as Record<
|
const answerFiles = {
|
||||||
string,
|
...import.meta.globEager('./Data/*/*/Answers/*.mp3'),
|
||||||
{ default: string }
|
...import.meta.globEager('./Data/*/*/answers/*.mp3')
|
||||||
>
|
} as Record<string, { default: string }>
|
||||||
|
|
||||||
const getParts = (path: string) => {
|
const getParts = (path: string) => {
|
||||||
const normalized = path.replace(/\\/g, '/')
|
const normalized = path.replace(/\\/g, '/')
|
||||||
@@ -54,7 +54,7 @@ const getParts = (path: string) => {
|
|||||||
const addEntry = (target: GameMap, info: ReturnType<typeof getParts>, url: string) => {
|
const addEntry = (target: GameMap, info: ReturnType<typeof getParts>, url: string) => {
|
||||||
if (!info) return
|
if (!info) return
|
||||||
const { game, category, type, file } = info
|
const { game, category, type, file } = info
|
||||||
const number = Number(file.replace('.mp3', ''))
|
const number = Number(file.replace(/\.mp3$/i, ''))
|
||||||
if (!Number.isFinite(number)) return
|
if (!Number.isFinite(number)) return
|
||||||
|
|
||||||
if (!target[game]) {
|
if (!target[game]) {
|
||||||
@@ -71,7 +71,9 @@ const addEntry = (target: GameMap, info: ReturnType<typeof getParts>, url: strin
|
|||||||
clues: []
|
clues: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const bucket = type === 'Songs' ? 'songs' : 'answers'
|
const normalizedType = type.toLowerCase()
|
||||||
|
if (normalizedType !== 'songs' && normalizedType !== 'answers') return
|
||||||
|
const bucket = normalizedType === 'songs' ? 'songs' : 'answers'
|
||||||
target[game].categories[category][bucket][number] = url
|
target[game].categories[category][bucket][number] = url
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user