mirror of
https://github.com/vercel/commerce.git
synced 2025-07-24 10:41:23 +00:00
Tried to optimize product page
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
export const docQuery = `*[_type in ["home", "page", "category", "product"] && defined(slug.current)] {
|
||||
_type,
|
||||
"slug": slug.current,
|
||||
"locale": language
|
||||
}`;
|
||||
|
||||
export const imageFields = `
|
||||
alt,
|
||||
crop,
|
||||
hotspot,
|
||||
"url": asset->url,
|
||||
"width": asset->metadata.dimensions.width,
|
||||
"height": asset->metadata.dimensions.height,
|
||||
asset-> {
|
||||
...,
|
||||
_id,
|
||||
assetId,
|
||||
metadata,
|
||||
_type,
|
||||
_ref,
|
||||
_rev
|
||||
}
|
||||
`;
|
||||
|
||||
|
@@ -262,4 +262,4 @@ export type ShopifyProductsOperation = {
|
||||
reverse?: boolean;
|
||||
sortKey?: string;
|
||||
};
|
||||
};
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
import { Image } from './common'
|
||||
import { Image } from './types'
|
||||
|
||||
export interface ProductPrice {
|
||||
/**
|
||||
@@ -145,28 +145,4 @@ export interface Product {
|
||||
* The locale version of the product.
|
||||
*/
|
||||
locale?: string
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Product operations
|
||||
*/
|
||||
|
||||
export type GetAllProductPathsOperation = {
|
||||
data: { products: Pick<Product, 'path'>[] }
|
||||
variables: { first?: number }
|
||||
}
|
||||
|
||||
export type GetAllProductsOperation = {
|
||||
data: { products: Product[] }
|
||||
variables: {
|
||||
relevance?: 'featured' | 'best_selling' | 'newest'
|
||||
ids?: string[]
|
||||
first?: number
|
||||
}
|
||||
}
|
||||
|
||||
export type GetProductOperation = {
|
||||
data: { product?: Product }
|
||||
variables: { path: string; slug?: never } | { path?: never; slug: string }
|
||||
}
|
||||
}
|
18
lib/storm/types.ts
Normal file
18
lib/storm/types.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export type Image = {
|
||||
/**
|
||||
* The URL of the image.
|
||||
*/
|
||||
url: string
|
||||
/**
|
||||
* A word or phrase that describes the content of an image.
|
||||
*/
|
||||
alt: string
|
||||
/**
|
||||
* The image's width.
|
||||
*/
|
||||
width?: number
|
||||
/**
|
||||
* The image's height.
|
||||
*/
|
||||
height?: number
|
||||
};
|
@@ -1,36 +0,0 @@
|
||||
export interface Discount {
|
||||
/**
|
||||
* The value of the discount, can be an amount or percentage.
|
||||
*/
|
||||
value: number
|
||||
}
|
||||
|
||||
export interface Measurement {
|
||||
/**
|
||||
* The measurement's value.
|
||||
*/
|
||||
value: number
|
||||
/**
|
||||
* The measurement's unit, such as "KILOGRAMS", "GRAMS", "POUNDS" & "OOUNCES".
|
||||
*/
|
||||
unit: 'KILOGRAMS' | 'GRAMS' | 'POUNDS' | 'OUNCES'
|
||||
}
|
||||
|
||||
export interface Image {
|
||||
/**
|
||||
* The URL of the image.
|
||||
*/
|
||||
url: string
|
||||
/**
|
||||
* A word or phrase that describes the content of an image.
|
||||
*/
|
||||
alt?: string
|
||||
/**
|
||||
* The image's width.
|
||||
*/
|
||||
width?: number
|
||||
/**
|
||||
* The image's height.
|
||||
*/
|
||||
height?: number
|
||||
}
|
Reference in New Issue
Block a user