1
0
mirror of https://github.com/vercel/commerce.git synced 2025-06-13 03:11:22 +00:00
2023-09-16 16:48:34 -05:00

15 lines
449 B
JavaScript

import { getMenu } from 'commerce/shopify';
export const getTags = async ({ product }) => {
const typesMenu = await getMenu('types-nav');
const types = typesMenu?.map(item => /search\/(\w+)/.exec(item?.path)?.[1]);
const tags = product?.collections?.nodes
?.map(col => col?.title)
?.filter(col => types?.includes(col?.toLowerCase()));
return tags;
};
export const listTags = ({ tags }) => `(${tags.join(', ')})`;