Makes Reveal, deferred images and the first row work from the HTML
Reveal content is visible in the HTML and only content below the viewport hides after hydration. Deferred photos get a noscript twin, and the first row of the portfolio loads eagerly per column count. Some old tests still expect the former behaviour; they are rewritten next, so this commit's test run is not fully green. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -35,16 +35,37 @@ export default function DeferredImage({
|
||||
});
|
||||
const load = pageLoaded && (near ?? inView);
|
||||
|
||||
// The twin is for visitors without JavaScript: the parser reads noscript
|
||||
// content as text when scripting is on, so it is never fetched, and React
|
||||
// ignores it when hydrating. It has the same style props, so the same
|
||||
// class and box, and leaves out what must stay unique.
|
||||
const twinProps: Record<string, unknown> = { ...rest };
|
||||
delete twinProps.id;
|
||||
delete twinProps['data-testid'];
|
||||
|
||||
return (
|
||||
<Image
|
||||
ref={ref}
|
||||
src={load ? image.src : undefined}
|
||||
alt={image.alt}
|
||||
htmlWidth={image.width}
|
||||
htmlHeight={image.height}
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
{...rest}
|
||||
/>
|
||||
<>
|
||||
<Image
|
||||
ref={ref}
|
||||
src={load ? image.src : undefined}
|
||||
alt={image.alt}
|
||||
htmlWidth={image.width}
|
||||
htmlHeight={image.height}
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
data-deferred
|
||||
{...rest}
|
||||
/>
|
||||
<noscript>
|
||||
<Image
|
||||
src={image.src}
|
||||
alt={image.alt}
|
||||
htmlWidth={image.width}
|
||||
htmlHeight={image.height}
|
||||
decoding="async"
|
||||
{...twinProps}
|
||||
/>
|
||||
</noscript>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user