|
|
|
@ -1,8 +1,14 @@ |
|
|
|
|
import React, { ImgHTMLAttributes } from "react"; |
|
|
|
|
|
|
|
|
|
import styles from "./Image.module.css"; |
|
|
|
|
|
|
|
|
|
export function Image(props: ImgHTMLAttributes<HTMLImageElement>) { |
|
|
|
|
const classes = props.className |
|
|
|
|
? [props.className, styles.image] |
|
|
|
|
: [styles.image]; |
|
|
|
|
|
|
|
|
|
if (props.src?.startsWith("http://") || props.src?.startsWith("https://")) { |
|
|
|
|
return <img {...props} />; |
|
|
|
|
return <img {...props} className={classes.join(" ")} />; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const { src: relativeSrc = "" } = props; |
|
|
|
@ -16,5 +22,5 @@ export function Image(props: ImgHTMLAttributes<HTMLImageElement>) { |
|
|
|
|
absoluteSrc += "/" + relativeSrc; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return <img {...props} src={absoluteSrc} />; |
|
|
|
|
return <img {...props} src={absoluteSrc} className={classes.join(" ")} />; |
|
|
|
|
} |
|
|
|
|