From 43a9c26497e16335a98838b80150077791e04fc6 Mon Sep 17 00:00:00 2001 From: Nils Pukropp Date: Thu, 14 May 2026 18:12:58 +0200 Subject: [PATCH] backend opti --- frontend/src/pages/api/[...path].ts | 11 ++++------- frontend/src/pages/index.astro | 5 +++++ frontend/src/pages/posts/[slug].astro | 18 ++++++++++++++++-- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/frontend/src/pages/api/[...path].ts b/frontend/src/pages/api/[...path].ts index b07a76f..7576c56 100644 --- a/frontend/src/pages/api/[...path].ts +++ b/frontend/src/pages/api/[...path].ts @@ -29,13 +29,10 @@ export const ALL: APIRoute = async ({ request, params }) => { headers, }; - if (request.method !== 'GET' && request.method !== 'HEAD') { - const reqClone = request.clone(); - if (request.method !== 'DELETE' || reqClone.body) { - fetchOptions.body = reqClone.body; - // @ts-ignore — required by Node fetch when body is a stream - fetchOptions.duplex = 'half'; - } + if (request.method !== 'GET' && request.method !== 'HEAD' && request.body) { + fetchOptions.body = request.body; + // @ts-ignore — required by Node fetch when body is a stream + fetchOptions.duplex = 'half'; } const response = await fetch(url.toString(), fetchOptions); diff --git a/frontend/src/pages/index.astro b/frontend/src/pages/index.astro index 0991fef..38873ce 100644 --- a/frontend/src/pages/index.astro +++ b/frontend/src/pages/index.astro @@ -58,6 +58,11 @@ const isAdmin = Astro.cookies.get('admin_session')?.value === '1'; --- + {posts[0]?.cover_image?.url && ( + + + + )}

diff --git a/frontend/src/pages/posts/[slug].astro b/frontend/src/pages/posts/[slug].astro index f5f0551..5395211 100644 --- a/frontend/src/pages/posts/[slug].astro +++ b/frontend/src/pages/posts/[slug].astro @@ -71,6 +71,11 @@ const displayTitle = post ? (post.title || formatSlug(post.slug)) : 'Work'; image={post?.cover_image?.url} type="article" > + {post?.cover_image?.url && ( + + + + )} {error && ( @@ -192,9 +197,18 @@ const displayTitle = post ? (post.title || formatSlug(post.slug)) : 'Work'; const pct = Math.max(0, Math.min(1, (window.scrollY - startY) / distance)); bar.style.transform = 'scaleX(' + pct + ')'; } + let pending = false; + function schedule() { + if (pending) return; + pending = true; + requestAnimationFrame(function () { + pending = false; + update(); + }); + } update(); - window.addEventListener('scroll', update, { passive: true }); - window.addEventListener('resize', update); + window.addEventListener('scroll', schedule, { passive: true }); + window.addEventListener('resize', schedule); })();