const storyModules = import.meta.glob(['../../assets/images/story/*.png', '../../assets/images/taoyuan-oath-title.png'], { eager: true, import: 'default' }) as Record; const storyAssetAliases: Record = { 'story-chaos': 'story-yellow-turban-chaos', 'story-liu-bei': 'story-liu-bei-resolve', 'story-three-heroes': 'story-three-heroes-meet', 'story-militia': 'story-volunteer-militia', 'story-sortie': 'story-first-sortie', 'story-yellow-pursuit': 'story-yellow-turban-pursuit', 'story-anti-dong': 'story-anti-dong-pass', 'story-xuzhou': 'story-xuzhou-handover', 'story-wandering': 'story-wandering-road', 'story-wolong': 'story-wolong-cottage', 'story-red-cliffs': 'story-red-cliffs-fire', 'story-yizhou': 'story-yizhou-mountain-pass', 'story-northern': 'story-northern-expedition', 'story-nanzhong': 'story-nanzhong-pacification', 'story-yiling-baidi': 'story-yiling-baidi-aftermath', 'story-qishan-renewed': 'story-qishan-renewed-offensive', 'story-hanzhong-rain': 'story-hanzhong-rain-defense', 'story-nanzhong-captures': 'story-nanzhong-seven-captures', 'story-resolve': 'story-liu-bei-resolve', 'title-taoyuan': 'story-taoyuan-oath-title' }; function storyKeyFromPath(path: string) { const fileName = path.split('/').pop() ?? path; const slug = fileName.replace(/\.png$/i, '').replace(/^\d+-/, ''); return `story-${slug}`; } const discoveredStoryAssets = Object.fromEntries( Object.entries(storyModules).map(([path, url]) => [storyKeyFromPath(path), url]) ); export const storyBackgroundAssets: Record = { ...discoveredStoryAssets }; Object.entries(storyAssetAliases).forEach(([alias, target]) => { const targetUrl = storyBackgroundAssets[target]; if (targetUrl) { storyBackgroundAssets[alias] = targetUrl; } }); export function storyBackgroundKeysFor(baseKey: string) { const prefix = `${baseKey}-`; const keys = Object.keys(storyBackgroundAssets) .filter((key) => key === baseKey || key.startsWith(prefix)) .sort(); return Array.from(new Set(keys)); }