replace manual -> work navigating via window with goto()
This commit is contained in:
parent
d49773134f
commit
e277b33bd8
5 changed files with 51 additions and 42 deletions
|
|
@ -6,12 +6,19 @@
|
||||||
import { beforeNavigate } from '$app/navigation';
|
import { beforeNavigate } from '$app/navigation';
|
||||||
import { browser } from '$app/environment';
|
import { browser } from '$app/environment';
|
||||||
import type { Snippet } from 'svelte';
|
import type { Snippet } from 'svelte';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
interface LayoutData {
|
interface LayoutData {
|
||||||
pathname: string;
|
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 showLoader = $state(false);
|
||||||
let timer: ReturnType<typeof setTimeout> | null = null;
|
let timer: ReturnType<typeof setTimeout> | null = null;
|
||||||
|
|
@ -81,7 +88,7 @@
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<meta property="og:type" content="website" />
|
<meta property="og:type" content="website" />
|
||||||
<meta property="og:url" content={`https://floter.design`+data.pathname} />
|
<meta property="og:url" content={`https://floter.design${page.url.pathname}`} />
|
||||||
<meta property="og:image" content="https://floter.design/ogimage.png">
|
<meta property="og:image" content="https://floter.design/ogimage.png">
|
||||||
<meta name="twitter:card" content="summary_large_image">
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
<meta name="description" content={page.data.description ? page.data.description : 'Simon Flöter is a designer and creative developer'} />
|
<meta name="description" content={page.data.description ? page.data.description : 'Simon Flöter is a designer and creative developer'} />
|
||||||
|
|
@ -89,11 +96,11 @@
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<Header />
|
<Header />
|
||||||
{#key data.pathname}
|
<!-- {#key data.pathname} -->
|
||||||
<div class="content">
|
<div class="content">
|
||||||
{#if showLoader}
|
{#if showLoader}
|
||||||
<Loader />
|
<Loader />
|
||||||
{/if}
|
{/if}
|
||||||
{@render children()}
|
{@render children()}
|
||||||
</div>
|
</div>
|
||||||
{/key}
|
<!-- {/key} -->
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
import { loading } from '$lib/utils/stores.js'
|
import { loading } from '$lib/utils/stores.js'
|
||||||
loading.set(true)
|
loading.set(true)
|
||||||
export const load = async ({ url }) => {
|
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)
|
loading.set(false)
|
||||||
return {
|
|
||||||
pathname
|
return {}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import gsap from 'gsap';
|
import gsap from 'gsap';
|
||||||
import { SplitText } from 'gsap/SplitText';
|
import { SplitText } from 'gsap/SplitText';
|
||||||
|
import { goto } from '$app/navigation';
|
||||||
let { data } = $props();
|
let { data } = $props();
|
||||||
|
|
||||||
const orderedPosts = $derived.by(() => (data.posts || []).sort((a, b) => {
|
const orderedPosts = $derived.by(() => (data.posts || []).sort((a, b) => {
|
||||||
|
|
@ -53,7 +54,8 @@
|
||||||
workclone.style.top = `0`;
|
workclone.style.top = `0`;
|
||||||
workclone.style.left = `0`;
|
workclone.style.left = `0`;
|
||||||
document.body.appendChild(workclone);
|
document.body.appendChild(workclone);
|
||||||
window.location.href = href || ''
|
// window.location.href = href || ''
|
||||||
|
goto(href || '');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
gsap.fromTo(split.chars, {
|
gsap.fromTo(split.chars, {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,21 @@
|
||||||
export async function load( { params }: { params: { slug: string }} ){
|
export async function load( { params }: { params: { slug: string }} ){
|
||||||
try {
|
try {
|
||||||
const post = await import(`../md/${params.slug}.md`)
|
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
|
// Don't pass the component - it's not serializable
|
||||||
// Import it directly in the page component instead
|
// Import it directly in the page component instead
|
||||||
|
|
|
||||||
|
|
@ -5,25 +5,9 @@
|
||||||
import { CldImage } from 'svelte-cloudinary';
|
import { CldImage } from 'svelte-cloudinary';
|
||||||
let { data } = $props();
|
let { data } = $props();
|
||||||
|
|
||||||
let visible = $state(false);
|
gsap.registerPlugin(ScrollToPlugin);
|
||||||
let Content = $state<any>(null);
|
|
||||||
|
|
||||||
// Import the markdown component dynamically and set up animations
|
|
||||||
onMount(() => {
|
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
|
let is_landscape = window.matchMedia('(orientation:landscape)').matches
|
||||||
|
|
||||||
window.addEventListener('resize', () => {
|
window.addEventListener('resize', () => {
|
||||||
|
|
@ -61,13 +45,13 @@
|
||||||
duration: .5,
|
duration: .5,
|
||||||
ease: 'power2.out',
|
ease: 'power2.out',
|
||||||
})
|
})
|
||||||
gsap.from('.work', {
|
gsap.to('.work', {
|
||||||
y: '100vh',
|
y: '-100vh',
|
||||||
duration: 1,
|
duration: 1,
|
||||||
ease: 'power4.out',
|
ease: 'power4.out',
|
||||||
})
|
})
|
||||||
gsap.from('.gallery-wrapper', {
|
gsap.to('.gallery-wrapper', {
|
||||||
y: '-100vh',
|
y: '100vh',
|
||||||
duration: 1,
|
duration: 1,
|
||||||
ease: 'power4.out',
|
ease: 'power4.out',
|
||||||
})
|
})
|
||||||
|
|
@ -140,8 +124,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="gallery-wrapper">
|
<div class="gallery-wrapper">
|
||||||
<div class="gallery">
|
<div class="gallery">
|
||||||
{#if visible}
|
{#each data.images as image (image)}
|
||||||
{#each data.images as image}
|
|
||||||
<figure>
|
<figure>
|
||||||
{#if image.includes('/video/')}
|
{#if image.includes('/video/')}
|
||||||
<video src={image} width="1400" height="840" autoplay muted loop></video>
|
<video src={image} width="1400" height="840" autoplay muted loop></video>
|
||||||
|
|
@ -159,11 +142,9 @@
|
||||||
{/if}
|
{/if}
|
||||||
</figure>
|
</figure>
|
||||||
{/each}
|
{/each}
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<article class="work">
|
<article class="work">
|
||||||
{#if visible}
|
|
||||||
<div class="description">
|
<div class="description">
|
||||||
{data.description}
|
{data.description}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -173,9 +154,9 @@
|
||||||
<div class="tasks">
|
<div class="tasks">
|
||||||
<div class="tasks-title">What I did:</div>
|
<div class="tasks-title">What I did:</div>
|
||||||
<ul>
|
<ul>
|
||||||
{#each data.tags as tag }
|
{#each data.tags as tag (tag)}
|
||||||
<li>{tag}</li>
|
<li>{tag}</li>
|
||||||
{ /each }
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="reference">
|
<div class="reference">
|
||||||
|
|
@ -190,12 +171,13 @@
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="work-content-text">
|
<div class="work-content-text">
|
||||||
{#if Content}
|
{#await import(`../md/${data.slug}.md`) then { default: Content }}
|
||||||
<Content />
|
<Content />
|
||||||
{/if}
|
{:catch error}
|
||||||
|
<p>Error loading content: {error.message}</p>
|
||||||
|
{/await}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
@ -237,6 +219,8 @@
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
.work {
|
.work {
|
||||||
|
position: relative;
|
||||||
|
top: 100vh;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
padding: 0 var(--spacing-outer) 100px var(--spacing-outer);
|
padding: 0 var(--spacing-outer) 100px var(--spacing-outer);
|
||||||
@media screen and (min-width: 768px) {
|
@media screen and (min-width: 768px) {
|
||||||
|
|
@ -324,6 +308,7 @@
|
||||||
}
|
}
|
||||||
.gallery-wrapper {
|
.gallery-wrapper {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
top: -100vh;
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
padding: 0 0 1em 0;
|
padding: 0 0 1em 0;
|
||||||
|
|
@ -333,7 +318,7 @@
|
||||||
|
|
||||||
@media screen and (min-width: 768px) {
|
@media screen and (min-width: 768px) {
|
||||||
margin-bottom: -80px;
|
margin-bottom: -80px;
|
||||||
top: -80px;
|
top: calc(-100vh - 80px);
|
||||||
padding: 2em 0 4em 0;
|
padding: 2em 0 4em 0;
|
||||||
margin-bottom: -120px;
|
margin-bottom: -120px;
|
||||||
perspective: 500px;
|
perspective: 500px;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue