Skip to content

Commit 8a17503

Browse files
⚡️ Use Cloudinary to optimize images
1 parent 76adb75 commit 8a17503

File tree

5 files changed

+145
-105
lines changed

5 files changed

+145
-105
lines changed

components/ContributorCard.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { env } from 'env.mjs';
2+
import { CldImage, getCldImageUrl } from 'next-cloudinary';
13
import { IoLogoGithub } from 'react-icons/io';
24

35
interface Contributor {
@@ -13,6 +15,15 @@ interface Props {
1315
}
1416

1517
export default function ContributorCard({ contributor }: Props) {
18+
const url = env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME
19+
? getCldImageUrl({
20+
src: contributor.avatar_url,
21+
deliveryType: 'fetch',
22+
width: 250,
23+
height: 250
24+
})
25+
: contributor.avatar_url;
26+
1627
return (
1728
<div className="text-center shadow-2xl card">
1829
<a
@@ -21,16 +32,15 @@ export default function ContributorCard({ contributor }: Props) {
2132
rel="noreferrer"
2233
>
2334
<figure className="px-10 pt-10">
24-
<img
25-
src={contributor.avatar_url}
26-
alt={contributor.name}
27-
className="rounded-xl"
28-
/>
35+
<img src={url} alt={contributor.name} className="rounded-xl" />
2936
</figure>
3037
</a>
3138
<div className="card-body items-center text-center">
3239
<h2 className="card-title text-neutral-100">{contributor.name}</h2>
33-
<a href={contributor.profile} className="link text-neutral-100 hover:text-[#dbe8d9]">
40+
<a
41+
href={contributor.profile}
42+
className="link text-neutral-100 hover:text-[#dbe8d9]"
43+
>
3444
{contributor.profile}
3545
</a>
3646
<div className="justify-center card-actions">

env.mjs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ export const env = createEnv({
55
server: {
66
GITHUB_TOKEN: z.string().optional()
77
},
8-
client: {},
9-
// If you're using Next.js < 13.4.4, you'll need to specify the runtimeEnv manually
8+
client: {
9+
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME: z.string().optional()
10+
},
1011
runtimeEnv: {
11-
GITHUB_TOKEN: process.env.GITHUB_TOKEN
12+
GITHUB_TOKEN: process.env.GITHUB_TOKEN,
13+
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME:
14+
process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME
1215
}
13-
// For Next.js >= 13.4.4, you only need to destructure client variables:
14-
// experimental__runtimeEnv: {
15-
// NEXT_PUBLIC_PUBLISHABLE_KEY: process.env.NEXT_PUBLIC_PUBLISHABLE_KEY,
16-
// }
1716
});

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"daisyui": "^3.7.7",
2121
"framer-motion": "^10.16.4",
2222
"next": "^13.5.3",
23+
"next-cloudinary": "^4.22.0",
2324
"next-seo": "^6.1.0",
2425
"nextjs-progressbar": "^0.0.16",
2526
"react": "18.2.0",

pnpm-lock.yaml

Lines changed: 122 additions & 86 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)