Fix: Correction du routage et chargement initial des vues
All checks were successful
Deploy / Deploy to Production (push) Successful in 15s

Router:
- Suppression de l'appel direct à loadPage au démarrage
- router.listen() gère maintenant le chargement initial
- Utilisation de router.run() dans le handler popstate
- Résolution de la 404 sur /.json à la home

App.svelte:
- Attente de pageData avant calcul du template et de la vue
- Renommage de view en View (majuscule requise en Svelte 5)
- Correction de la réactivité des composants dynamiques

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
isUnknown 2026-02-07 08:38:49 +01:00
parent 9ab6344835
commit 65cfba8c77
2 changed files with 6 additions and 9 deletions

View file

@ -29,10 +29,10 @@
'default': Default 'default': Default
} }
const template = $derived(page.template || 'default')
const view = $derived(templates[template] || Default)
const pageData = $derived(page.data) const pageData = $derived(page.data)
const showFooter = $derived(template !== 'home') const template = $derived(pageData ? (page.template || 'default') : null)
const View = $derived(template ? (templates[template] || Default) : null)
const showFooter = $derived(template && template !== 'home')
</script> </script>
<div class="app"> <div class="app">
@ -40,8 +40,8 @@
<Header /> <Header />
<main class="main"> <main class="main">
{#if pageData && view} {#if pageData && View}
<view data={pageData} /> <View data={pageData} />
{/if} {/if}
</main> </main>

View file

@ -60,9 +60,6 @@ router
}); });
export function initRouter() { export function initRouter() {
// Load initial page data
loadPage(window.location.pathname);
// Start listening to route changes // Start listening to route changes
router.listen(); router.listen();
@ -86,7 +83,7 @@ export function initRouter() {
// Handle browser back/forward // Handle browser back/forward
window.addEventListener("popstate", () => { window.addEventListener("popstate", () => {
loadPage(window.location.pathname); router.run(window.location.pathname);
}); });
} }