diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 90ed880..9c40cb7 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -6,12 +6,19 @@ import { beforeNavigate } from '$app/navigation'; import { browser } from '$app/environment'; import type { Snippet } from 'svelte'; + import { onMount } from 'svelte'; interface LayoutData { pathname: string; } - let { data, children }: { data: LayoutData; children: Snippet } = $props(); + onMount(() => { + console.log('layout mounted'); + // Set initial random background color on first load + // setRandomBgColor(); + }); + + let { children }: { children: Snippet } = $props(); let showLoader = $state(false); let timer: ReturnType | null = null; @@ -81,7 +88,7 @@ - + @@ -89,11 +96,11 @@
-{#key data.pathname} +
{#if showLoader} {/if} {@render children()}
-{/key} \ No newline at end of file + \ No newline at end of file diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts index 8d3ec26..8545636 100644 --- a/src/routes/+layout.ts +++ b/src/routes/+layout.ts @@ -1,9 +1,10 @@ import { loading } from '$lib/utils/stores.js' loading.set(true) export const load = async ({ url }) => { - const { pathname } = url + loading.set(true) + // Simulate async operation if needed + await new Promise(resolve => setTimeout(resolve, 0)) loading.set(false) - return { - pathname - } -} \ No newline at end of file + + return {} +} diff --git a/src/routes/work/+page.svelte b/src/routes/work/+page.svelte index 6096521..a099244 100644 --- a/src/routes/work/+page.svelte +++ b/src/routes/work/+page.svelte @@ -2,6 +2,7 @@ import { onMount } from 'svelte'; import gsap from 'gsap'; import { SplitText } from 'gsap/SplitText'; + import { goto } from '$app/navigation'; let { data } = $props(); const orderedPosts = $derived.by(() => (data.posts || []).sort((a, b) => { @@ -53,7 +54,8 @@ workclone.style.top = `0`; workclone.style.left = `0`; document.body.appendChild(workclone); - window.location.href = href || '' + // window.location.href = href || '' + goto(href || ''); } }) gsap.fromTo(split.chars, { diff --git a/src/routes/work/[slug]/+page.server.ts b/src/routes/work/[slug]/+page.server.ts index 37f1984..7a9e50b 100644 --- a/src/routes/work/[slug]/+page.server.ts +++ b/src/routes/work/[slug]/+page.server.ts @@ -1,7 +1,21 @@ export async function load( { params }: { params: { slug: string }} ){ try { const post = await import(`../md/${params.slug}.md`) - const { title = '', date = '', header_bg_image = '', svg = '', video = '', tags = [], reference = '', referenceName = '', tasks = [], description = [], images = [], agency = '', agencyName = '' } = post.metadata + const { + title = '', + date = '', + header_bg_image = '', + svg = '', + video = '', + tags = [], + reference = '', + referenceName = '', + tasks = [], + description = [], + images = [], + agency = '', + agencyName = '' + } = post.metadata // Don't pass the component - it's not serializable // Import it directly in the page component instead diff --git a/src/routes/work/[slug]/+page.svelte b/src/routes/work/[slug]/+page.svelte index 6466b03..487e3fd 100644 --- a/src/routes/work/[slug]/+page.svelte +++ b/src/routes/work/[slug]/+page.svelte @@ -5,25 +5,9 @@ import { CldImage } from 'svelte-cloudinary'; let { data } = $props(); - let visible = $state(false); - let Content = $state(null); + gsap.registerPlugin(ScrollToPlugin); - // Import the markdown component dynamically and set up animations onMount(() => { - // Load the markdown component asynchronously - (async () => { - try { - const post = await import(`../md/${data.slug}.md`); - Content = post.default; - } catch (error) { - console.error('Error loading markdown component:', error); - } - })(); - - gsap.registerPlugin(ScrollToPlugin); - - visible = true; - let is_landscape = window.matchMedia('(orientation:landscape)').matches window.addEventListener('resize', () => { @@ -61,13 +45,13 @@ duration: .5, ease: 'power2.out', }) - gsap.from('.work', { - y: '100vh', + gsap.to('.work', { + y: '-100vh', duration: 1, ease: 'power4.out', }) - gsap.from('.gallery-wrapper', { - y: '-100vh', + gsap.to('.gallery-wrapper', { + y: '100vh', duration: 1, ease: 'power4.out', }) @@ -140,8 +124,7 @@
-{#if visible}
{data.description}
@@ -173,9 +154,9 @@
What I did:
    - {#each data.tags as tag } + {#each data.tags as tag (tag)}
  • {tag}
  • - { /each } + {/each}
@@ -190,12 +171,13 @@ {/if}
- {#if Content} + {#await import(`../md/${data.slug}.md`) then { default: Content }} - {/if} + {:catch error} +

Error loading content: {error.message}

+ {/await}
-{/if}