mirror of
https://github.com/vercel/commerce.git
synced 2025-06-18 05:01:22 +00:00
Avoid repeating placeholder image reference and move to a variable
This commit is contained in:
parent
4c03104f6a
commit
25129c699c
@ -31,6 +31,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,
|
||||
@ -57,7 +58,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>
|
||||
@ -80,7 +81,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.image}
|
||||
width={imgWidth}
|
||||
|
Loading…
x
Reference in New Issue
Block a user