Newer
Older
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import React from "react";
import { StaticImage, IGatsbyImageData, GatsbyImage, getImage } from "gatsby-plugin-image";
interface Props {
image?: string | IGatsbyImageData;
classname?: string;
}
const Image = (props: Props) => {
const {
image,
classname = ""
} = props;
const imageClassname = `h-full w-full object-cover ${classname}`;
const imageNoAvailable = (
<StaticImage
src='../../images/no-image-available.jpg'
alt="no-image-available"
className={imageClassname}
/>
)
if (! image || typeof image == 'undefined') {
return (
<>
{imageNoAvailable}
</>
);
}
if (typeof image == 'string') {
return (
<>
<img
src={image}
alt={image}
className={imageClassname}
/>
</>
)
}
const img = getImage(image) ;
if (typeof img == 'undefined') {
return (
<>
{imageNoAvailable}
</>
)
}
return (
<>
<GatsbyImage image={img} alt="gatsby-image" className={imageClassname}/>
</>
)
};
export default Image;