Tried to optimize product page

This commit is contained in:
Henrik Larsson
2023-08-11 10:19:55 +02:00
parent a7efbf8fc3
commit 767245672c
18 changed files with 190 additions and 263 deletions

View File

@@ -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
}
`;

View File

@@ -262,4 +262,4 @@ export type ShopifyProductsOperation = {
reverse?: boolean;
sortKey?: string;
};
};
};

View File

@@ -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
View 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
};

View File

@@ -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
}