backend opti
This commit is contained in:
@@ -29,14 +29,11 @@ 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) {
|
|
||||||
fetchOptions.body = reqClone.body;
|
|
||||||
// @ts-ignore — required by Node fetch when body is a stream
|
// @ts-ignore — required by Node fetch when body is a stream
|
||||||
fetchOptions.duplex = 'half';
|
fetchOptions.duplex = 'half';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const response = await fetch(url.toString(), fetchOptions);
|
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}>
|
<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">
|
||||||
|
|||||||
@@ -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();
|
||||||
window.addEventListener('scroll', update, { passive: true });
|
});
|
||||||
window.addEventListener('resize', update);
|
}
|
||||||
|
update();
|
||||||
|
window.addEventListener('scroll', schedule, { passive: true });
|
||||||
|
window.addEventListener('resize', schedule);
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|||||||
Reference in New Issue
Block a user