Move prod config file out of build directories
This commit is contained in:
@@ -8,22 +8,31 @@ export function useConfig() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadConfig = async () => {
|
const loadConfig = async () => {
|
||||||
|
// Try local development path first, then production path
|
||||||
|
const paths = ['/config.yaml', '/homepage/config.yaml']
|
||||||
|
|
||||||
|
for (const path of paths) {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/config.yaml')
|
const response = await fetch(path)
|
||||||
if (!response.ok) {
|
if (response.ok) {
|
||||||
throw new Error('Failed to load configuration')
|
|
||||||
}
|
|
||||||
const text = await response.text()
|
const text = await response.text()
|
||||||
|
console.log(`Loaded config from ${path}`)
|
||||||
console.log('Raw YAML:', text.substring(0, 500) + '...') // Show first 500 chars
|
console.log('Raw YAML:', text.substring(0, 500) + '...') // Show first 500 chars
|
||||||
const parsed = yaml.load(text) as Config
|
const parsed = yaml.load(text) as Config
|
||||||
console.log('Parsed config sections:', parsed.sections)
|
console.log('Parsed config sections:', parsed.sections)
|
||||||
console.log('First service cardStyle:', parsed.services[0]?.cardStyle)
|
console.log('First service cardStyle:', parsed.services[0]?.cardStyle)
|
||||||
setConfig(parsed)
|
setConfig(parsed)
|
||||||
setError(null)
|
setError(null)
|
||||||
} catch (err) {
|
return // Successfully loaded config, exit the loop
|
||||||
setError(err instanceof Error ? err.message : 'Failed to load configuration')
|
|
||||||
console.error('Error loading configuration:', err)
|
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`Failed to load config from ${path}:`, err)
|
||||||
|
// Continue to next path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we get here, none of the paths worked
|
||||||
|
setError('Failed to load configuration from any location')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load config immediately
|
// Load config immediately
|
||||||
|
|||||||
Reference in New Issue
Block a user