next-intl 3.21.1 → 3.21.2-canary.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/dist/development/middleware/middleware.js +19 -17
- package/dist/development/middleware/resolveLocale.js +20 -34
- package/dist/development/middleware/syncCookie.js +8 -7
- package/dist/development/navigation/react-client/ClientLink.js +2 -2
- package/dist/development/navigation/react-client/createLocalizedPathnamesNavigation.js +6 -1
- package/dist/development/navigation/react-client/createNavigation.js +83 -0
- package/dist/development/navigation/react-client/createSharedPathnamesNavigation.js +6 -1
- package/dist/development/navigation/react-client/useBasePathname.js +0 -14
- package/dist/development/navigation/react-client/useBaseRouter.js +3 -3
- package/dist/development/navigation/react-server/ServerLink.js +4 -2
- package/dist/development/navigation/react-server/createLocalizedPathnamesNavigation.js +5 -4
- package/dist/development/navigation/react-server/createNavigation.js +30 -0
- package/dist/development/navigation/react-server/createSharedPathnamesNavigation.js +2 -0
- package/dist/development/navigation/react-server/redirects.js +2 -2
- package/dist/development/navigation/shared/BaseLink.js +30 -26
- package/dist/development/navigation/shared/LegacyBaseLink.js +57 -0
- package/dist/development/navigation/shared/createSharedNavigationFns.js +148 -0
- package/dist/development/navigation/shared/redirects.js +3 -0
- package/dist/development/navigation/shared/syncLocaleCookie.js +26 -5
- package/dist/development/navigation/shared/utils.js +40 -1
- package/dist/development/navigation.react-client.js +2 -0
- package/dist/development/navigation.react-server.js +2 -0
- package/dist/development/react-client/index.js +0 -2
- package/dist/development/routing/config.js +18 -1
- package/dist/development/server/react-server/RequestLocale.js +15 -25
- package/dist/development/server/react-server/RequestLocaleCache.js +23 -0
- package/dist/development/server/react-server/RequestLocaleLegacy.js +43 -0
- package/dist/development/server/react-server/getConfig.js +15 -17
- package/dist/development/server/react-server/getRequestConfig.js +1 -1
- package/dist/development/server.react-server.js +2 -2
- package/dist/development/shared/constants.js +0 -9
- package/dist/esm/middleware/middleware.js +1 -1
- package/dist/esm/middleware/resolveLocale.js +1 -1
- package/dist/esm/middleware/syncCookie.js +1 -1
- package/dist/esm/navigation/react-client/ClientLink.js +1 -1
- package/dist/esm/navigation/react-client/createLocalizedPathnamesNavigation.js +1 -1
- package/dist/esm/navigation/react-client/createNavigation.js +1 -0
- package/dist/esm/navigation/react-client/createSharedPathnamesNavigation.js +1 -1
- package/dist/esm/navigation/react-client/useBasePathname.js +0 -1
- package/dist/esm/navigation/react-client/useBaseRouter.js +1 -1
- package/dist/esm/navigation/react-server/ServerLink.js +1 -1
- package/dist/esm/navigation/react-server/createLocalizedPathnamesNavigation.js +1 -1
- package/dist/esm/navigation/react-server/createNavigation.js +1 -0
- package/dist/esm/navigation/react-server/createSharedPathnamesNavigation.js +1 -1
- package/dist/esm/navigation/react-server/redirects.js +1 -1
- package/dist/esm/navigation/shared/BaseLink.js +1 -1
- package/dist/esm/navigation/shared/LegacyBaseLink.js +2 -0
- package/dist/esm/navigation/shared/createSharedNavigationFns.js +1 -0
- package/dist/esm/navigation/shared/syncLocaleCookie.js +1 -1
- package/dist/esm/navigation/shared/utils.js +1 -1
- package/dist/esm/navigation.react-client.js +1 -1
- package/dist/esm/navigation.react-server.js +1 -1
- package/dist/esm/routing/config.js +1 -1
- package/dist/esm/server/react-server/RequestLocale.js +1 -1
- package/dist/esm/server/react-server/RequestLocaleCache.js +1 -0
- package/dist/esm/server/react-server/RequestLocaleLegacy.js +1 -0
- package/dist/esm/server/react-server/getConfig.js +1 -1
- package/dist/esm/server.react-server.js +1 -1
- package/dist/esm/shared/constants.js +1 -1
- package/dist/production/middleware/middleware.js +1 -1
- package/dist/production/middleware/resolveLocale.js +1 -1
- package/dist/production/middleware/syncCookie.js +1 -1
- package/dist/production/navigation/react-client/ClientLink.js +1 -1
- package/dist/production/navigation/react-client/createLocalizedPathnamesNavigation.js +1 -1
- package/dist/production/navigation/react-client/createNavigation.js +1 -0
- package/dist/production/navigation/react-client/createSharedPathnamesNavigation.js +1 -1
- package/dist/production/navigation/react-client/useBasePathname.js +0 -1
- package/dist/production/navigation/react-client/useBaseRouter.js +1 -1
- package/dist/production/navigation/react-server/ServerLink.js +1 -1
- package/dist/production/navigation/react-server/createLocalizedPathnamesNavigation.js +1 -1
- package/dist/production/navigation/react-server/createNavigation.js +1 -0
- package/dist/production/navigation/react-server/createSharedPathnamesNavigation.js +1 -1
- package/dist/production/navigation/react-server/redirects.js +1 -1
- package/dist/production/navigation/shared/BaseLink.js +1 -1
- package/dist/production/navigation/shared/LegacyBaseLink.js +2 -0
- package/dist/production/navigation/shared/createSharedNavigationFns.js +1 -0
- package/dist/production/navigation/shared/syncLocaleCookie.js +1 -1
- package/dist/production/navigation/shared/utils.js +1 -1
- package/dist/production/navigation.react-client.js +1 -1
- package/dist/production/navigation.react-server.js +1 -1
- package/dist/production/routing/config.js +1 -1
- package/dist/production/server/react-server/RequestLocale.js +1 -1
- package/dist/production/server/react-server/RequestLocaleCache.js +1 -0
- package/dist/production/server/react-server/RequestLocaleLegacy.js +1 -0
- package/dist/production/server/react-server/getConfig.js +1 -1
- package/dist/production/server.react-server.js +1 -1
- package/dist/production/shared/constants.js +1 -1
- package/dist/types/src/middleware/getAlternateLinksHeaderValue.d.ts +3 -3
- package/dist/types/src/middleware/middleware.d.ts +11 -3
- package/dist/types/src/middleware/resolveLocale.d.ts +2 -3
- package/dist/types/src/middleware/syncCookie.d.ts +2 -1
- package/dist/types/src/middleware/utils.d.ts +4 -4
- package/dist/types/src/navigation/createNavigation.test.d.ts +1 -0
- package/dist/types/src/navigation/react-client/ClientLink.d.ts +6 -6
- package/dist/types/src/navigation/react-client/createLocalizedPathnamesNavigation.d.ts +17 -5
- package/dist/types/src/navigation/react-client/createNavigation.d.ts +467 -0
- package/dist/types/src/navigation/react-client/createNavigation.test.d.ts +1 -0
- package/dist/types/src/navigation/react-client/createSharedPathnamesNavigation.d.ts +9 -5
- package/dist/types/src/navigation/react-client/index.d.ts +1 -0
- package/dist/types/src/navigation/react-client/redirects.d.ts +4 -4
- package/dist/types/src/navigation/react-client/useBasePathname.d.ts +2 -15
- package/dist/types/src/navigation/react-client/useBaseRouter.d.ts +3 -2
- package/dist/types/src/navigation/react-server/ServerLink.d.ts +5 -5
- package/dist/types/src/navigation/react-server/createLocalizedPathnamesNavigation.d.ts +14 -5
- package/dist/types/src/navigation/react-server/createNavigation.d.ts +385 -0
- package/dist/types/src/navigation/react-server/createNavigation.test.d.ts +1 -0
- package/dist/types/src/navigation/react-server/createSharedPathnamesNavigation.d.ts +3 -3
- package/dist/types/src/navigation/react-server/index.d.ts +1 -0
- package/dist/types/src/navigation/react-server/redirects.d.ts +4 -4
- package/dist/types/src/navigation/shared/BaseLink.d.ts +13 -6
- package/dist/types/src/navigation/shared/LegacyBaseLink.d.ts +12 -0
- package/dist/types/src/navigation/shared/createSharedNavigationFns.d.ts +385 -0
- package/dist/types/src/navigation/shared/redirects.d.ts +5 -5
- package/dist/types/src/navigation/shared/syncLocaleCookie.d.ts +2 -1
- package/dist/types/src/navigation/shared/utils.d.ts +10 -3
- package/dist/types/src/routing/config.d.ts +46 -11
- package/dist/types/src/routing/defineRouting.d.ts +2 -2
- package/dist/types/src/routing/types.d.ts +4 -4
- package/dist/types/src/server/react-server/RequestLocale.d.ts +1 -2
- package/dist/types/src/server/react-server/RequestLocaleCache.d.ts +2 -0
- package/dist/types/src/server/react-server/RequestLocaleLegacy.d.ts +1 -0
- package/dist/types/src/server/react-server/createRequestConfig.d.ts +2 -3
- package/dist/types/src/server/react-server/getRequestConfig.d.ts +32 -6
- package/dist/types/src/server/react-server/index.d.ts +1 -1
- package/dist/types/src/shared/constants.d.ts +0 -3
- package/dist/types/src/shared/types.d.ts +3 -0
- package/dist/types/src/shared/utils.d.ts +2 -2
- package/package.json +3 -3
- package/dist/types/src/middleware/config.d.ts +0 -7
|
@@ -11,13 +11,15 @@ var resolveLocale = require('./resolveLocale.js');
|
|
|
11
11
|
var syncCookie = require('./syncCookie.js');
|
|
12
12
|
var utils = require('./utils.js');
|
|
13
13
|
|
|
14
|
-
function createMiddleware(routing,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
function createMiddleware(routing, /** @deprecated Should be passed via the first parameter `routing` instead (ideally defined with `defineRouting`) */
|
|
15
|
+
options) {
|
|
16
|
+
var _options$alternateLin, _options$localeDetect, _options$localeCookie;
|
|
17
|
+
const resolvedRouting = config.receiveRoutingConfig({
|
|
18
|
+
...routing,
|
|
19
|
+
alternateLinks: (_options$alternateLin = options === null || options === void 0 ? void 0 : options.alternateLinks) !== null && _options$alternateLin !== void 0 ? _options$alternateLin : routing.alternateLinks,
|
|
20
|
+
localeDetection: (_options$localeDetect = options === null || options === void 0 ? void 0 : options.localeDetection) !== null && _options$localeDetect !== void 0 ? _options$localeDetect : routing.localeDetection,
|
|
21
|
+
localeCookie: (_options$localeCookie = options === null || options === void 0 ? void 0 : options.localeCookie) !== null && _options$localeCookie !== void 0 ? _options$localeCookie : routing.localeCookie
|
|
22
|
+
});
|
|
21
23
|
return function middleware(request) {
|
|
22
24
|
var _resolvedRouting$doma;
|
|
23
25
|
let unsafeExternalPathname;
|
|
@@ -36,7 +38,7 @@ function createMiddleware(routing, options) {
|
|
|
36
38
|
const {
|
|
37
39
|
domain,
|
|
38
40
|
locale
|
|
39
|
-
} = resolveLocale.default(resolvedRouting,
|
|
41
|
+
} = resolveLocale.default(resolvedRouting, request.headers, request.cookies, externalPathname);
|
|
40
42
|
const hasMatchedDefaultLocale = domain ? domain.defaultLocale === locale : locale === resolvedRouting.defaultLocale;
|
|
41
43
|
const domainsConfig = ((_resolvedRouting$doma = resolvedRouting.domains) === null || _resolvedRouting$doma === void 0 ? void 0 : _resolvedRouting$doma.filter(curDomain => utils.isLocaleSupportedOnDomain(locale, curDomain))) || [];
|
|
42
44
|
const hasUnknownHost = resolvedRouting.domains != null && !domain;
|
|
@@ -55,7 +57,7 @@ function createMiddleware(routing, options) {
|
|
|
55
57
|
}
|
|
56
58
|
function redirect(url, redirectDomain) {
|
|
57
59
|
const urlObj = new URL(utils$1.normalizeTrailingSlash(url), request.url);
|
|
58
|
-
if (domainsConfig.length > 0 && !redirectDomain) {
|
|
60
|
+
if (domainsConfig.length > 0 && !redirectDomain && domain) {
|
|
59
61
|
const bestMatchingDomain = utils.getBestMatchingDomain(domain, locale, domainsConfig);
|
|
60
62
|
if (bestMatchingDomain) {
|
|
61
63
|
redirectDomain = bestMatchingDomain.domain;
|
|
@@ -84,11 +86,12 @@ function createMiddleware(routing, options) {
|
|
|
84
86
|
let response;
|
|
85
87
|
let internalTemplateName;
|
|
86
88
|
let unprefixedInternalPathname = unprefixedExternalPathname;
|
|
87
|
-
|
|
89
|
+
const pathnames = resolvedRouting.pathnames;
|
|
90
|
+
if (pathnames) {
|
|
88
91
|
let resolvedTemplateLocale;
|
|
89
|
-
[resolvedTemplateLocale, internalTemplateName] = utils.getInternalTemplate(
|
|
92
|
+
[resolvedTemplateLocale, internalTemplateName] = utils.getInternalTemplate(pathnames, unprefixedExternalPathname, locale);
|
|
90
93
|
if (internalTemplateName) {
|
|
91
|
-
const pathnameConfig =
|
|
94
|
+
const pathnameConfig = pathnames[internalTemplateName];
|
|
92
95
|
const localeTemplate = typeof pathnameConfig === 'string' ? pathnameConfig :
|
|
93
96
|
// @ts-expect-error -- This is fine
|
|
94
97
|
pathnameConfig[locale];
|
|
@@ -152,14 +155,13 @@ function createMiddleware(routing, options) {
|
|
|
152
155
|
}
|
|
153
156
|
}
|
|
154
157
|
}
|
|
155
|
-
if (
|
|
156
|
-
syncCookie.default(request, response, locale);
|
|
158
|
+
if (resolvedRouting.localeDetection && resolvedRouting.localeCookie) {
|
|
159
|
+
syncCookie.default(request, response, locale, resolvedRouting.localeCookie);
|
|
157
160
|
}
|
|
158
|
-
if (resolvedRouting.localePrefix.mode !== 'never' &&
|
|
159
|
-
var _resolvedRouting$path;
|
|
161
|
+
if (resolvedRouting.localePrefix.mode !== 'never' && resolvedRouting.alternateLinks && resolvedRouting.locales.length > 1) {
|
|
160
162
|
response.headers.set('Link', getAlternateLinksHeaderValue.default({
|
|
161
163
|
routing: resolvedRouting,
|
|
162
|
-
localizedPathnames: internalTemplateName != null &&
|
|
164
|
+
localizedPathnames: internalTemplateName != null && pathnames ? pathnames === null || pathnames === void 0 ? void 0 : pathnames[internalTemplateName] : undefined,
|
|
163
165
|
request,
|
|
164
166
|
resolvedLocale: locale
|
|
165
167
|
}));
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var intlLocalematcher = require('@formatjs/intl-localematcher');
|
|
6
6
|
var Negotiator = require('negotiator');
|
|
7
|
-
var constants = require('../shared/constants.js');
|
|
8
7
|
var utils = require('./utils.js');
|
|
9
8
|
|
|
10
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -12,11 +11,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
12
11
|
var Negotiator__default = /*#__PURE__*/_interopDefault(Negotiator);
|
|
13
12
|
|
|
14
13
|
function findDomainFromHost(requestHeaders, domains) {
|
|
15
|
-
|
|
16
|
-
let host = utils.getHost(requestHeaders);
|
|
17
|
-
|
|
18
|
-
// Remove port (easier for local development)
|
|
19
|
-
host = (_host = host) === null || _host === void 0 ? void 0 : _host.replace(/:\d+$/, '');
|
|
14
|
+
const host = utils.getHost(requestHeaders);
|
|
20
15
|
if (host && domains) {
|
|
21
16
|
return domains.find(cur => cur.domain === host);
|
|
22
17
|
}
|
|
@@ -41,54 +36,46 @@ function getAcceptLanguageLocale(requestHeaders, locales, defaultLocale) {
|
|
|
41
36
|
}
|
|
42
37
|
return locale;
|
|
43
38
|
}
|
|
44
|
-
function getLocaleFromCookie(
|
|
45
|
-
if (requestCookies.has(
|
|
39
|
+
function getLocaleFromCookie(routing, requestCookies) {
|
|
40
|
+
if (routing.localeCookie && requestCookies.has(routing.localeCookie.name)) {
|
|
46
41
|
var _requestCookies$get;
|
|
47
|
-
const value = (_requestCookies$get = requestCookies.get(
|
|
48
|
-
if (value && locales.includes(value)) {
|
|
42
|
+
const value = (_requestCookies$get = requestCookies.get(routing.localeCookie.name)) === null || _requestCookies$get === void 0 ? void 0 : _requestCookies$get.value;
|
|
43
|
+
if (value && routing.locales.includes(value)) {
|
|
49
44
|
return value;
|
|
50
45
|
}
|
|
51
46
|
}
|
|
52
47
|
}
|
|
53
|
-
function resolveLocaleFromPrefix(
|
|
54
|
-
let {
|
|
55
|
-
defaultLocale,
|
|
56
|
-
localePrefix,
|
|
57
|
-
locales
|
|
58
|
-
} = _ref;
|
|
59
|
-
let {
|
|
60
|
-
localeDetection
|
|
61
|
-
} = _ref2;
|
|
48
|
+
function resolveLocaleFromPrefix(routing, requestHeaders, requestCookies, pathname) {
|
|
62
49
|
let locale;
|
|
63
50
|
|
|
64
51
|
// Prio 1: Use route prefix
|
|
65
52
|
if (pathname) {
|
|
66
53
|
var _getPathnameMatch;
|
|
67
|
-
locale = (_getPathnameMatch = utils.getPathnameMatch(pathname, locales, localePrefix)) === null || _getPathnameMatch === void 0 ? void 0 : _getPathnameMatch.locale;
|
|
54
|
+
locale = (_getPathnameMatch = utils.getPathnameMatch(pathname, routing.locales, routing.localePrefix)) === null || _getPathnameMatch === void 0 ? void 0 : _getPathnameMatch.locale;
|
|
68
55
|
}
|
|
69
56
|
|
|
70
57
|
// Prio 2: Use existing cookie
|
|
71
|
-
if (!locale && localeDetection && requestCookies) {
|
|
72
|
-
locale = getLocaleFromCookie(
|
|
58
|
+
if (!locale && routing.localeDetection && requestCookies) {
|
|
59
|
+
locale = getLocaleFromCookie(routing, requestCookies);
|
|
73
60
|
}
|
|
74
61
|
|
|
75
62
|
// Prio 3: Use the `accept-language` header
|
|
76
|
-
if (!locale && localeDetection && requestHeaders) {
|
|
77
|
-
locale = getAcceptLanguageLocale(requestHeaders, locales, defaultLocale);
|
|
63
|
+
if (!locale && routing.localeDetection && requestHeaders) {
|
|
64
|
+
locale = getAcceptLanguageLocale(requestHeaders, routing.locales, routing.defaultLocale);
|
|
78
65
|
}
|
|
79
66
|
|
|
80
67
|
// Prio 4: Use default locale
|
|
81
68
|
if (!locale) {
|
|
82
|
-
locale = defaultLocale;
|
|
69
|
+
locale = routing.defaultLocale;
|
|
83
70
|
}
|
|
84
71
|
return locale;
|
|
85
72
|
}
|
|
86
|
-
function resolveLocaleFromDomain(routing,
|
|
73
|
+
function resolveLocaleFromDomain(routing, requestHeaders, requestCookies, pathname) {
|
|
87
74
|
const domains = routing.domains;
|
|
88
75
|
const domain = findDomainFromHost(requestHeaders, domains);
|
|
89
76
|
if (!domain) {
|
|
90
77
|
return {
|
|
91
|
-
locale: resolveLocaleFromPrefix(routing,
|
|
78
|
+
locale: resolveLocaleFromPrefix(routing, requestHeaders, requestCookies, pathname)
|
|
92
79
|
};
|
|
93
80
|
}
|
|
94
81
|
let locale;
|
|
@@ -111,8 +98,8 @@ function resolveLocaleFromDomain(routing, options, requestHeaders, requestCookie
|
|
|
111
98
|
}
|
|
112
99
|
|
|
113
100
|
// Prio 2: Use existing cookie
|
|
114
|
-
if (!locale &&
|
|
115
|
-
const cookieLocale = getLocaleFromCookie(
|
|
101
|
+
if (!locale && routing.localeDetection && requestCookies) {
|
|
102
|
+
const cookieLocale = getLocaleFromCookie(routing, requestCookies);
|
|
116
103
|
if (cookieLocale) {
|
|
117
104
|
if (utils.isLocaleSupportedOnDomain(cookieLocale, domain)) {
|
|
118
105
|
locale = cookieLocale;
|
|
@@ -121,7 +108,7 @@ function resolveLocaleFromDomain(routing, options, requestHeaders, requestCookie
|
|
|
121
108
|
}
|
|
122
109
|
|
|
123
110
|
// Prio 3: Use the `accept-language` header
|
|
124
|
-
if (!locale &&
|
|
111
|
+
if (!locale && routing.localeDetection && requestHeaders) {
|
|
125
112
|
const headerLocale = getAcceptLanguageLocale(requestHeaders, domain.locales || routing.locales, domain.defaultLocale);
|
|
126
113
|
if (headerLocale) {
|
|
127
114
|
locale = headerLocale;
|
|
@@ -137,13 +124,12 @@ function resolveLocaleFromDomain(routing, options, requestHeaders, requestCookie
|
|
|
137
124
|
domain
|
|
138
125
|
};
|
|
139
126
|
}
|
|
140
|
-
function resolveLocale(routing,
|
|
127
|
+
function resolveLocale(routing, requestHeaders, requestCookies, pathname) {
|
|
141
128
|
if (routing.domains) {
|
|
142
|
-
|
|
143
|
-
return resolveLocaleFromDomain(routingWithDomains, options, requestHeaders, requestCookies, pathname);
|
|
129
|
+
return resolveLocaleFromDomain(routing, requestHeaders, requestCookies, pathname);
|
|
144
130
|
} else {
|
|
145
131
|
return {
|
|
146
|
-
locale: resolveLocaleFromPrefix(routing,
|
|
132
|
+
locale: resolveLocaleFromPrefix(routing, requestHeaders, requestCookies, pathname)
|
|
147
133
|
};
|
|
148
134
|
}
|
|
149
135
|
}
|
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function syncCookie(request, response, locale) {
|
|
5
|
+
function syncCookie(request, response, locale, localeCookie) {
|
|
8
6
|
var _request$cookies$get;
|
|
9
|
-
const
|
|
7
|
+
const {
|
|
8
|
+
name,
|
|
9
|
+
...rest
|
|
10
|
+
} = localeCookie;
|
|
11
|
+
const hasOutdatedCookie = ((_request$cookies$get = request.cookies.get(name)) === null || _request$cookies$get === void 0 ? void 0 : _request$cookies$get.value) !== locale;
|
|
10
12
|
if (hasOutdatedCookie) {
|
|
11
|
-
response.cookies.set(
|
|
13
|
+
response.cookies.set(name, locale, {
|
|
12
14
|
path: request.nextUrl.basePath || undefined,
|
|
13
|
-
|
|
14
|
-
maxAge: constants.COOKIE_MAX_AGE
|
|
15
|
+
...rest
|
|
15
16
|
});
|
|
16
17
|
}
|
|
17
18
|
}
|
|
@@ -6,7 +6,7 @@ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelper
|
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var useLocale = require('../../react-client/useLocale.js');
|
|
8
8
|
var utils = require('../../shared/utils.js');
|
|
9
|
-
var
|
|
9
|
+
var LegacyBaseLink = require('../shared/LegacyBaseLink.js');
|
|
10
10
|
|
|
11
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
|
|
@@ -21,7 +21,7 @@ function ClientLink(_ref, ref) {
|
|
|
21
21
|
const defaultLocale = useLocale.default();
|
|
22
22
|
const finalLocale = locale || defaultLocale;
|
|
23
23
|
const prefix = utils.getLocalePrefix(finalLocale, localePrefix);
|
|
24
|
-
return /*#__PURE__*/React__default.default.createElement(
|
|
24
|
+
return /*#__PURE__*/React__default.default.createElement(LegacyBaseLink.default, _rollupPluginBabelHelpers.extends({
|
|
25
25
|
ref: ref,
|
|
26
26
|
locale: finalLocale,
|
|
27
27
|
localePrefixMode: localePrefix.mode,
|
|
@@ -16,8 +16,12 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
16
16
|
|
|
17
17
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Consider switching to `createNavigation` (see https://github.com/amannn/next-intl/pull/1316)
|
|
21
|
+
**/
|
|
19
22
|
function createLocalizedPathnamesNavigation(routing) {
|
|
20
23
|
const config$1 = config.receiveRoutingConfig(routing);
|
|
24
|
+
const localeCookie = config.receiveLocaleCookie(routing === null || routing === void 0 ? void 0 : routing.localeCookie);
|
|
21
25
|
function useTypedLocale() {
|
|
22
26
|
const locale = useLocale.default();
|
|
23
27
|
const isValid = config$1.locales.includes(locale);
|
|
@@ -45,6 +49,7 @@ function createLocalizedPathnamesNavigation(routing) {
|
|
|
45
49
|
pathnames: config$1.pathnames
|
|
46
50
|
}),
|
|
47
51
|
locale: locale,
|
|
52
|
+
localeCookie: localeCookie,
|
|
48
53
|
localePrefix: config$1.localePrefix
|
|
49
54
|
}, rest));
|
|
50
55
|
}
|
|
@@ -81,7 +86,7 @@ function createLocalizedPathnamesNavigation(routing) {
|
|
|
81
86
|
}, ...args);
|
|
82
87
|
}
|
|
83
88
|
function useRouter() {
|
|
84
|
-
const baseRouter = useBaseRouter.default(config$1.localePrefix);
|
|
89
|
+
const baseRouter = useBaseRouter.default(config$1.localePrefix, localeCookie);
|
|
85
90
|
const defaultLocale = useTypedLocale();
|
|
86
91
|
return React.useMemo(() => ({
|
|
87
92
|
...baseRouter,
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var navigation = require('next/navigation');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var useLocale = require('../../react-client/useLocale.js');
|
|
8
|
+
var createSharedNavigationFns = require('../shared/createSharedNavigationFns.js');
|
|
9
|
+
var syncLocaleCookie = require('../shared/syncLocaleCookie.js');
|
|
10
|
+
var utils = require('../shared/utils.js');
|
|
11
|
+
var useBasePathname = require('./useBasePathname.js');
|
|
12
|
+
|
|
13
|
+
function createNavigation(routing) {
|
|
14
|
+
function useTypedLocale() {
|
|
15
|
+
return useLocale.default();
|
|
16
|
+
}
|
|
17
|
+
const {
|
|
18
|
+
Link,
|
|
19
|
+
config,
|
|
20
|
+
getPathname,
|
|
21
|
+
...redirects
|
|
22
|
+
} = createSharedNavigationFns.default(useTypedLocale, routing);
|
|
23
|
+
|
|
24
|
+
/** @see https://next-intl-docs.vercel.app/docs/routing/navigation#usepathname */
|
|
25
|
+
function usePathname() {
|
|
26
|
+
const pathname = useBasePathname.default(config.localePrefix);
|
|
27
|
+
const locale = useTypedLocale();
|
|
28
|
+
|
|
29
|
+
// @ts-expect-error -- Mirror the behavior from Next.js, where `null` is returned when `usePathname` is used outside of Next, but the types indicate that a string is always returned.
|
|
30
|
+
return React.useMemo(() => pathname &&
|
|
31
|
+
// @ts-expect-error -- This is fine
|
|
32
|
+
config.pathnames ? utils.getRoute(locale, pathname,
|
|
33
|
+
// @ts-expect-error -- This is fine
|
|
34
|
+
config.pathnames) : pathname, [locale, pathname]);
|
|
35
|
+
}
|
|
36
|
+
function useRouter() {
|
|
37
|
+
const router = navigation.useRouter();
|
|
38
|
+
const curLocale = useTypedLocale();
|
|
39
|
+
const nextPathname = navigation.usePathname();
|
|
40
|
+
return React.useMemo(() => {
|
|
41
|
+
function createHandler(fn) {
|
|
42
|
+
return function handler(href, options) {
|
|
43
|
+
const {
|
|
44
|
+
locale: nextLocale,
|
|
45
|
+
...rest
|
|
46
|
+
} = options || {};
|
|
47
|
+
|
|
48
|
+
// @ts-expect-error -- We're passing a domain here just in case
|
|
49
|
+
const pathname = getPathname({
|
|
50
|
+
href,
|
|
51
|
+
locale: nextLocale || curLocale,
|
|
52
|
+
domain: window.location.host
|
|
53
|
+
});
|
|
54
|
+
const args = [pathname];
|
|
55
|
+
if (Object.keys(rest).length > 0) {
|
|
56
|
+
// @ts-expect-error -- This is fine
|
|
57
|
+
args.push(rest);
|
|
58
|
+
}
|
|
59
|
+
fn(...args);
|
|
60
|
+
syncLocaleCookie.default(config.localeCookie, nextPathname, curLocale, nextLocale);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
...router,
|
|
65
|
+
/** @see https://next-intl-docs.vercel.app/docs/routing/navigation#userouter */
|
|
66
|
+
push: createHandler(router.push),
|
|
67
|
+
/** @see https://next-intl-docs.vercel.app/docs/routing/navigation#userouter */
|
|
68
|
+
replace: createHandler(router.replace),
|
|
69
|
+
/** @see https://next-intl-docs.vercel.app/docs/routing/navigation#userouter */
|
|
70
|
+
prefetch: createHandler(router.prefetch)
|
|
71
|
+
};
|
|
72
|
+
}, [curLocale, nextPathname, router]);
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
...redirects,
|
|
76
|
+
Link,
|
|
77
|
+
usePathname,
|
|
78
|
+
useRouter,
|
|
79
|
+
getPathname
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
exports.default = createNavigation;
|
|
@@ -14,11 +14,16 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
14
14
|
|
|
15
15
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Consider switching to `createNavigation` (see https://github.com/amannn/next-intl/pull/1316)
|
|
19
|
+
**/
|
|
17
20
|
function createSharedPathnamesNavigation(routing) {
|
|
18
21
|
const localePrefix = config.receiveLocalePrefixConfig(routing === null || routing === void 0 ? void 0 : routing.localePrefix);
|
|
22
|
+
const localeCookie = config.receiveLocaleCookie(routing === null || routing === void 0 ? void 0 : routing.localeCookie);
|
|
19
23
|
function Link(props, ref) {
|
|
20
24
|
return /*#__PURE__*/React__default.default.createElement(ClientLink.default, _rollupPluginBabelHelpers.extends({
|
|
21
25
|
ref: ref,
|
|
26
|
+
localeCookie: localeCookie,
|
|
22
27
|
localePrefix: localePrefix
|
|
23
28
|
}, props));
|
|
24
29
|
}
|
|
@@ -48,7 +53,7 @@ function createSharedPathnamesNavigation(routing) {
|
|
|
48
53
|
return result;
|
|
49
54
|
}
|
|
50
55
|
function useRouter() {
|
|
51
|
-
return useBaseRouter.default(localePrefix);
|
|
56
|
+
return useBaseRouter.default(localePrefix, localeCookie);
|
|
52
57
|
}
|
|
53
58
|
return {
|
|
54
59
|
Link: LinkWithRef,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use client";
|
|
2
1
|
'use strict';
|
|
3
2
|
|
|
4
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -8,19 +7,6 @@ var React = require('react');
|
|
|
8
7
|
var useLocale = require('../../react-client/useLocale.js');
|
|
9
8
|
var utils = require('../../shared/utils.js');
|
|
10
9
|
|
|
11
|
-
/**
|
|
12
|
-
* Returns the pathname without a potential locale prefix.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```tsx
|
|
16
|
-
* 'use client';
|
|
17
|
-
*
|
|
18
|
-
* import {usePathname} from 'next-intl/client';
|
|
19
|
-
*
|
|
20
|
-
* // When the user is on `/en`, this will be `/`
|
|
21
|
-
* const pathname = usePathname();
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
10
|
function useBasePathname(localePrefix) {
|
|
25
11
|
// The types aren't entirely correct here. Outside of Next.js
|
|
26
12
|
// `useParams` can be called, but the return type is `null`.
|
|
@@ -28,7 +28,7 @@ var utils = require('../shared/utils.js');
|
|
|
28
28
|
* router.push('/about', {locale: 'de'});
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
|
-
function useBaseRouter(localePrefix) {
|
|
31
|
+
function useBaseRouter(localePrefix, localeCookie) {
|
|
32
32
|
const router = navigation.useRouter();
|
|
33
33
|
const locale = useLocale.default();
|
|
34
34
|
const pathname = navigation.usePathname();
|
|
@@ -50,7 +50,7 @@ function useBaseRouter(localePrefix) {
|
|
|
50
50
|
locale: nextLocale,
|
|
51
51
|
...rest
|
|
52
52
|
} = options || {};
|
|
53
|
-
syncLocaleCookie.default(pathname, locale, nextLocale);
|
|
53
|
+
syncLocaleCookie.default(localeCookie, pathname, locale, nextLocale);
|
|
54
54
|
const args = [localize(href, nextLocale)];
|
|
55
55
|
if (Object.keys(rest).length > 0) {
|
|
56
56
|
args.push(rest);
|
|
@@ -66,7 +66,7 @@ function useBaseRouter(localePrefix) {
|
|
|
66
66
|
replace: createHandler(router.replace),
|
|
67
67
|
prefetch: createHandler(router.prefetch)
|
|
68
68
|
};
|
|
69
|
-
}, [locale, localePrefix, pathname, router]);
|
|
69
|
+
}, [locale, localeCookie, localePrefix, pathname, router]);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
exports.default = useBaseRouter;
|
|
@@ -5,13 +5,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var utils = require('../../shared/utils.js');
|
|
8
|
-
var
|
|
8
|
+
var LegacyBaseLink = require('../shared/LegacyBaseLink.js');
|
|
9
9
|
var getLocale = require('../../server/react-server/getLocale.js');
|
|
10
10
|
|
|
11
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
|
|
13
13
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
14
14
|
|
|
15
|
+
// Only used by legacy navigation APIs, can be removed when they are removed
|
|
16
|
+
|
|
15
17
|
async function ServerLink(_ref) {
|
|
16
18
|
let {
|
|
17
19
|
locale,
|
|
@@ -20,7 +22,7 @@ async function ServerLink(_ref) {
|
|
|
20
22
|
} = _ref;
|
|
21
23
|
const finalLocale = locale || (await getLocale.default());
|
|
22
24
|
const prefix = utils.getLocalePrefix(finalLocale, localePrefix);
|
|
23
|
-
return /*#__PURE__*/React__default.default.createElement(
|
|
25
|
+
return /*#__PURE__*/React__default.default.createElement(LegacyBaseLink.default, _rollupPluginBabelHelpers.extends({
|
|
24
26
|
locale: finalLocale,
|
|
25
27
|
localePrefixMode: localePrefix.mode,
|
|
26
28
|
prefix: prefix
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var config = require('../../routing/config.js');
|
|
8
|
-
var
|
|
8
|
+
var RequestLocaleLegacy = require('../../server/react-server/RequestLocaleLegacy.js');
|
|
9
9
|
var utils = require('../shared/utils.js');
|
|
10
10
|
var ServerLink = require('./ServerLink.js');
|
|
11
11
|
var redirects = require('./redirects.js');
|
|
@@ -22,7 +22,7 @@ function createLocalizedPathnamesNavigation(routing) {
|
|
|
22
22
|
locale,
|
|
23
23
|
...rest
|
|
24
24
|
} = _ref;
|
|
25
|
-
const defaultLocale =
|
|
25
|
+
const defaultLocale = RequestLocaleLegacy.getRequestLocale();
|
|
26
26
|
const finalLocale = locale || defaultLocale;
|
|
27
27
|
return /*#__PURE__*/React__default.default.createElement(ServerLink.default, _rollupPluginBabelHelpers.extends({
|
|
28
28
|
href: utils.compileLocalizedPathname({
|
|
@@ -34,11 +34,12 @@ function createLocalizedPathnamesNavigation(routing) {
|
|
|
34
34
|
pathnames: config$1.pathnames
|
|
35
35
|
}),
|
|
36
36
|
locale: locale,
|
|
37
|
+
localeCookie: config$1.localeCookie,
|
|
37
38
|
localePrefix: config$1.localePrefix
|
|
38
39
|
}, rest));
|
|
39
40
|
}
|
|
40
41
|
function redirect(href) {
|
|
41
|
-
const locale =
|
|
42
|
+
const locale = RequestLocaleLegacy.getRequestLocale();
|
|
42
43
|
const pathname = getPathname({
|
|
43
44
|
href,
|
|
44
45
|
locale
|
|
@@ -52,7 +53,7 @@ function createLocalizedPathnamesNavigation(routing) {
|
|
|
52
53
|
}, ...args);
|
|
53
54
|
}
|
|
54
55
|
function permanentRedirect(href) {
|
|
55
|
-
const locale =
|
|
56
|
+
const locale = RequestLocaleLegacy.getRequestLocale();
|
|
56
57
|
const pathname = getPathname({
|
|
57
58
|
href,
|
|
58
59
|
locale
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var RequestLocale = require('../../server/react-server/RequestLocale.js');
|
|
6
|
+
var createSharedNavigationFns = require('../shared/createSharedNavigationFns.js');
|
|
7
|
+
|
|
8
|
+
function createNavigation(routing) {
|
|
9
|
+
function getLocale() {
|
|
10
|
+
return RequestLocale.getRequestLocale();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
|
+
const {
|
|
15
|
+
config,
|
|
16
|
+
...fns
|
|
17
|
+
} = createSharedNavigationFns.default(getLocale, routing);
|
|
18
|
+
function notSupported(hookName) {
|
|
19
|
+
return () => {
|
|
20
|
+
throw new Error("`".concat(hookName, "` is not supported in Server Components. You can use this hook if you convert the calling component to a Client Component."));
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
...fns,
|
|
25
|
+
usePathname: notSupported('usePathname'),
|
|
26
|
+
useRouter: notSupported('useRouter')
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
exports.default = createNavigation;
|
|
@@ -14,6 +14,7 @@ var React__default = /*#__PURE__*/_interopDefault(React);
|
|
|
14
14
|
|
|
15
15
|
function createSharedPathnamesNavigation(routing) {
|
|
16
16
|
const localePrefix = config.receiveLocalePrefixConfig(routing === null || routing === void 0 ? void 0 : routing.localePrefix);
|
|
17
|
+
const localeCookie = config.receiveLocaleCookie(routing === null || routing === void 0 ? void 0 : routing.localeCookie);
|
|
17
18
|
function notSupported(hookName) {
|
|
18
19
|
return () => {
|
|
19
20
|
throw new Error("`".concat(hookName, "` is not supported in Server Components. You can use this hook if you convert the component to a Client Component."));
|
|
@@ -21,6 +22,7 @@ function createSharedPathnamesNavigation(routing) {
|
|
|
21
22
|
}
|
|
22
23
|
function Link(props) {
|
|
23
24
|
return /*#__PURE__*/React__default.default.createElement(ServerLink.default, _rollupPluginBabelHelpers.extends({
|
|
25
|
+
localeCookie: localeCookie,
|
|
24
26
|
localePrefix: localePrefix
|
|
25
27
|
}, props));
|
|
26
28
|
}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var RequestLocaleLegacy = require('../../server/react-server/RequestLocaleLegacy.js');
|
|
6
6
|
var redirects = require('../shared/redirects.js');
|
|
7
7
|
|
|
8
8
|
function createRedirectFn(redirectFn) {
|
|
9
9
|
return function serverRedirect(params) {
|
|
10
|
-
const locale =
|
|
10
|
+
const locale = RequestLocaleLegacy.getRequestLocale();
|
|
11
11
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
12
12
|
args[_key - 1] = arguments[_key];
|
|
13
13
|
}
|
|
@@ -8,7 +8,6 @@ var NextLink = require('next/link');
|
|
|
8
8
|
var navigation = require('next/navigation');
|
|
9
9
|
var React = require('react');
|
|
10
10
|
var useLocale = require('../../react-client/useLocale.js');
|
|
11
|
-
var utils = require('../../shared/utils.js');
|
|
12
11
|
var syncLocaleCookie = require('./syncLocaleCookie.js');
|
|
13
12
|
|
|
14
13
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -18,39 +17,38 @@ var React__default = /*#__PURE__*/_interopDefault(React);
|
|
|
18
17
|
|
|
19
18
|
function BaseLink(_ref, ref) {
|
|
20
19
|
let {
|
|
20
|
+
defaultLocale,
|
|
21
21
|
href,
|
|
22
22
|
locale,
|
|
23
|
-
|
|
23
|
+
localeCookie,
|
|
24
24
|
onClick,
|
|
25
25
|
prefetch,
|
|
26
|
-
|
|
26
|
+
unprefixed,
|
|
27
27
|
...rest
|
|
28
28
|
} = _ref;
|
|
29
|
+
const curLocale = useLocale.default();
|
|
30
|
+
const isChangingLocale = locale !== curLocale;
|
|
31
|
+
const linkLocale = locale || curLocale;
|
|
32
|
+
const host = useHost();
|
|
33
|
+
const finalHref =
|
|
34
|
+
// Only after hydration (to avoid mismatches)
|
|
35
|
+
host &&
|
|
36
|
+
// If there is an `unprefixed` prop, the
|
|
37
|
+
// `defaultLocale` might differ by domain
|
|
38
|
+
unprefixed && (
|
|
39
|
+
// Unprefix the pathname if a domain matches
|
|
40
|
+
unprefixed.domains[host] === linkLocale ||
|
|
41
|
+
// … and handle unknown domains by applying the
|
|
42
|
+
// global `defaultLocale` (e.g. on localhost)
|
|
43
|
+
!Object.keys(unprefixed.domains).includes(host) && curLocale === defaultLocale && !locale) ? unprefixed.pathname : href;
|
|
44
|
+
|
|
29
45
|
// The types aren't entirely correct here. Outside of Next.js
|
|
30
46
|
// `useParams` can be called, but the return type is `null`.
|
|
31
47
|
const pathname = navigation.usePathname();
|
|
32
|
-
const curLocale = useLocale.default();
|
|
33
|
-
const isChangingLocale = locale !== curLocale;
|
|
34
|
-
const [localizedHref, setLocalizedHref] = React.useState(() => utils.isLocalizableHref(href) && (localePrefixMode !== 'never' || isChangingLocale) ?
|
|
35
|
-
// For the `localePrefix: 'as-needed' strategy, the href shouldn't
|
|
36
|
-
// be prefixed if the locale is the default locale. To determine this, we
|
|
37
|
-
// need a) the default locale and b) the information if we use prefixed
|
|
38
|
-
// routing. The default locale can vary by domain, therefore during the
|
|
39
|
-
// RSC as well as the SSR render, we can't determine the default locale
|
|
40
|
-
// statically. Therefore we always prefix the href since this will
|
|
41
|
-
// always result in a valid URL, even if it might cause a redirect. This
|
|
42
|
-
// is better than pointing to a non-localized href during the server
|
|
43
|
-
// render, which would potentially be wrong. The final href is
|
|
44
|
-
// determined in the effect below.
|
|
45
|
-
utils.prefixHref(href, prefix) : href);
|
|
46
48
|
function onLinkClick(event) {
|
|
47
|
-
syncLocaleCookie.default(pathname, curLocale, locale);
|
|
49
|
+
syncLocaleCookie.default(localeCookie, pathname, curLocale, locale);
|
|
48
50
|
if (onClick) onClick(event);
|
|
49
51
|
}
|
|
50
|
-
React.useEffect(() => {
|
|
51
|
-
if (!pathname) return;
|
|
52
|
-
setLocalizedHref(utils.localizeHref(href, locale, curLocale, pathname, prefix));
|
|
53
|
-
}, [curLocale, href, locale, pathname, prefix]);
|
|
54
52
|
if (isChangingLocale) {
|
|
55
53
|
if (prefetch && "development" !== 'production') {
|
|
56
54
|
console.error('The `prefetch` prop is currently not supported when using the `locale` prop on `Link` to switch the locale.`');
|
|
@@ -59,13 +57,19 @@ function BaseLink(_ref, ref) {
|
|
|
59
57
|
}
|
|
60
58
|
return /*#__PURE__*/React__default.default.createElement(NextLink__default.default, _rollupPluginBabelHelpers.extends({
|
|
61
59
|
ref: ref,
|
|
62
|
-
href:
|
|
60
|
+
href: finalHref,
|
|
63
61
|
hrefLang: isChangingLocale ? locale : undefined,
|
|
64
62
|
onClick: onLinkClick,
|
|
65
63
|
prefetch: prefetch
|
|
66
64
|
}, rest));
|
|
67
65
|
}
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
function useHost() {
|
|
67
|
+
const [host, setHost] = React.useState();
|
|
68
|
+
React.useEffect(() => {
|
|
69
|
+
setHost(window.location.host);
|
|
70
|
+
}, []);
|
|
71
|
+
return host;
|
|
72
|
+
}
|
|
73
|
+
var BaseLink$1 = /*#__PURE__*/React.forwardRef(BaseLink);
|
|
70
74
|
|
|
71
|
-
exports.default =
|
|
75
|
+
exports.default = BaseLink$1;
|