feat: add helpful links

Signed-off-by: Chloe <pinkcloudvnn@gmail.com>
This commit is contained in:
Chloe
2024-06-14 14:25:27 +07:00
parent 8f82f6299e
commit d38a20cbaf
5 changed files with 55 additions and 2 deletions

View File

@@ -173,6 +173,7 @@ const reshapeCollection = (collection: ShopifyCollection): Collection | undefine
return {
...collection,
helpfulLinks: parseMetaFieldValue<string[]>(collection.helpfulLinks),
path: `/search/${collection.handle}`
};
};
@@ -495,7 +496,8 @@ export async function getCollections(): Promise<Collection[]> {
description: 'All products'
},
path: '/search',
updatedAt: new Date().toISOString()
updatedAt: new Date().toISOString(),
helpfulLinks: null
},
// Filter out the `hidden` collections.
// Collections that start with `hidden-*` need to be hidden on the search page.

View File

@@ -9,6 +9,9 @@ const collectionFragment = /* GraphQL */ `
seo {
...seo
}
helpfulLinks: metafield(namespace: "custom", key: "helpful_links") {
value
}
updatedAt
}
${seoFragment}

View File

@@ -31,8 +31,9 @@ export type CartItem = {
coreCharge?: CartItem;
};
export type Collection = ShopifyCollection & {
export type Collection = Omit<ShopifyCollection, 'helpfulLinks'> & {
path: string;
helpfulLinks: string[] | null;
};
export type Image = {
@@ -186,6 +187,7 @@ export type ShopifyCollection = {
description: string;
seo: SEO;
updatedAt: string;
helpfulLinks: { value: string } | null;
};
export type ShopifyProduct = {