mirror of
https://github.com/vercel/commerce.git
synced 2025-06-18 13:11:23 +00:00
Avoid repeating placeholder image reference and move to a variable
This commit is contained in:
parent
da11c82b7b
commit
d23cbdb3c8
@ -32,6 +32,7 @@ const ProductCard: FC<Props> = ({
|
||||
imgLayout = 'responsive',
|
||||
}) => {
|
||||
const src = p.images.edges?.[0]?.node?.urlOriginal!
|
||||
const placeholderImg = '/product-img-placeholder.svg';
|
||||
const { price } = usePrice({
|
||||
amount: p.prices?.price?.value,
|
||||
baseAmount: p.prices?.retailPrice?.value,
|
||||
@ -58,7 +59,7 @@ const ProductCard: FC<Props> = ({
|
||||
layout={imgLayout}
|
||||
loading={imgLoading}
|
||||
priority={imgPriority}
|
||||
src={p.images.edges?.[0]?.node.urlOriginal! || '/product-img-placeholder.svg'}
|
||||
src={p.images.edges?.[0]?.node.urlOriginal! || placeholderImg}
|
||||
alt={p.images.edges?.[0]?.node.altText || 'Product Image'}
|
||||
/>
|
||||
</div>
|
||||
@ -81,7 +82,7 @@ const ProductCard: FC<Props> = ({
|
||||
<div className={s.imageContainer}>
|
||||
<Image
|
||||
quality="85"
|
||||
src={src || '/product-img-placeholder.svg'}
|
||||
src={src || placeholderImg}
|
||||
alt={p.name}
|
||||
className={s.productImage}
|
||||
width={imgWidth}
|
||||
|
Loading…
x
Reference in New Issue
Block a user