Skip to content

Commit 8c086f7

Browse files
authored
Merge pull request #5 from PreferredAI/image-lazy-loading
2 parents 4579d13 + dda5a2d commit 8c086f7

File tree

5 files changed

+46
-3
lines changed

5 files changed

+46
-3
lines changed

.github/workflows/test-build.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Test Build
2+
3+
on:
4+
pull_request:
5+
branches: ["main"]
6+
7+
# Cancel in-progress runs for the same PR
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup pnpm
20+
uses: pnpm/action-setup@v4
21+
with:
22+
version: 9
23+
24+
- name: Setup Node
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: "20"
28+
cache: "pnpm"
29+
30+
- name: Install dependencies
31+
run: pnpm install --frozen-lockfile
32+
33+
- name: Build with Next.js
34+
run: pnpm build

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)