backend opti

This commit is contained in:
2026-05-14 18:12:58 +02:00
parent 2ace527c9f
commit 43a9c26497
3 changed files with 25 additions and 9 deletions
+4 -7
View File
@@ -29,13 +29,10 @@ export const ALL: APIRoute = async ({ request, params }) => {
headers, headers,
}; };
if (request.method !== 'GET' && request.method !== 'HEAD') { if (request.method !== 'GET' && request.method !== 'HEAD' && request.body) {
const reqClone = request.clone(); fetchOptions.body = request.body;
if (request.method !== 'DELETE' || reqClone.body) { // @ts-ignore — required by Node fetch when body is a stream
fetchOptions.body = reqClone.body; fetchOptions.duplex = 'half';
// @ts-ignore — required by Node fetch when body is a stream
fetchOptions.duplex = 'half';
}
} }
const response = await fetch(url.toString(), fetchOptions); const response = await fetch(url.toString(), fetchOptions);
+5
View File
@@ -58,6 +58,11 @@ const isAdmin = Astro.cookies.get('admin_session')?.value === '1';
--- ---
<Layout title="Catalogue" description={siteConfig.welcome_subtitle}> <Layout title="Catalogue" description={siteConfig.welcome_subtitle}>
{posts[0]?.cover_image?.url && (
<Fragment slot="head">
<link rel="preload" as="image" href={posts[0].cover_image.url} fetchpriority="high" />
</Fragment>
)}
<section class="relative mb-16 md:mb-24"> <section class="relative mb-16 md:mb-24">
<div class="max-w-2xl"> <div class="max-w-2xl">
<h1 class="font-display italic font-semibold text-[var(--text)] text-5xl md:text-7xl lg:text-8xl leading-[0.95] tracking-tight mb-6"> <h1 class="font-display italic font-semibold text-[var(--text)] text-5xl md:text-7xl lg:text-8xl leading-[0.95] tracking-tight mb-6">
+16 -2
View File
@@ -71,6 +71,11 @@ const displayTitle = post ? (post.title || formatSlug(post.slug)) : 'Work';
image={post?.cover_image?.url} image={post?.cover_image?.url}
type="article" type="article"
> >
{post?.cover_image?.url && (
<Fragment slot="head">
<link rel="preload" as="image" href={post.cover_image.url} fetchpriority="high" />
</Fragment>
)}
<div id="reading-progress" class="reading-progress" aria-hidden="true"></div> <div id="reading-progress" class="reading-progress" aria-hidden="true"></div>
{error && ( {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)); const pct = Math.max(0, Math.min(1, (window.scrollY - startY) / distance));
bar.style.transform = 'scaleX(' + pct + ')'; bar.style.transform = 'scaleX(' + pct + ')';
} }
let pending = false;
function schedule() {
if (pending) return;
pending = true;
requestAnimationFrame(function () {
pending = false;
update();
});
}
update(); update();
window.addEventListener('scroll', update, { passive: true }); window.addEventListener('scroll', schedule, { passive: true });
window.addEventListener('resize', update); window.addEventListener('resize', schedule);
})(); })();
</script> </script>
</Layout> </Layout>