diff --git a/components/product/ProductCard.tsx b/components/product/ProductCard.tsx index 625e48ce..a4cccb5d 100644 --- a/components/product/ProductCard.tsx +++ b/components/product/ProductCard.tsx @@ -8,6 +8,7 @@ import { useVariantPossibilities } from "$store/sdk/useVariantPossiblities.ts"; import type { Product } from "apps/commerce/types.ts"; import { mapProductToAnalyticsItem } from "apps/commerce/utils/productToAnalyticsItem.ts"; import Image from "apps/website/components/Image.tsx"; +import { relative } from "$store/sdk/url.ts"; export interface Layout { basics?: { @@ -52,11 +53,6 @@ interface Props { platform?: Platform; } -const relative = (url: string) => { - const link = new URL(url); - return `${link.pathname}${link.search}`; -}; - const WIDTH = 200; const HEIGHT = 279; @@ -85,16 +81,24 @@ function ProductCard( !l?.basics?.contentAlignment || l?.basics?.contentAlignment == "Left" ? "left" : "center"; - const skuSelector = variants.map(([value, link]) => ( -
  • - - - -
  • - )); + const relativeUrl = relative(url); + const skuSelector = variants.map(([value, link]) => { + const relativeLink = relative(link); + return ( +
  • + + + +
  • + ); + }); const cta = ( {name} ))} diff --git a/sdk/url.ts b/sdk/url.ts new file mode 100644 index 00000000..1f8aba32 --- /dev/null +++ b/sdk/url.ts @@ -0,0 +1,5 @@ +export const relative = (link?: string | undefined) => { + const linkUrl = link ? new URL(link) : undefined; + const linkPath = linkUrl ? `${linkUrl.pathname}${linkUrl.search}` : undefined; + return linkPath; +};