@graphcommerce/magento-product 4.6.1 → 4.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Api/ProductPageItem.graphql +1 -0
- package/CHANGELOG.md +6 -0
- package/components/ProductPageBreadcrumb/ProductPageBreadcrumb.graphql +14 -0
- package/components/ProductPageBreadcrumb/ProductPageBreadcrumb.tsx +42 -0
- package/components/ProductPageBreadcrumb/index.ts +2 -0
- package/components/ProductPageCategory/productPageCategory.ts +3 -1
- package/components/index.ts +2 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1659](https://github.com/graphcommerce-org/graphcommerce/pull/1659) [`6987ec7d2`](https://github.com/graphcommerce-org/graphcommerce/commit/6987ec7d21ce2d481fabbd6eda039702fcf5242b) Thanks [@Jessevdpoel](https://github.com/Jessevdpoel)! - Added product and category breadcrumbs
|
|
8
|
+
|
|
3
9
|
## 4.6.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { usePrevPageRouter } from '@graphcommerce/framer-next-pages'
|
|
2
|
+
import { Trans } from '@lingui/react'
|
|
3
|
+
import { Breadcrumbs, BreadcrumbsProps, Container, Link, Typography } from '@mui/material'
|
|
4
|
+
import PageLink from 'next/link'
|
|
5
|
+
import { productPageCategory } from '../ProductPageCategory/productPageCategory'
|
|
6
|
+
import { ProductPageBreadcrumbFragment } from './ProductPageBreadcrumb.gql'
|
|
7
|
+
|
|
8
|
+
type ProductPageBreadcrumbsProps = ProductPageBreadcrumbFragment & BreadcrumbsProps
|
|
9
|
+
|
|
10
|
+
export function ProductPageBreadcrumb(props: ProductPageBreadcrumbsProps) {
|
|
11
|
+
const { categories, name } = props
|
|
12
|
+
const prev = usePrevPageRouter()
|
|
13
|
+
|
|
14
|
+
const category =
|
|
15
|
+
categories?.find((c) => `/${c?.url_path}` === prev?.asPath) ?? productPageCategory(props)
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<Container maxWidth={false}>
|
|
19
|
+
<Breadcrumbs>
|
|
20
|
+
<PageLink href='/' passHref>
|
|
21
|
+
<Link underline='hover' color='inherit'>
|
|
22
|
+
<Trans id='Home' />
|
|
23
|
+
</Link>
|
|
24
|
+
</PageLink>
|
|
25
|
+
{category?.breadcrumbs?.map((mapped_category, i) => (
|
|
26
|
+
<Link
|
|
27
|
+
underline='hover'
|
|
28
|
+
key={mapped_category?.category_uid}
|
|
29
|
+
color='inherit'
|
|
30
|
+
href={`/${mapped_category?.category_url_path}`}
|
|
31
|
+
>
|
|
32
|
+
{mapped_category?.category_name}
|
|
33
|
+
</Link>
|
|
34
|
+
))}
|
|
35
|
+
<Link underline='hover' color='inherit' href={`/${category?.url_path}`}>
|
|
36
|
+
{category?.name}
|
|
37
|
+
</Link>
|
|
38
|
+
<Typography color='text.primary'>{name}</Typography>
|
|
39
|
+
</Breadcrumbs>
|
|
40
|
+
</Container>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
@@ -6,7 +6,9 @@ import { ProductPageCategoryFragment } from './ProductPageCategory.gql'
|
|
|
6
6
|
* - Prefers categories that are included in the menu
|
|
7
7
|
* - Prefers categories that have a longer path than shorter ones.
|
|
8
8
|
*/
|
|
9
|
-
export function productPageCategory
|
|
9
|
+
export function productPageCategory<Product extends ProductPageCategoryFragment>(
|
|
10
|
+
product?: Product | null,
|
|
11
|
+
): NonNullable<Product['categories']>[number] | undefined {
|
|
10
12
|
if (!product?.categories?.length) return undefined
|
|
11
13
|
return product?.categories?.reduce((carry, value) => {
|
|
12
14
|
if (!value?.include_in_menu) return carry
|
package/components/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './AddProductsToCart'
|
|
2
2
|
export * from './JsonLdProduct/jsonLdProduct'
|
|
3
3
|
export * from './ProductAddToCart'
|
|
4
|
+
export * from './ProductCustomizable'
|
|
4
5
|
export * from './ProductList/ProductList.gql'
|
|
5
6
|
export * from './ProductListCount/ProductListCount'
|
|
6
7
|
export * from './ProductListFilters/ProductFilters.gql'
|
|
@@ -18,6 +19,7 @@ export * from './ProductListItems/renderer'
|
|
|
18
19
|
export * from './ProductListLink/ProductListLink'
|
|
19
20
|
export * from './ProductListPagination/ProductListPagination'
|
|
20
21
|
export * from './ProductListSort/ProductListSort'
|
|
22
|
+
export * from './ProductPageBreadcrumb'
|
|
21
23
|
export * from './ProductPageCategory/productPageCategory'
|
|
22
24
|
export * from './ProductPageDescription/ProductPageDescription'
|
|
23
25
|
export * from './ProductPageGallery/ProductPageGallery'
|
|
@@ -31,4 +33,3 @@ export * from './ProductSpecs/ProductSpecs'
|
|
|
31
33
|
export * from './ProductStaticPaths/getProductStaticPaths'
|
|
32
34
|
export * from './ProductUpsells/UpsellProducts.gql'
|
|
33
35
|
export * from './ProductWeight/ProductWeight'
|
|
34
|
-
export * from './ProductCustomizable'
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/magento-product",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "4.
|
|
5
|
+
"version": "4.7.0",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@graphcommerce/ecommerce-ui": "1.5.1",
|
|
23
23
|
"@graphcommerce/framer-scroller": "2.1.39",
|
|
24
|
+
"@graphcommerce/framer-next-pages": "3.3.0",
|
|
24
25
|
"@graphcommerce/graphql": "3.4.8",
|
|
25
26
|
"@graphcommerce/graphql-mesh": "4.2.0",
|
|
26
27
|
"@graphcommerce/image": "3.1.9",
|