Config file fixes
This commit is contained in:
@@ -8,31 +8,22 @@ export function useConfig() {
|
||||
|
||||
useEffect(() => {
|
||||
const loadConfig = async () => {
|
||||
// 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
|
||||
try {
|
||||
const response = await fetch('/config.yaml')
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to load configuration')
|
||||
}
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user