updated and fixed most pages + navbar update on home page

This commit is contained in:
Henri
2026-04-22 20:59:29 +03:00
parent 83e090ef8f
commit 08d6e08c4d
12 changed files with 168 additions and 213 deletions

View File

@@ -11,7 +11,23 @@
let { routes } = $props();
let currentPath = $state(window.location.pathname);
let CurrentComponent = $derived(routes[currentPath] || routes["/"]);
let CurrentComponent = $state(null);
async function resolveCurrentComponent(path) {
const routeEntry = routes[path] || routes["/"];
if (typeof routeEntry === "function") {
try {
const module = await routeEntry();
CurrentComponent = module?.default || null;
} catch {
CurrentComponent = null;
}
return;
}
CurrentComponent = routeEntry || null;
}
function navigate(path) {
window.history.pushState({}, "", path);
@@ -46,6 +62,10 @@
return () => window.removeEventListener("click", handleClick);
});
$effect(() => {
resolveCurrentComponent(currentPath);
});
</script>
{#if CurrentComponent}