@graphcommerce/magento-category 4.3.0 → 4.4.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`1f7ee6f6c`](https://github.com/graphcommerce-org/graphcommerce/commit/1f7ee6f6cfb28544439ed36e10929ac530d1b2b7), [`707dbc73d`](https://github.com/graphcommerce-org/graphcommerce/commit/707dbc73d181204d88fdbbd2e09340e25b2b5f7b)]:
8
+ - @graphcommerce/next-ui@4.21.0
9
+ - @graphcommerce/graphql@3.4.6
10
+ - @graphcommerce/framer-scroller@2.1.32
11
+ - @graphcommerce/magento-product@4.4.25
12
+ - @graphcommerce/magento-store@4.2.27
13
+ - @graphcommerce/image@3.1.8
14
+
15
+ ## 4.4.0
16
+
17
+ ### Minor Changes
18
+
19
+ - [#1591](https://github.com/graphcommerce-org/graphcommerce/pull/1591) [`eee08c956`](https://github.com/graphcommerce-org/graphcommerce/commit/eee08c956fbcc4fe8d915b6fa8b399dafca69acd) Thanks [@ErwinOtten](https://github.com/ErwinOtten)! - Remove need for rootCategory query
20
+
21
+ * [#1591](https://github.com/graphcommerce-org/graphcommerce/pull/1591) [`79f057889`](https://github.com/graphcommerce-org/graphcommerce/commit/79f057889847c61d75db7f567fd6575a57cf1022) Thanks [@ErwinOtten](https://github.com/ErwinOtten)! - Remove need for query rootCategory
22
+
23
+ ### Patch Changes
24
+
25
+ - [#1596](https://github.com/graphcommerce-org/graphcommerce/pull/1596) [`3a619b70d`](https://github.com/graphcommerce-org/graphcommerce/commit/3a619b70d082804b8de46a8e8232f9431479a8b7) Thanks [@paales](https://github.com/paales)! - Make sure the canonical of a page doesn’t contain a double forward slash
26
+
27
+ - Updated dependencies [[`43822fd61`](https://github.com/graphcommerce-org/graphcommerce/commit/43822fd61c949215b8ddce9fb37d09f29b638426), [`3a619b70d`](https://github.com/graphcommerce-org/graphcommerce/commit/3a619b70d082804b8de46a8e8232f9431479a8b7)]:
28
+ - @graphcommerce/next-ui@4.20.0
29
+ - @graphcommerce/framer-scroller@2.1.31
30
+ - @graphcommerce/magento-product@4.4.24
31
+ - @graphcommerce/magento-store@4.2.26
32
+
33
+ ## 4.3.1
34
+
35
+ ### Patch Changes
36
+
37
+ - [#1588](https://github.com/graphcommerce-org/graphcommerce/pull/1588) [`42030e04b`](https://github.com/graphcommerce-org/graphcommerce/commit/42030e04b2ebe004379c6f052e10407c2f5df18f) Thanks [@paales](https://github.com/paales)! - Make sure the canonical of a page doesn’t contain a double forward slash
38
+
39
+ - Updated dependencies [[`b6d3a3c13`](https://github.com/graphcommerce-org/graphcommerce/commit/b6d3a3c13ea63ef0f691f497507f07c0e094de5b)]:
40
+ - @graphcommerce/next-ui@4.19.0
41
+ - @graphcommerce/framer-scroller@2.1.30
42
+ - @graphcommerce/magento-product@4.4.23
43
+ - @graphcommerce/magento-store@4.2.25
44
+
3
45
  ## 4.3.0
4
46
 
5
47
  ### Minor Changes
@@ -12,13 +12,15 @@ export type CategoryMetaProps = CategoryMetaFragment &
12
12
 
13
13
  export function CategoryMeta(props: CategoryMetaProps) {
14
14
  const { meta_title, meta_description, name, params, current_page } = props
15
- const {
15
+ let {
16
16
  title = meta_title ?? name ?? '',
17
17
  metaDescription = meta_description ?? undefined,
18
18
  metaRobots,
19
- canonical = params?.url,
19
+ canonical,
20
20
  } = props
21
21
 
22
+ if (params?.url && !canonical) canonical = `/${params.url}`
23
+
22
24
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
23
25
  const anyFilterActive = Object.keys(params?.filters ?? {}).length > 0
24
26
  const currentPage = params?.currentPage ?? 1
@@ -42,7 +44,7 @@ export function CategoryMeta(props: CategoryMetaProps) {
42
44
  title={titleTrans}
43
45
  metaDescription={metaDescriptionTrans}
44
46
  metaRobots={anyFilterActive ? ['noindex'] : metaRobots}
45
- canonical={isPaginated ? `/${canonical}/q/page/${currentPage}` : canonical}
47
+ canonical={isPaginated ? `${canonical}/q/page/${currentPage}` : canonical}
46
48
  />
47
49
  )
48
50
  }
@@ -13,7 +13,7 @@ export function categoryToNav(props: Item | null | undefined): NavigationNode |
13
13
  if (!props) return undefined
14
14
  const { uid, children, include_in_menu, name, url_path } = props
15
15
 
16
- if (!uid || include_in_menu !== 1 || !url_path || !name) return undefined
16
+ if (!uid || include_in_menu !== 1 || !name) return undefined
17
17
 
18
18
  // If we've got children we make a button that navigates to childitems.
19
19
  if (children && children.length > 0) {
@@ -21,7 +21,15 @@ export function categoryToNav(props: Item | null | undefined): NavigationNode |
21
21
  name,
22
22
  id: uid,
23
23
  childItems: [
24
- { name: i18n._(/* i18n */ 'All {name}', { name }), href: `/${url_path}`, id: `${uid}-all` },
24
+ ...(url_path
25
+ ? [
26
+ {
27
+ name: i18n._(/* i18n */ 'All {name}', { name }),
28
+ href: `/${url_path}`,
29
+ id: `${uid}-all`,
30
+ },
31
+ ]
32
+ : []),
25
33
  ...children.map(categoryToNav).filter(nonNullable),
26
34
  ],
27
35
  } as NavigationNodeButton
@@ -35,6 +43,8 @@ export function categoryToNav(props: Item | null | undefined): NavigationNode |
35
43
  * Converts the Magento GraphQL category tree to a NavigationNode tree, which can be used in the
36
44
  * Navigation component.
37
45
  */
38
- export function useMagentoMenuToNavigation(menu: MenuQueryFragment['menu']) {
39
- return (menu?.items ?? []).map(categoryToNav).filter(nonNullable)
46
+ export function useMagentoMenuToNavigation(menu: MenuQueryFragment['menu'], includeRoot: boolean) {
47
+ return ((includeRoot ? menu?.items : menu?.items?.[0]?.children) || [])
48
+ .map(categoryToNav)
49
+ .filter(nonNullable)
40
50
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/magento-category",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "4.3.0",
5
+ "version": "4.4.1",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -12,19 +12,19 @@
12
12
  }
13
13
  },
14
14
  "devDependencies": {
15
- "@graphcommerce/eslint-config-pwa": "^4.1.9",
15
+ "@graphcommerce/eslint-config-pwa": "^4.1.10",
16
16
  "@graphcommerce/prettier-config-pwa": "^4.0.6",
17
17
  "@graphcommerce/typescript-config-pwa": "^4.0.4",
18
18
  "@playwright/test": "^1.21.1",
19
19
  "type-fest": "^2.12.2"
20
20
  },
21
21
  "dependencies": {
22
- "@graphcommerce/framer-scroller": "2.1.29",
23
- "@graphcommerce/graphql": "3.4.5",
24
- "@graphcommerce/image": "3.1.7",
25
- "@graphcommerce/magento-product": "4.4.22",
26
- "@graphcommerce/magento-store": "4.2.24",
27
- "@graphcommerce/next-ui": "4.18.0"
22
+ "@graphcommerce/framer-scroller": "2.1.32",
23
+ "@graphcommerce/graphql": "3.4.6",
24
+ "@graphcommerce/image": "3.1.8",
25
+ "@graphcommerce/magento-product": "4.4.25",
26
+ "@graphcommerce/magento-store": "4.2.27",
27
+ "@graphcommerce/next-ui": "4.21.0"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@lingui/react": "^3.13.2",
@@ -1,5 +1,5 @@
1
- query GetCategoryStaticPaths($rootCategory: String!) {
2
- categories(filters: { parent_category_uid: { eq: $rootCategory } }) {
1
+ query GetCategoryStaticPaths {
2
+ categories {
3
3
  items {
4
4
  uid
5
5
  url_path
@@ -12,6 +12,14 @@ query GetCategoryStaticPaths($rootCategory: String!) {
12
12
  children {
13
13
  uid
14
14
  url_path
15
+ children {
16
+ uid
17
+ url_path
18
+ children {
19
+ uid
20
+ url_path
21
+ }
22
+ }
15
23
  }
16
24
  }
17
25
  }
@@ -1,6 +1,7 @@
1
1
  fragment MenuQueryFragment on Query {
2
- menu: categories(filters: { parent_category_uid: { eq: $rootCategory } }) {
2
+ menu: categories {
3
3
  items {
4
+ uid
4
5
  ...NavigationItem
5
6
  children {
6
7
  uid
@@ -8,6 +9,10 @@ fragment MenuQueryFragment on Query {
8
9
  children {
9
10
  uid
10
11
  ...NavigationItem
12
+ children {
13
+ uid
14
+ ...NavigationItem
15
+ }
11
16
  }
12
17
  }
13
18
  }
@@ -12,12 +12,8 @@ const getCategoryStaticPaths = async (
12
12
  client: ApolloClient<NormalizedCacheObject>,
13
13
  locale: string,
14
14
  ) => {
15
- const rootCategory =
16
- (await client.query({ query: StoreConfigDocument })).data.storeConfig?.root_category_uid ?? ''
17
-
18
15
  const { data } = await client.query({
19
16
  query: GetCategoryStaticPathsDocument,
20
- variables: { rootCategory },
21
17
  })
22
18
 
23
19
  const paths: StaticPathsResult['paths'] = []