Skip to content

Commit ccb7a29

Browse files
authored
Merge pull request #7147 from Fireentity/fix/6930-blog-lcp-request-discovery
Fix LCP request discovery by optimizing initial blog image loading
2 parents 87cbf46 + 0669d28 commit ccb7a29

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/components/Card/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Image from "../image";
66
import { CardWrapper } from "./Card.style";
77
import { useStyledDarkMode } from "../../theme/app/useStyledDarkMode";
88

9-
const Card = ({ frontmatter, fields }) => {
9+
const Card = ({ frontmatter, fields, loading = "lazy", fetchpriority = "auto" }) => {
1010

1111
const { isDark } = useStyledDarkMode();
1212

@@ -18,6 +18,8 @@ const Card = ({ frontmatter, fields }) => {
1818
{...((isDark && frontmatter.darkthumbnail && frontmatter.darkthumbnail.publicURL !== frontmatter.thumbnail.publicURL)
1919
? frontmatter.darkthumbnail : frontmatter.thumbnail)}
2020
imgStyle={{ objectFit: "contain" }}
21+
loading={loading}
22+
fetchpriority={fetchpriority}
2123
alt={frontmatter.title}
2224
/>
2325
</div>

src/sections/Blog/Blog-grid/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ const BlogGrid = ({
6161
</Col>
6262
)}
6363

64-
{searchedPosts.length > 0 && searchedPosts.map(({ id, frontmatter, fields }) => (
64+
{searchedPosts.length > 0 && searchedPosts.map(({ id, frontmatter, fields }, index) => (
6565
<Col key={id} $xs={12} $sm={6}>
66-
<Card frontmatter={frontmatter} fields={fields} />
66+
<Card frontmatter={frontmatter} fields={fields} loading={index === 0 ? "eager" : "lazy"} fetchpriority={index === 0 ? "high" : "auto"} />
6767
</Col>
6868
))}
6969
<Col>

src/sections/Blog/Blog-list/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ const BlogList = ({
7474
}}
7575
className="blog-lists">
7676
{searchedPosts.length > 0 &&
77-
searchedPosts?.map(({ id, frontmatter, fields }) => (
77+
searchedPosts?.map(({ id, frontmatter, fields }, index) => (
7878
<Col $xs={12} key={id}>
79-
<Card frontmatter={frontmatter} fields={fields} />
79+
<Card frontmatter={frontmatter} fields={fields} loading={index === 0 ? "eager" : "lazy"} fetchpriority={index === 0 ? "high" : "auto"} />
8080
</Col>
8181
))}
8282
<Col>

0 commit comments

Comments
 (0)