diff --git a/frontend/helpers/path-helpers.ts b/frontend/helpers/path-helpers.ts index 8ad98483..4ecffad4 100644 --- a/frontend/helpers/path-helpers.ts +++ b/frontend/helpers/path-helpers.ts @@ -19,12 +19,17 @@ type ProductListPathAttributes = Pick< ProductList, 'type' | 'handle' | 'deviceTitle' >; - -export function productListPath( - productList: ProductListPathAttributes, - itemType?: string, - variant?: string | undefined -): string { +type ProductListPathProps = { + productList: ProductListPathAttributes; + itemType?: string; + variant?: string | undefined; +}; + +export function productListPath({ + productList, + itemType, + variant, +}: ProductListPathProps): string { switch (productList.type) { case ProductListType.AllParts: { return '/Parts'; diff --git a/frontend/seo/product-list/hreflangs.ts b/frontend/seo/product-list/hreflangs.ts index 9ef87286..850a48d0 100644 --- a/frontend/seo/product-list/hreflangs.ts +++ b/frontend/seo/product-list/hreflangs.ts @@ -221,10 +221,10 @@ export function useHreflangs( productList: ProductList, itemType: string | null ): Hreflangs | null { - const path = productListPath(productList, itemType ?? undefined).replace( - /^\//, - '' - ); + const path = productListPath({ + productList, + itemType: itemType ?? undefined, + }).replace(/^\//, ''); const collection = pathToCollection[path] ?? null; return collection ? hreflangs[collection] : null; } diff --git a/frontend/templates/page/sections/BrowseSection.tsx b/frontend/templates/page/sections/BrowseSection.tsx index fa096385..1941f14c 100644 --- a/frontend/templates/page/sections/BrowseSection.tsx +++ b/frontend/templates/page/sections/BrowseSection.tsx @@ -157,7 +157,7 @@ function FeaturedCategories({ categories }: FeaturedCategoriesProps) { }} > diff --git a/frontend/templates/product-list/MetaTags.tsx b/frontend/templates/product-list/MetaTags.tsx index cf9d8ac8..bb8ac560 100644 --- a/frontend/templates/product-list/MetaTags.tsx +++ b/frontend/templates/product-list/MetaTags.tsx @@ -1,7 +1,6 @@ import { PRODUCT_LIST_PAGE_PARAM } from '@config/constants'; import { metaTitleWithSuffix } from '@helpers/metadata-helpers'; import { productListPath } from '@helpers/path-helpers'; -import { stylizeDeviceItemType } from '@helpers/product-list-helpers'; import { useAppContext } from '@ifixit/app'; import type { ProductList } from '@models/product-list'; import { noIndexExemptions, useHreflangs } from '@seo/product-list'; @@ -115,19 +114,14 @@ function useCanonicalUrl( ): string { const appContext = useAppContext(); const pagination = usePagination(); - - const page = pagination.currentRefinement + 1; - - const itemTypeHandle = itemType - ? `/${encodeURIComponent(stylizeDeviceItemType(itemType))}` - : ''; const variant = useVariant(); + const page = pagination.currentRefinement + 1; - return `${appContext.ifixitOrigin}${productListPath( + return `${appContext.ifixitOrigin}${productListPath({ productList, - undefined, - productList.indexVariantsInsteadOfDevice ? variant : undefined - )}${itemTypeHandle}${page > 1 ? `?${PRODUCT_LIST_PAGE_PARAM}=${page}` : ''}`; + itemType: itemType ?? undefined, + variant: productList.indexVariantsInsteadOfDevice ? variant : undefined, + })}${page > 1 ? `?${PRODUCT_LIST_PAGE_PARAM}=${page}` : ''}`; } function useShouldNoIndex( diff --git a/frontend/templates/product-list/hooks/useProductListBreadcrumbs.ts b/frontend/templates/product-list/hooks/useProductListBreadcrumbs.ts index d54c6bd9..db972ebb 100644 --- a/frontend/templates/product-list/hooks/useProductListBreadcrumbs.ts +++ b/frontend/templates/product-list/hooks/useProductListBreadcrumbs.ts @@ -16,7 +16,7 @@ export function useProductListBreadcrumbs( productList.ancestors.forEach((ancestor) => { breadcrumbs.push({ label: ancestor.title, - url: productListPath(ancestor), + url: productListPath({ productList: ancestor }), }); }); @@ -27,7 +27,7 @@ export function useProductListBreadcrumbs( if (productList.type === ProductListType.DeviceParts && itemType) { breadcrumbs.push({ label: productList.title, - url: productListPath(productList), + url: productListPath({ productList }), }); breadcrumbs.push({ label: itemType, diff --git a/frontend/templates/product-list/sections/FeaturedProductListsSection.tsx b/frontend/templates/product-list/sections/FeaturedProductListsSection.tsx index 5a2b3482..42217f30 100644 --- a/frontend/templates/product-list/sections/FeaturedProductListsSection.tsx +++ b/frontend/templates/product-list/sections/FeaturedProductListsSection.tsx @@ -88,7 +88,7 @@ const ProductListLink = ({ productList }: ProductListLinkProps) => { )} diff --git a/frontend/templates/product-list/sections/FilterableProductsSection/index.tsx b/frontend/templates/product-list/sections/FilterableProductsSection/index.tsx index eb301d18..453817d4 100644 --- a/frontend/templates/product-list/sections/FilterableProductsSection/index.tsx +++ b/frontend/templates/product-list/sections/FilterableProductsSection/index.tsx @@ -349,7 +349,7 @@ const ProductListEmptyState = forwardRef( This collection does not have products. {parentCategory && ( - + Return to {parentCategory.title} )} diff --git a/frontend/templates/product-list/sections/ProductListChildrenSection.tsx b/frontend/templates/product-list/sections/ProductListChildrenSection.tsx index 01abdde3..3f535c52 100644 --- a/frontend/templates/product-list/sections/ProductListChildrenSection.tsx +++ b/frontend/templates/product-list/sections/ProductListChildrenSection.tsx @@ -68,9 +68,11 @@ export function ProductListChildrenSection({