Ensure product images conditional rendering in astro file
Updated 'src/pages/products/[...slug].astro' to conditionally render product images only when they exist. Prevents potential errors or breaks in layout when there is an absence of either 'first' or 'second' blueprint images for a particular product.
This commit is contained in:
parent
502aee8b33
commit
c14e7fbdb3
1 changed files with 16 additions and 12 deletions
|
@ -168,21 +168,25 @@ const { product } = Astro.props;
|
||||||
<div
|
<div
|
||||||
class="relative left-12 top-12 z-10 -ml-12 overflow-hidden rounded-xl shadow-lg md:left-12 md:top-16 lg:ml-0"
|
class="relative left-12 top-12 z-10 -ml-12 overflow-hidden rounded-xl shadow-lg md:left-12 md:top-16 lg:ml-0"
|
||||||
>
|
>
|
||||||
<Image
|
{product.data.blueprints.first &&
|
||||||
src={product.data.blueprints.first}
|
<Image
|
||||||
class="h-full w-full object-cover object-center"
|
src={product.data.blueprints.first}
|
||||||
alt="Blueprint Illustration"
|
class="h-full w-full object-cover object-center"
|
||||||
format={"avif"}
|
alt="Blueprint Illustration"
|
||||||
/>
|
format={"avif"}
|
||||||
|
/>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="relative right-12 overflow-hidden rounded-xl shadow-xl">
|
<div class="relative right-12 overflow-hidden rounded-xl shadow-xl">
|
||||||
<Image
|
{product.data.blueprints.second &&
|
||||||
src={product.data.blueprints.second}
|
<Image
|
||||||
class="h-full w-full object-cover object-center"
|
src={product.data.blueprints.second}
|
||||||
alt="Blueprint Illustration"
|
class="h-full w-full object-cover object-center"
|
||||||
format={"avif"}
|
alt="Blueprint Illustration"
|
||||||
/>
|
format={"avif"}
|
||||||
|
/>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue