@graphcommerce/magento-category 4.3.1 → 4.4.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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#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
8
+
9
+ * [#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
10
+
11
+ ### Patch Changes
12
+
13
+ - [#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
14
+
15
+ - Updated dependencies [[`43822fd61`](https://github.com/graphcommerce-org/graphcommerce/commit/43822fd61c949215b8ddce9fb37d09f29b638426), [`3a619b70d`](https://github.com/graphcommerce-org/graphcommerce/commit/3a619b70d082804b8de46a8e8232f9431479a8b7)]:
16
+ - @graphcommerce/next-ui@4.20.0
17
+ - @graphcommerce/framer-scroller@2.1.31
18
+ - @graphcommerce/magento-product@4.4.24
19
+ - @graphcommerce/magento-store@4.2.26
20
+
3
21
  ## 4.3.1
4
22
 
5
23
  ### Patch Changes
@@ -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.1",
5
+ "version": "4.4.0",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -19,12 +19,12 @@
19
19
  "type-fest": "^2.12.2"
20
20
  },
21
21
  "dependencies": {
22
- "@graphcommerce/framer-scroller": "2.1.30",
22
+ "@graphcommerce/framer-scroller": "2.1.31",
23
23
  "@graphcommerce/graphql": "3.4.5",
24
24
  "@graphcommerce/image": "3.1.7",
25
- "@graphcommerce/magento-product": "4.4.23",
26
- "@graphcommerce/magento-store": "4.2.25",
27
- "@graphcommerce/next-ui": "4.19.0"
25
+ "@graphcommerce/magento-product": "4.4.24",
26
+ "@graphcommerce/magento-store": "4.2.26",
27
+ "@graphcommerce/next-ui": "4.20.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
@@ -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'] = []