diff --git a/src/entities/project/ui/ProjectCard/ProjectCard.tsx b/src/entities/project/ui/ProjectCard/ProjectCard.tsx index 2af0474..f498486 100644 --- a/src/entities/project/ui/ProjectCard/ProjectCard.tsx +++ b/src/entities/project/ui/ProjectCard/ProjectCard.tsx @@ -26,6 +26,12 @@ type Props = { * Optional preview image URL */ imageUrl?: string; + /** + * Skip lazy-loading the preview image. Set true for above-the-fold cards + * (typically the first card in the list) to improve LCP. + * @default false + */ + priority?: boolean; }; /** @@ -33,7 +39,7 @@ type Props = { * Sidebar: year badge, stack tags, View Project button. * Main: title, optional image, description. */ -export function ProjectCard({ title, year, description, tags, url, imageUrl }: Props) { +export function ProjectCard({ title, year, description, tags, url, imageUrl, priority = false }: Props) { return ( )} - @@ -57,7 +63,9 @@ export function ProjectCard({ title, year, description, tags, url, imageUrl }: P >
{title} - {imageUrl && } + {imageUrl && ( + + )}
diff --git a/src/widgets/ProjectsSection/ui/ProjectsSection/ProjectsSection.tsx b/src/widgets/ProjectsSection/ui/ProjectsSection/ProjectsSection.tsx index f71d3e0..97da991 100644 --- a/src/widgets/ProjectsSection/ui/ProjectsSection/ProjectsSection.tsx +++ b/src/widgets/ProjectsSection/ui/ProjectsSection/ProjectsSection.tsx @@ -13,9 +13,14 @@ export default async function ProjectsSection() { tags: ['projects'], }); + /* Mark the first project that actually has an image as LCP-priority. + * Using `index === 0` alone misses the case where the first card has no + * image and the LCP candidate ends up being the next card's image. */ + const lcpIndex = items.findIndex((project) => project.image); + return (
- {items.map((project) => ( + {items.map((project, index) => ( ))}