Skip to content

Commit 63f71e7

Browse files
committed
Squashed commit of the following:
commit 909cf88f534accf25fa210cad288912538faf526 Author: Alex <alex@codingcat.dev> Date: Tue Feb 21 12:41:19 2023 -0500 update next-image-experimental
1 parent 19652a6 commit 63f71e7

15 files changed

Lines changed: 52 additions & 22 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const normalizeSrc = (src) => (src[0] === '/' ? src.slice(1) : src);
2+
export default function cloudinaryLoader({ src, width, quality }) {
3+
const params = [
4+
'f_auto',
5+
'c_limit',
6+
'w_' + width,
7+
'q_' + (quality || 'auto'),
8+
];
9+
const paramsString = params.join(',') + '/';
10+
return (
11+
'https://media.codingcat.dev/image/upload/' +
12+
paramsString +
13+
normalizeSrc(src)
14+
);
15+
}

‎apps/codingcatdev/next.config.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ module.exports = withPWA(
1515
withBundleAnalyzer({
1616
reactStrictMode: true,
1717
images: {
18-
domains: ['s3.us-west-2.amazonaws.com', 'media.codingcat.dev'],
18+
domains: ['s3.us-west-2.amazonaws.com'],
19+
loader: 'custom',
20+
loaderFile: './cloudinary-loader.js',
1921
},
2022
async redirects() {
2123
return [

‎apps/codingcatdev/src/components/PostMedia.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ export default function PostMedia({
113113
</div>
114114
) : (
115115
<>
116-
{!noImage && post.coverPhoto?.secure_url ? (
116+
{!noImage && post.coverPhoto?.public_id ? (
117117
<Image
118-
src={post.coverPhoto?.secure_url}
118+
src={post.coverPhoto?.public_id}
119119
alt={post.title}
120120
width="480"
121121
height="270"

‎apps/codingcatdev/src/components/PostsCards.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ export default function PostsCards({ posts }: { posts: Post[] }): JSX.Element {
1818
href={`/${post._type}/${post.slug}`}
1919
className="self-start"
2020
>
21-
{post.coverPhoto?.secure_url && post._type === 'course' ? (
21+
{post.coverPhoto?.public_id && post._type === 'course' ? (
2222
<>
2323
<Image
24-
src={post.coverPhoto?.secure_url}
24+
src={post.coverPhoto?.public_id}
2525
alt={post.title}
2626
width="480"
2727
height="270"
@@ -33,10 +33,10 @@ export default function PostsCards({ posts }: { posts: Post[] }): JSX.Element {
3333
}}
3434
/>
3535
</>
36-
) : post.coverPhoto?.secure_url ? (
36+
) : post.coverPhoto?.public_id ? (
3737
<>
3838
<Image
39-
src={post.coverPhoto?.secure_url}
39+
src={post.coverPhoto?.public_id}
4040
alt={post.title}
4141
width="480"
4242
height="270"

‎apps/codingcatdev/src/components/ScheduleCards.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default function ScheduleCards({
2121
>
2222
<Link href={`/schedule/${post.slug}`}>
2323
<Image
24-
src={`${post?.coverPhoto?.secure_url}`}
24+
src={`${post?.coverPhoto?.public_id}`}
2525
alt={`CodingCat.dev Podcast hosted by Alex & Brittney with ${
2626
post?.guests && post?.guests?.length > 1
2727
? 'guests'

‎apps/codingcatdev/src/components/authors/AuthorCard.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ export default function AuthorCard({
77
}: {
88
author: Author;
99
}): JSX.Element {
10-
console.log(author);
1110
return (
1211
<>
1312
{author?.displayName && author?.photoURL ? (
1413
<Image
15-
src={author.photoURL.secure_url}
14+
src={author.photoURL.public_id}
1615
width="96"
1716
height="96"
1817
alt={author.displayName}
@@ -23,6 +22,8 @@ export default function AuthorCard({
2322
className="w-24 rounded-full"
2423
width="96"
2524
height="96"
25+
unoptimized={true}
26+
loader={() => '/static/images/avatar.png'}
2627
src="/static/images/avatar.png"
2728
alt="Avatar Image Placeholder"
2829
/>

‎apps/codingcatdev/src/components/notion-custom-blocks/RenderBlocks.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ const myMapper = {
3838
className={`${className || ''} object-contain `}
3939
src={getCloudinaryPublicId(media?.src)}
4040
alt={media?.alt || media?.name || ''}
41+
height="100%"
42+
width="100%"
4143
fill
4244
sizes="100vw"
4345
/>
@@ -47,6 +49,8 @@ const myMapper = {
4749
className={`${className || ''} object-contain `}
4850
src={media.src}
4951
alt={media?.alt || media?.name || ''}
52+
height="100%"
53+
width="100%"
5054
fill
5155
sizes="100vw"
5256
/>

‎apps/codingcatdev/src/components/user/AvatarMenu.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ export default function AvatarMenu({
8585
) : (
8686
<Image
8787
src="/static/images/avatar.png"
88+
loader={() => '/static/images/avatar.png'}
89+
unoptimized={true}
8890
width="40"
8991
height="40"
9092
alt="Avatar for user Profile"

‎apps/codingcatdev/src/components/user/AvatarProfile.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export default function AvatarProfile({
2222
{dbProfile && dbProfile?.photoURL ? (
2323
<Image
2424
src={dbProfile.photoURL}
25+
loader={() => dbProfile.photoURL || ''}
26+
unoptimized={true}
2527
width="40"
2628
height="40"
2729
alt={
@@ -32,6 +34,8 @@ export default function AvatarProfile({
3234
) : (
3335
<Image
3436
src={user.photoURL || ''}
37+
loader={() => user.photoURL || ''}
38+
unoptimized={true}
3539
width="40"
3640
height="40"
3741
alt={user.displayName ? user.displayName : 'A Good Description'}

‎apps/codingcatdev/src/components/user/UserMembership.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ export default function UserMembership({
5959
<div className="w-32 h-32 m-4">
6060
<Image
6161
src={user.photoURL}
62+
loader={() => user.photoURL || ''}
6263
height="500"
6364
width="500"
65+
unoptimized={true}
6466
alt={`${user.displayName} Photo`}
6567
sizes="100vw"
6668
style={{

0 commit comments

Comments
 (0)