-
Notifications
You must be signed in to change notification settings - Fork 28.2k
/
Copy pathimage-external.tsx
36 lines (31 loc) · 1.06 KB
/
image-external.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import type { ImageConfigComplete, ImageLoaderProps } from './image-config'
import type { ImageProps, ImageLoader, StaticImageData } from './get-img-props'
import { getImgProps } from './get-img-props'
import { warnOnce } from './utils/warn-once'
import { Image } from '../../client/image-component'
// @ts-ignore - This is replaced by webpack alias
import defaultLoader from 'next/dist/shared/lib/image-loader'
const unstable_getImgProps = (imgProps: ImageProps) => {
warnOnce(
'Warning: unstable_getImgProps() is experimental and may change or be removed at any time. Use at your own risk.'
)
const { props } = getImgProps(imgProps, {
defaultLoader,
// This is replaced by webpack define plugin
imgConf: process.env.__NEXT_IMAGE_OPTS as any as ImageConfigComplete,
})
for (const [key, value] of Object.entries(props)) {
if (value === undefined) {
delete props[key as keyof typeof props]
}
}
return { props }
}
export default Image
export {
ImageProps,
ImageLoaderProps,
ImageLoader,
StaticImageData,
unstable_getImgProps,
}