backend opti
This commit is contained in:
@@ -29,14 +29,11 @@ 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;
|
||||
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);
|
||||
|
||||
|
||||
@@ -58,6 +58,11 @@ const isAdmin = Astro.cookies.get('admin_session')?.value === '1';
|
||||
---
|
||||
|
||||
<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">
|
||||
<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">
|
||||
|
||||
@@ -71,6 +71,11 @@ const displayTitle = post ? (post.title || formatSlug(post.slug)) : 'Work';
|
||||
image={post?.cover_image?.url}
|
||||
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>
|
||||
|
||||
{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();
|
||||
window.addEventListener('scroll', update, { passive: true });
|
||||
window.addEventListener('resize', update);
|
||||
});
|
||||
}
|
||||
update();
|
||||
window.addEventListener('scroll', schedule, { passive: true });
|
||||
window.addEventListener('resize', schedule);
|
||||
})();
|
||||
</script>
|
||||
</Layout>
|
||||
|
||||
Reference in New Issue
Block a user