@graphcommerce/next-ui 6.0.0-canary.42 → 6.0.0-canary.44
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 +8 -0
- package/PageMeta/PageMeta.tsx +3 -2
- package/hooks/index.ts +1 -1
- package/hooks/useStorefrontConfig.ts +18 -0
- package/package.json +8 -8
- package/hooks/useI18nConfig.ts +0 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 6.0.0-canary.44
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1842](https://github.com/graphcommerce-org/graphcommerce/pull/1842) [`7b67d84bd`](https://github.com/graphcommerce-org/graphcommerce/commit/7b67d84bd269c3fc91afbd69f6683c5d12808d36) - Renamed i18n to storefront in configuration ([@paales](https://github.com/paales))
|
|
8
|
+
|
|
9
|
+
## 6.0.0-canary.43
|
|
10
|
+
|
|
3
11
|
## 6.0.0-canary.42
|
|
4
12
|
|
|
5
13
|
## 6.0.0-canary.41
|
package/PageMeta/PageMeta.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import { resolveHref } from 'next/dist/shared/lib/router/utils/resolve-href'
|
|
|
7
7
|
import Head from 'next/head'
|
|
8
8
|
import { useRouter } from 'next/router'
|
|
9
9
|
import type {} from '@graphcommerce/next-config'
|
|
10
|
-
import {
|
|
10
|
+
import { storefrontConfig } from '../hooks'
|
|
11
11
|
|
|
12
12
|
// https://developers.google.com/search/docs/advanced/robots/robots_meta_tag#directives
|
|
13
13
|
export type MetaRobots =
|
|
@@ -64,7 +64,8 @@ export function canonicalize(router: PartialNextRouter, incoming?: Canonical) {
|
|
|
64
64
|
href = localeDomain || addBasePath(addLocale(as, curLocale, router.defaultLocale))
|
|
65
65
|
|
|
66
66
|
let siteUrl =
|
|
67
|
-
|
|
67
|
+
storefrontConfig(router.locale)?.canonicalBaseUrl ||
|
|
68
|
+
import.meta.graphCommerce.canonicalBaseUrl
|
|
68
69
|
if (siteUrl.endsWith('/')) siteUrl = siteUrl.slice(0, -1)
|
|
69
70
|
|
|
70
71
|
canonical = `${siteUrl}${href}`
|
package/hooks/index.ts
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useRouter } from 'next/router'
|
|
2
|
+
|
|
3
|
+
export const storefrontAll = import.meta.graphCommerce.storefront
|
|
4
|
+
|
|
5
|
+
/** Get the current storefront config based on the provided locale */
|
|
6
|
+
export const storefrontConfig = (locale?: string | undefined) =>
|
|
7
|
+
storefrontAll.find((l) => l.locale === locale)
|
|
8
|
+
|
|
9
|
+
export const storefrontConfigDefault = () =>
|
|
10
|
+
storefrontAll.find((l) => l.defaultLocale) ?? storefrontAll[0]
|
|
11
|
+
|
|
12
|
+
/** Automatically selects the correct storefront config based on the current locale */
|
|
13
|
+
export function useStorefrontConfig(locale?: string | undefined) {
|
|
14
|
+
const routerLocale = useRouter().locale
|
|
15
|
+
const config = storefrontConfig(locale ?? routerLocale)
|
|
16
|
+
if (!config) throw Error(`No storefront config found for locale ${locale}`)
|
|
17
|
+
return config
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/next-ui",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "6.0.0-canary.
|
|
5
|
+
"version": "6.0.0-canary.44",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"sideEffects": false,
|
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
"@emotion/react": "^11.10.6",
|
|
19
19
|
"@emotion/server": "^11.4.0",
|
|
20
20
|
"@emotion/styled": "^11.10.6",
|
|
21
|
-
"@graphcommerce/framer-next-pages": "6.0.0-canary.
|
|
22
|
-
"@graphcommerce/framer-scroller": "6.0.0-canary.
|
|
23
|
-
"@graphcommerce/framer-utils": "6.0.0-canary.
|
|
24
|
-
"@graphcommerce/image": "6.0.0-canary.
|
|
21
|
+
"@graphcommerce/framer-next-pages": "6.0.0-canary.44",
|
|
22
|
+
"@graphcommerce/framer-scroller": "6.0.0-canary.44",
|
|
23
|
+
"@graphcommerce/framer-utils": "6.0.0-canary.44",
|
|
24
|
+
"@graphcommerce/image": "6.0.0-canary.44",
|
|
25
25
|
"cookie": "^0.5.0",
|
|
26
26
|
"react-is": "^18.2.0",
|
|
27
27
|
"schema-dts": "^1.1.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@graphcommerce/eslint-config-pwa": "6.0.0-canary.
|
|
31
|
-
"@graphcommerce/prettier-config-pwa": "6.0.0-canary.
|
|
32
|
-
"@graphcommerce/typescript-config-pwa": "6.0.0-canary.
|
|
30
|
+
"@graphcommerce/eslint-config-pwa": "6.0.0-canary.44",
|
|
31
|
+
"@graphcommerce/prettier-config-pwa": "6.0.0-canary.44",
|
|
32
|
+
"@graphcommerce/typescript-config-pwa": "6.0.0-canary.44",
|
|
33
33
|
"@types/cookie": "^0.5.1",
|
|
34
34
|
"@types/react-is": "^17.0.3",
|
|
35
35
|
"typescript": "4.9.5"
|
package/hooks/useI18nConfig.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type {} from '@graphcommerce/next-config'
|
|
2
|
-
import { useRouter } from 'next/router'
|
|
3
|
-
|
|
4
|
-
export const i18nAll = import.meta.graphCommerce.i18n
|
|
5
|
-
|
|
6
|
-
/** Get the current i18n config based on the provided locale */
|
|
7
|
-
export const i18nConfig = (locale?: string | undefined) => i18nAll.find((l) => l.locale === locale)
|
|
8
|
-
|
|
9
|
-
export const i18nConfigDefault = () => i18nAll.find((l) => l.defaultLocale) ?? i18nAll[0]
|
|
10
|
-
|
|
11
|
-
/** Automatically selects the correct i18n config based on the current locale */
|
|
12
|
-
export function useI18nConfig(locale?: string | undefined) {
|
|
13
|
-
const routerLocale = useRouter().locale
|
|
14
|
-
const config = i18nConfig(locale ?? routerLocale)
|
|
15
|
-
if (!config) throw Error(`No i18n config found for locale ${locale}`)
|
|
16
|
-
return config
|
|
17
|
-
}
|