diff --git a/packages/api/src/platforms/vtex/resolvers/collection.ts b/packages/api/src/platforms/vtex/resolvers/collection.ts index f67a49f34a..efacbc8764 100644 --- a/packages/api/src/platforms/vtex/resolvers/collection.ts +++ b/packages/api/src/platforms/vtex/resolvers/collection.ts @@ -1,11 +1,14 @@ -import { isCollectionPageType } from '../loaders/collection' -import { slugify } from '../utils/slugify' import type { Resolver } from '..' import type { Brand } from '../clients/commerce/types/Brand' import type { CategoryTree } from '../clients/commerce/types/CategoryTree' import type { CollectionPageType } from '../clients/commerce/types/Portal' +import { isCollectionPageType } from '../loaders/collection' +import { slugify } from '../utils/slugify' -export type Root = Brand | (CategoryTree & { level: number }) | CollectionPageType +export type Root = + | Brand + | (CategoryTree & { level: number }) + | CollectionPageType const isBrand = (x: any): x is Brand | CollectionPageType => x.type === 'brand' || @@ -32,7 +35,7 @@ export const StoreCollection: Record> = { seo: (root) => isBrand(root) || isCollectionPageType(root) ? { - title: root.title, + title: root.title ?? root.name, description: root.metaTagDescription, } : { @@ -43,10 +46,10 @@ export const StoreCollection: Record> = { isBrand(root) ? 'Brand' : isCollectionPageType(root) - ? root.pageType - : root.level === 0 - ? 'Department' - : 'Category', + ? root.pageType + : root.level === 0 + ? 'Department' + : 'Category', meta: (root) => { const slug = slugifyRoot(root) @@ -55,15 +58,15 @@ export const StoreCollection: Record> = { selectedFacets: [{ key: 'brand', value: slug }], } : isCollection(root) - ? { - selectedFacets: [{ key: 'productclusterids', value: root.id }], - } - : { - selectedFacets: slug.split('/').map((segment, index) => ({ - key: `category-${index + 1}`, - value: segment, - })), - } + ? { + selectedFacets: [{ key: 'productclusterids', value: root.id }], + } + : { + selectedFacets: slug.split('/').map((segment, index) => ({ + key: `category-${index + 1}`, + value: segment, + })), + } }, breadcrumbList: async (root, _, ctx) => { const {