diff --git a/src/hooks/useConfig.ts b/src/hooks/useConfig.ts index b10ee56..c99a958 100644 --- a/src/hooks/useConfig.ts +++ b/src/hooks/useConfig.ts @@ -8,22 +8,31 @@ export function useConfig() { useEffect(() => { const loadConfig = async () => { - try { - const response = await fetch('/config.yaml') - if (!response.ok) { - throw new Error('Failed to load configuration') + // Try local development path first, then production path + const paths = ['/config.yaml', '/homepage/config.yaml'] + + for (const path of paths) { + try { + const response = await fetch(path) + if (response.ok) { + const text = await response.text() + console.log(`Loaded config from ${path}`) + console.log('Raw YAML:', text.substring(0, 500) + '...') // Show first 500 chars + const parsed = yaml.load(text) as Config + console.log('Parsed config sections:', parsed.sections) + console.log('First service cardStyle:', parsed.services[0]?.cardStyle) + setConfig(parsed) + setError(null) + return // Successfully loaded config, exit the loop + } + } catch (err) { + console.error(`Failed to load config from ${path}:`, err) + // Continue to next path } - const text = await response.text() - console.log('Raw YAML:', text.substring(0, 500) + '...') // Show first 500 chars - const parsed = yaml.load(text) as Config - console.log('Parsed config sections:', parsed.sections) - console.log('First service cardStyle:', parsed.services[0]?.cardStyle) - setConfig(parsed) - setError(null) - } catch (err) { - setError(err instanceof Error ? err.message : 'Failed to load configuration') - console.error('Error loading configuration:', err) } + + // If we get here, none of the paths worked + setError('Failed to load configuration from any location') } // Load config immediately