mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 20:26:49 +00:00
slug
This commit is contained in:
@@ -13,16 +13,25 @@ export function normalizeProduct(productNode: BCProduct): Product {
|
||||
|
||||
return {
|
||||
path,
|
||||
slug: path?.slice(1, -1),
|
||||
images: images?.edges?.map(
|
||||
({ node: { urlOriginal, altText, ...rest } }: any) => ({
|
||||
url: urlOriginal,
|
||||
alt: altText,
|
||||
...rest,
|
||||
})
|
||||
),
|
||||
variants: variants?.edges?.map(({ node }: any) => node),
|
||||
productOptions: productOptions?.edges?.map(({ node }: any) => node),
|
||||
slug: path?.replace(/^\/+|\/+$/g, ''),
|
||||
images: images.edges
|
||||
? images.edges.map(
|
||||
({ node: { urlOriginal, altText, ...rest } }: any) => ({
|
||||
url: urlOriginal,
|
||||
alt: altText,
|
||||
...rest,
|
||||
})
|
||||
)
|
||||
: [],
|
||||
variants: variants.edges
|
||||
? variants.edges.map(({ node: { entityId, ...rest } }: any) => ({
|
||||
id: entityId,
|
||||
...rest,
|
||||
}))
|
||||
: [],
|
||||
productOptions: productOptions.edges
|
||||
? productOptions.edges.map(({ node }: any) => node)
|
||||
: [],
|
||||
price: {
|
||||
value: prices?.price.value,
|
||||
currencyCode: prices?.price.currencyCode,
|
||||
|
4
framework/types.d.ts
vendored
4
framework/types.d.ts
vendored
@@ -8,8 +8,8 @@ interface Product extends Entity {
|
||||
description: string
|
||||
slug: string
|
||||
path?: string
|
||||
images: ProductImage[] | any[] | undefined
|
||||
variants: ProductVariant[] | any[] | null | undefined
|
||||
images: ProductImage[]
|
||||
variants: ProductVariant[]
|
||||
price: ProductPrice
|
||||
}
|
||||
interface ProductImage {
|
||||
|
Reference in New Issue
Block a user