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
+16 -2
View File
@@ -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();
});
}
update();
window.addEventListener('scroll', update, { passive: true });
window.addEventListener('resize', update);
window.addEventListener('scroll', schedule, { passive: true });
window.addEventListener('resize', schedule);
})();
</script>
</Layout>