Skip to content

Commit f0d09ba

Browse files
authored
Merge pull request #80 from kleros/refactor/images-caching
refactor: images-loading
2 parents 14d328e + 50916bc commit f0d09ba

File tree

12 files changed

+115
-12
lines changed

12 files changed

+115
-12
lines changed

frontend/next.config.mjs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
const nextConfig = {
33
reactStrictMode: true,
44
images: {
5+
minimumCacheTTL: 31536000,
6+
deviceSizes: [640, 750, 828, 1080, 1200, 1920],
57
remotePatterns: [
68
{
79
protocol: "https",
8-
hostname: "delicate-eggs-595f0e58b8.media.strapiapp.com"
9-
}
10-
]
11-
}
10+
hostname: "delicate-eggs-595f0e58b8.media.strapiapp.com",
11+
},
12+
],
13+
},
1214
};
1315

1416
export default nextConfig;

frontend/src/app/for-lawyers/components/Hero.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const Hero: React.FC = async () => {
4040
src={background.url}
4141
alt="Hero Image Background"
4242
fill
43-
priority
43+
unoptimized
4444
className="absolute left-0 top-0 z-[-1] h-full object-cover"
4545
/>
4646
</div>

frontend/src/app/layout.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import Footer from "@/components/Footer";
77
import Navbar from "@/components/Navbar";
88
import { navbarQuery, NavbarQueryType } from "@/queries/navbar";
99
import "@/styles/globals.css";
10+
import { getHeroImgsProps } from "@/utils/getHeroImgsProps";
1011
import { request } from "@/utils/graphQLClient";
12+
import { HeroImagesQueryType, herosImagesQuery } from "@/queries/heroImages";
1113

1214
const urbanist = Urbanist({
1315
weight: ["400", "500"],
@@ -20,9 +22,23 @@ export default async function RootLayout({
2022
children: React.ReactNode;
2123
}) {
2224
const navbarData = await request<NavbarQueryType>(navbarQuery);
25+
const herosImgs = await request<HeroImagesQueryType>(herosImagesQuery);
26+
const props = getHeroImgsProps(herosImgs);
2327

2428
return (
2529
<html lang="en">
30+
<head>
31+
{props.map((prop) => (
32+
<link
33+
key={prop.props.alt}
34+
rel="preload"
35+
as="image"
36+
imageSizes="100vw"
37+
imageSrcSet={prop.props.srcSet}
38+
href={prop.props.src}
39+
></link>
40+
))}
41+
</head>
2642
<body className="min-w-80 bg-background-1 antialiased">
2743
<main className={clsx(urbanist.className)}>
2844
<Navbar {...{ navbarData }} />

frontend/src/components/BrandAssets/Hero.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const Hero: React.FC<IHero> = ({ heroData }) => {
3131
src={heroData.background.url}
3232
alt="Hero Image Background"
3333
fill
34-
priority
34+
unoptimized
3535
className="absolute left-0 top-0 z-[-1] h-full object-cover"
3636
/>
3737
</div>

frontend/src/components/Community/hero.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const Hero: React.FC<IHero> = ({ heroData }) => {
3434
src={background.url}
3535
alt="Hero Image Background"
3636
fill
37-
priority
37+
unoptimized
3838
className="absolute left-0 top-0 z-[-1] h-full object-cover"
3939
/>
4040
</div>

frontend/src/components/Cooperative/hero.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const Hero: React.FC<IHero> = ({ heroData }) => {
4242
src={background.url}
4343
alt="Hero Image Background"
4444
fill
45-
priority
45+
unoptimized
4646
className="absolute left-0 top-0 z-[-1] h-full object-cover"
4747
/>
4848
</div>

frontend/src/components/Earn/Hero.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const Hero: React.FC<IHero> = ({ heroData }) => {
4949
src={background.url}
5050
alt="Hero Image Background"
5151
fill
52-
priority
52+
unoptimized
5353
className="absolute left-0 top-0 z-[-1] h-full object-cover"
5454
/>
5555
</div>

frontend/src/components/ForBuilders/Hero.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const Hero: React.FC<IHero> = ({ heroData }) => {
4646
src={heroData.background.url}
4747
alt="Hero Image Background"
4848
fill
49-
priority
49+
unoptimized
5050
className="absolute left-0 top-0 z-[-1] h-full object-cover"
5151
/>
5252
</div>

frontend/src/components/PNKToken/Hero.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const Hero: React.FC<IHero> = ({ heroData }) => {
3535
src={background.url}
3636
alt="Hero Image Background"
3737
fill
38-
priority
38+
unoptimized
3939
className="absolute left-0 top-0 z-[-1] h-full object-cover"
4040
/>
4141
</div>

frontend/src/components/ResearchDevelopment/Hero.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const Hero: React.FC<IHero> = ({ heroData }) => {
4848
src={background.url}
4949
alt="Hero Image Background"
5050
fill
51-
priority
51+
unoptimized
5252
className="absolute left-0 top-0 z-[-1] h-full object-cover"
5353
/>
5454
</div>

0 commit comments

Comments
 (0)