Skip to content

Commit 69e30e8

Browse files
committed
Update placeholder components
* Remove `PlaceholderLocal` and `PlaceholderRemote` components * Add `BlurImg`, `RemoteBlurImg`, and `ShimmerImg` components
1 parent 544ba1f commit 69e30e8

5 files changed

Lines changed: 7 additions & 14 deletions

File tree

src/components/placeholder-local.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,7 @@ import { ImgProps } from '../types/img.type';
44
import Img from './img';
55

66
export default async function PlaceholderLocal({ src, ...props }: ImgProps) {
7-
let buffer: ArrayBuffer;
8-
9-
if (src.startsWith('http')) {
10-
const res = await fetch(src);
11-
buffer = await res.arrayBuffer();
12-
} else {
13-
buffer = await readFile('.' + src);
14-
}
15-
7+
let buffer: ArrayBuffer = await readFile('.' + src);
168
const { base64 } = await getPlaiceholder(Buffer.from(buffer));
179

1810
return (

src/components/placeholder-remote.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22

33
import { use } from 'react';
4-
import { getBase64 } from '../lib/getBase64';
4+
import { getBase64 } from '../lib/utils';
55
import { ImgProps } from '../types/img.type';
66
import Img from './img';
77

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22

33
import { use } from 'react';
4-
import { getBase64, toBase64 } from '../lib/getBase64';
4+
import { getBase64, toBase64 } from '../lib/utils';
55
import { ImgProps } from '../types/img.type';
66
import Img from './img';
77

File renamed without changes.

src/placeholder/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { default as PlaceholderLocal } from '../components/placeholder-local';
2-
import { default as PlaceholderRemote } from '../components/placeholder-remote';
1+
import { default as BlurImg } from '../components/placeholder-local';
2+
import { default as RemoteBlurImg } from '../components/placeholder-remote';
3+
import { default as ShimmerImg } from '../components/placeholder-shimmer';
34

4-
export { PlaceholderLocal, PlaceholderRemote };
5+
export { BlurImg, RemoteBlurImg, ShimmerImg };

0 commit comments

Comments
 (0)