backend opti
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user