forked from crowetic/commerce
Add product description html (#274)
This commit is contained in:
parent
d838f34c73
commit
0b715c2dd2
@ -136,7 +136,7 @@ const ProductView: FC<Props> = ({ product }) => {
|
|||||||
))}
|
))}
|
||||||
|
|
||||||
<div className="pb-14 break-words w-full max-w-xl">
|
<div className="pb-14 break-words w-full max-w-xl">
|
||||||
<Text html={product.description} />
|
<Text html={product.descriptionHtml || product.description} />
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<div>
|
<div>
|
||||||
|
@ -163,6 +163,7 @@ interface Entity {
|
|||||||
export interface Product extends Entity {
|
export interface Product extends Entity {
|
||||||
name: string
|
name: string
|
||||||
description: string
|
description: string
|
||||||
|
descriptionHtml?: string
|
||||||
slug?: string
|
slug?: string
|
||||||
path?: string
|
path?: string
|
||||||
images: ProductImage[]
|
images: ProductImage[]
|
||||||
|
@ -21,11 +21,10 @@ const getProduct = async (options: {
|
|||||||
const { data }: GraphQLFetcherResult = await config.fetch(getProductQuery, {
|
const { data }: GraphQLFetcherResult = await config.fetch(getProductQuery, {
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
|
const { productByHandle } = data
|
||||||
const { productByHandle: product } = data
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
product: product ? normalizeProduct(product) : null,
|
product: productByHandle ? normalizeProduct(productByHandle) : null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +83,7 @@ export function normalizeProduct(productNode: ShopifyProduct): Product {
|
|||||||
images,
|
images,
|
||||||
variants,
|
variants,
|
||||||
description,
|
description,
|
||||||
|
descriptionHtml,
|
||||||
handle,
|
handle,
|
||||||
priceRange,
|
priceRange,
|
||||||
options,
|
options,
|
||||||
@ -93,7 +94,6 @@ export function normalizeProduct(productNode: ShopifyProduct): Product {
|
|||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
vendor,
|
vendor,
|
||||||
description,
|
|
||||||
path: `/${handle}`,
|
path: `/${handle}`,
|
||||||
slug: handle?.replace(/^\/+|\/+$/g, ''),
|
slug: handle?.replace(/^\/+|\/+$/g, ''),
|
||||||
price: money(priceRange?.minVariantPrice),
|
price: money(priceRange?.minVariantPrice),
|
||||||
@ -104,6 +104,8 @@ export function normalizeProduct(productNode: ShopifyProduct): Product {
|
|||||||
.filter((o) => o.name !== 'Title') // By default Shopify adds a 'Title' name when there's only one option. We don't need it. https://community.shopify.com/c/Shopify-APIs-SDKs/Adding-new-product-variant-is-automatically-adding-quot-Default/td-p/358095
|
.filter((o) => o.name !== 'Title') // By default Shopify adds a 'Title' name when there's only one option. We don't need it. https://community.shopify.com/c/Shopify-APIs-SDKs/Adding-new-product-variant-is-automatically-adding-quot-Default/td-p/358095
|
||||||
.map((o) => normalizeProductOption(o))
|
.map((o) => normalizeProductOption(o))
|
||||||
: [],
|
: [],
|
||||||
|
...(description && { description }),
|
||||||
|
...(descriptionHtml && { descriptionHtml }),
|
||||||
...rest,
|
...rest,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ edges {
|
|||||||
title
|
title
|
||||||
vendor
|
vendor
|
||||||
handle
|
handle
|
||||||
description
|
|
||||||
priceRange {
|
priceRange {
|
||||||
minVariantPrice {
|
minVariantPrice {
|
||||||
amount
|
amount
|
||||||
|
Loading…
x
Reference in New Issue
Block a user