Skip to content

Commit 18fef87

Browse files
committed
feat: images lazy loading
1 parent 4579d13 commit 18fef87

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

src/app/layout.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import type { Metadata } from "next";
22
import "./globals.css";
33
import Link from "next/link";
4+
import Image from "next/image";
45
import Navigation from "@/components/Navigation";
56
import TeamPhotos from "@/components/TeamPhotos";
67
import { getAllCategories } from "@/lib/markdown-posts";
8+
import BrandLogo from "@/assets/Brand.png";
79

810
export const metadata: Metadata = {
911
title: "Preferred.AI",
@@ -30,10 +32,11 @@ export default function RootLayout({
3032
<div className="flex items-center justify-between gap-4 py-6">
3133
<Link href="/" className="inline-block">
3234
<div className="flex items-center gap-3">
33-
<img
34-
src="/Brand.png"
35+
<Image
36+
src={BrandLogo}
3537
alt="Preferred.AI"
3638
className="h-16 w-auto"
39+
priority
3740
/>
3841
<p className="hidden text-sm italic text-gray-600 lg:block">
3942
Preferences and Recommendations from Data & AI

src/assets/Brand.png

18.4 KB
Loading

src/components/TeamPhotos.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"use client";
22

3+
import Image from "next/image";
4+
35
import { useState, useEffect } from "react";
46
import { TEAM_PHOTOS } from "@/data/teamPhotos";
57

@@ -40,9 +42,12 @@ export default function TeamPhotos() {
4042
isVisible ? "opacity-100" : "opacity-0"
4143
}`}
4244
>
43-
<img
45+
<Image
4446
src={TEAM_PHOTOS[currentIndex].url}
4547
alt={`${TEAM_PHOTOS[currentIndex].date} - ${TEAM_PHOTOS[currentIndex].location}`}
48+
width={0}
49+
height={0}
50+
sizes="100vw"
4651
className="h-auto w-full object-cover"
4752
/>
4853
</div>

src/lib/rehype-figure.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export default function rehypeFigure() {
3636
...node,
3737
properties: {
3838
...node.properties,
39+
loading: 'lazy',
3940
},
4041
},
4142
],

0 commit comments

Comments
 (0)