@prezly/theme-kit-nextjs 1.15.0 → 1.16.0-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/build/adapter-nextjs/api-handlers/fetchGalleries.js +15 -69
- package/build/adapter-nextjs/api-handlers/fetchGalleries.js.map +1 -1
- package/build/adapter-nextjs/api-handlers/fetchStories.js +17 -71
- package/build/adapter-nextjs/api-handlers/fetchStories.js.map +1 -1
- package/build/adapter-nextjs/api-handlers/index.js +2 -7
- package/build/adapter-nextjs/api-handlers/index.js.map +1 -1
- package/build/adapter-nextjs/getNewsroomServerSideProps.js +9 -63
- package/build/adapter-nextjs/getNewsroomServerSideProps.js.map +1 -1
- package/build/adapter-nextjs/getNewsroomStaticProps.js +9 -63
- package/build/adapter-nextjs/getNewsroomStaticProps.js.map +1 -1
- package/build/adapter-nextjs/index.js +6 -22
- package/build/adapter-nextjs/index.js.map +1 -1
- package/build/adapter-nextjs/page-props/category.d.ts +1 -1
- package/build/adapter-nextjs/page-props/category.js +95 -202
- package/build/adapter-nextjs/page-props/category.js.map +1 -1
- package/build/adapter-nextjs/page-props/gallery.d.ts +1 -1
- package/build/adapter-nextjs/page-props/gallery.js +59 -141
- package/build/adapter-nextjs/page-props/gallery.js.map +1 -1
- package/build/adapter-nextjs/page-props/galleryAlbum.d.ts +1 -1
- package/build/adapter-nextjs/page-props/galleryAlbum.js +41 -139
- package/build/adapter-nextjs/page-props/galleryAlbum.js.map +1 -1
- package/build/adapter-nextjs/page-props/home.d.ts +1 -1
- package/build/adapter-nextjs/page-props/home.js +58 -142
- package/build/adapter-nextjs/page-props/home.js.map +1 -1
- package/build/adapter-nextjs/page-props/index.js +8 -41
- package/build/adapter-nextjs/page-props/index.js.map +1 -1
- package/build/adapter-nextjs/page-props/lib/types.d.ts +1 -1
- package/build/adapter-nextjs/page-props/lib/types.js +1 -2
- package/build/adapter-nextjs/page-props/search.d.ts +2 -2
- package/build/adapter-nextjs/page-props/search.js +21 -103
- package/build/adapter-nextjs/page-props/search.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js +18 -22
- package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/createPaths.js +10 -45
- package/build/adapter-nextjs/page-props/sitemap/createPaths.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js +29 -81
- package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/index.js +4 -24
- package/build/adapter-nextjs/page-props/sitemap/index.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/types.js +1 -2
- package/build/adapter-nextjs/page-props/story.d.ts +1 -1
- package/build/adapter-nextjs/page-props/story.js +58 -166
- package/build/adapter-nextjs/page-props/story.js.map +1 -1
- package/build/adapter-nextjs/page-props/storyPreview.js +20 -85
- package/build/adapter-nextjs/page-props/storyPreview.js.map +1 -1
- package/build/adapter-nextjs/processRequest.js +9 -24
- package/build/adapter-nextjs/processRequest.js.map +1 -1
- package/build/adapter-nextjs/processStaticRequest.js +3 -18
- package/build/adapter-nextjs/processStaticRequest.js.map +1 -1
- package/build/components-nextjs/PageSeo/PageSeo.js +42 -57
- package/build/components-nextjs/PageSeo/PageSeo.js.map +1 -1
- package/build/components-nextjs/PageSeo/index.js +2 -20
- package/build/components-nextjs/PageSeo/index.js.map +1 -1
- package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js +2 -6
- package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js.map +1 -1
- package/build/components-nextjs/PageSeo/lib/types.js +1 -2
- package/build/components-nextjs/StorySeo/StorySeo.js +28 -36
- package/build/components-nextjs/StorySeo/StorySeo.js.map +1 -1
- package/build/components-nextjs/StorySeo/index.js +1 -5
- package/build/components-nextjs/StorySeo/index.js.map +1 -1
- package/build/components-nextjs/document.d.ts +6 -0
- package/build/components-nextjs/document.js +21 -0
- package/build/components-nextjs/document.js.map +1 -0
- package/build/components-nextjs/index.d.ts +1 -0
- package/build/components-nextjs/index.js +3 -7
- package/build/components-nextjs/index.js.map +1 -1
- package/build/data-fetching/api/PrezlyApi.js +171 -363
- package/build/data-fetching/api/PrezlyApi.js.map +1 -1
- package/build/data-fetching/api/getPrezlyApi.js +5 -9
- package/build/data-fetching/api/getPrezlyApi.js.map +1 -1
- package/build/data-fetching/api/index.js +1 -17
- package/build/data-fetching/api/index.js.map +1 -1
- package/build/data-fetching/api/queries.js +13 -45
- package/build/data-fetching/api/queries.js.map +1 -1
- package/build/data-fetching/index.js +3 -19
- package/build/data-fetching/index.js.map +1 -1
- package/build/data-fetching/lib/getAlgoliaSettings.js +6 -10
- package/build/data-fetching/lib/getAlgoliaSettings.js.map +1 -1
- package/build/data-fetching/lib/getEnvVariables.js +11 -29
- package/build/data-fetching/lib/getEnvVariables.js.map +1 -1
- package/build/data-fetching/lib/index.js +4 -11
- package/build/data-fetching/lib/index.js.map +1 -1
- package/build/data-fetching/lib/isSdkError.js +1 -5
- package/build/data-fetching/lib/isSdkError.js.map +1 -1
- package/build/data-fetching/lib/isUuid.js +2 -6
- package/build/data-fetching/lib/isUuid.js.map +1 -1
- package/build/data-fetching/types.js +1 -2
- package/build/index.d.ts +1 -0
- package/build/index.js +9 -24
- package/build/index.js.map +1 -1
- package/build/infinite-loading/index.js +4 -24
- package/build/infinite-loading/index.js.map +1 -1
- package/build/infinite-loading/types.js +1 -2
- package/build/infinite-loading/useInfiniteGalleriesLoading.js +25 -83
- package/build/infinite-loading/useInfiniteGalleriesLoading.js.map +1 -1
- package/build/infinite-loading/useInfiniteLoading.js +21 -97
- package/build/infinite-loading/useInfiniteLoading.js.map +1 -1
- package/build/infinite-loading/useInfiniteStoriesLoading.js +36 -99
- package/build/infinite-loading/useInfiniteStoriesLoading.js.map +1 -1
- package/build/intl/index.js +4 -25
- package/build/intl/index.js.map +1 -1
- package/build/intl/languages.js +47 -93
- package/build/intl/languages.js.map +1 -1
- package/build/intl/locale.js +21 -27
- package/build/intl/locale.js.map +1 -1
- package/build/intl/localeConfig.js +11 -32
- package/build/intl/localeConfig.js.map +1 -1
- package/build/intl/localeObject.js +30 -49
- package/build/intl/localeObject.js.map +1 -1
- package/build/newsroom-context/context.js +18 -34
- package/build/newsroom-context/context.js.map +1 -1
- package/build/newsroom-context/hooks/index.js +11 -27
- package/build/newsroom-context/hooks/index.js.map +1 -1
- package/build/newsroom-context/hooks/useAlgoliaSettings.js +3 -7
- package/build/newsroom-context/hooks/useAlgoliaSettings.js.map +1 -1
- package/build/newsroom-context/hooks/useCategories.js +3 -7
- package/build/newsroom-context/hooks/useCategories.js.map +1 -1
- package/build/newsroom-context/hooks/useCompanyInformation.js +3 -7
- package/build/newsroom-context/hooks/useCompanyInformation.js.map +1 -1
- package/build/newsroom-context/hooks/useCurrentCategory.js +3 -7
- package/build/newsroom-context/hooks/useCurrentCategory.js.map +1 -1
- package/build/newsroom-context/hooks/useCurrentLocale.js +3 -7
- package/build/newsroom-context/hooks/useCurrentLocale.js.map +1 -1
- package/build/newsroom-context/hooks/useCurrentStory.js +3 -7
- package/build/newsroom-context/hooks/useCurrentStory.js.map +1 -1
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js +10 -14
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js.map +1 -1
- package/build/newsroom-context/hooks/useGetTranslationUrl.js +17 -26
- package/build/newsroom-context/hooks/useGetTranslationUrl.js.map +1 -1
- package/build/newsroom-context/hooks/useLanguages.js +3 -7
- package/build/newsroom-context/hooks/useLanguages.js.map +1 -1
- package/build/newsroom-context/hooks/useNewsroom.js +3 -7
- package/build/newsroom-context/hooks/useNewsroom.js.map +1 -1
- package/build/newsroom-context/hooks/useNewsroomContext.js +4 -8
- package/build/newsroom-context/hooks/useNewsroomContext.js.map +1 -1
- package/build/newsroom-context/index.js +2 -21
- package/build/newsroom-context/index.js.map +1 -1
- package/build/sentry/client.d.ts +2 -0
- package/build/sentry/client.js +5 -0
- package/build/sentry/client.js.map +1 -0
- package/build/sentry/common.d.ts +2 -0
- package/build/sentry/common.js +25 -0
- package/build/sentry/common.js.map +1 -0
- package/build/sentry/index.d.ts +2 -0
- package/build/sentry/index.js +3 -0
- package/build/sentry/index.js.map +1 -0
- package/build/sentry/server.d.ts +2 -0
- package/build/sentry/server.js +5 -0
- package/build/sentry/server.js.map +1 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/types.js +1 -2
- package/build/utils/boilerplate.js +3 -9
- package/build/utils/boilerplate.js.map +1 -1
- package/build/utils/constants.js +3 -6
- package/build/utils/constants.js.map +1 -1
- package/build/utils/getAssetsUrl.js +3 -7
- package/build/utils/getAssetsUrl.js.map +1 -1
- package/build/utils/getDataRequestLink.js +3 -7
- package/build/utils/getDataRequestLink.js.map +1 -1
- package/build/utils/getLocalizedCategoryData.js +15 -32
- package/build/utils/getLocalizedCategoryData.js.map +1 -1
- package/build/utils/getNewsroomLogoUrl.js +6 -12
- package/build/utils/getNewsroomLogoUrl.js.map +1 -1
- package/build/utils/getPrivacyPortalUrl.js +3 -7
- package/build/utils/getPrivacyPortalUrl.js.map +1 -1
- package/build/utils/getStoryPublicationDate.js +2 -6
- package/build/utils/getStoryPublicationDate.js.map +1 -1
- package/build/utils/getUploadcareGroupUrl.js +3 -7
- package/build/utils/getUploadcareGroupUrl.js.map +1 -1
- package/build/utils/index.js +10 -26
- package/build/utils/index.js.map +1 -1
- package/build/utils/isEmbargoStory.js +1 -5
- package/build/utils/isEmbargoStory.js.map +1 -1
- package/package.json +2 -1
- package/src/adapter-nextjs/page-props/category.ts +5 -2
- package/src/adapter-nextjs/page-props/gallery.ts +5 -2
- package/src/adapter-nextjs/page-props/galleryAlbum.ts +5 -2
- package/src/adapter-nextjs/page-props/home.ts +5 -2
- package/src/adapter-nextjs/page-props/lib/types.ts +4 -4
- package/src/adapter-nextjs/page-props/search.ts +10 -3
- package/src/adapter-nextjs/page-props/story.ts +5 -2
- package/src/components-nextjs/document.tsx +38 -0
- package/src/components-nextjs/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/sentry/client.ts +7 -0
- package/src/sentry/common.ts +27 -0
- package/src/sentry/index.ts +2 -0
- package/src/sentry/server.ts +7 -0
package/build/intl/locale.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var querystring_1 = require("querystring");
|
|
5
|
-
var localeObject_1 = require("./localeObject");
|
|
6
|
-
exports.DEFAULT_LOCALE = 'en';
|
|
1
|
+
import { stringify } from 'querystring';
|
|
2
|
+
import { LocaleObject } from './localeObject';
|
|
3
|
+
export const DEFAULT_LOCALE = 'en';
|
|
7
4
|
// We use pseudo locale used for localization testing, to reliably determine if we need to fallback to the default newsroom language
|
|
8
|
-
|
|
5
|
+
export const DUMMY_DEFAULT_LOCALE = 'qps-ploc';
|
|
9
6
|
/**
|
|
10
7
|
* This a list of locales that Prezly has translations for. Each code represents a language file in the `@prezly/themes-intl-messages` package.
|
|
11
8
|
* See https://github.com/prezly/themes-intl-messages for more info.
|
|
12
9
|
*/
|
|
13
|
-
|
|
10
|
+
const SUPPORTED_LOCALES = [
|
|
14
11
|
'af',
|
|
15
12
|
'ar',
|
|
16
13
|
'az',
|
|
@@ -63,14 +60,14 @@ var SUPPORTED_LOCALES = [
|
|
|
63
60
|
* Use this function to determine which translations file you should load from `@prezly/themes-intl-mesages` package.
|
|
64
61
|
* See https://github.com/prezly/theme-nextjs-bea/blob/main/utils/lang.ts for a usage example.
|
|
65
62
|
*/
|
|
66
|
-
function getSupportedLocaleIsoCode(locale) {
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
export function getSupportedLocaleIsoCode(locale) {
|
|
64
|
+
const localeIsoCode = locale.toHyphenCode();
|
|
65
|
+
const isSupportedLocale = localeIsoCode.length >= 2 && SUPPORTED_LOCALES.includes(localeIsoCode);
|
|
69
66
|
if (isSupportedLocale) {
|
|
70
67
|
return localeIsoCode;
|
|
71
68
|
}
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
const language = locale.toNeutralLanguageCode();
|
|
70
|
+
const isSupportedLanguage = SUPPORTED_LOCALES.includes(language);
|
|
74
71
|
if (isSupportedLanguage) {
|
|
75
72
|
return language;
|
|
76
73
|
}
|
|
@@ -84,36 +81,33 @@ function getSupportedLocaleIsoCode(locale) {
|
|
|
84
81
|
// This code should never be reached, because locale code check is happening in `LocaleObject.fromAnyCode`
|
|
85
82
|
// eslint-disable-next-line no-console
|
|
86
83
|
console.warn('Unsupported locale provided. Please use `LocaleObject.fromAnyCode` to ensure you are using a correct language code');
|
|
87
|
-
return
|
|
84
|
+
return DEFAULT_LOCALE;
|
|
88
85
|
}
|
|
89
|
-
|
|
90
|
-
function getRedirectToCanonicalLocale(shortestLocaleCode, nextLocaleIsoCode, redirectPath, query) {
|
|
86
|
+
export function getRedirectToCanonicalLocale(shortestLocaleCode, nextLocaleIsoCode, redirectPath, query) {
|
|
91
87
|
// No need to redirect if no particular locale was requested by the application
|
|
92
|
-
if (!nextLocaleIsoCode || nextLocaleIsoCode ===
|
|
88
|
+
if (!nextLocaleIsoCode || nextLocaleIsoCode === DUMMY_DEFAULT_LOCALE) {
|
|
93
89
|
return undefined;
|
|
94
90
|
}
|
|
95
|
-
|
|
96
|
-
?
|
|
91
|
+
const shortestLocaleSlug = shortestLocaleCode
|
|
92
|
+
? LocaleObject.fromAnyCode(shortestLocaleCode).toUrlSlug()
|
|
97
93
|
: shortestLocaleCode;
|
|
98
94
|
if (shortestLocaleSlug !== nextLocaleIsoCode) {
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
const prefixedPath = redirectPath && !redirectPath.startsWith('/') ? `/${redirectPath}` : redirectPath;
|
|
96
|
+
const urlQuery = query ? `?${stringify(query)}` : '';
|
|
101
97
|
return {
|
|
102
98
|
destination: shortestLocaleSlug
|
|
103
|
-
?
|
|
104
|
-
:
|
|
99
|
+
? `/${shortestLocaleSlug}${prefixedPath}${urlQuery}`
|
|
100
|
+
: `${prefixedPath}${urlQuery}`,
|
|
105
101
|
permanent: false,
|
|
106
102
|
};
|
|
107
103
|
}
|
|
108
104
|
return undefined;
|
|
109
105
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
var neutralLanguageCode = locale.toNeutralLanguageCode();
|
|
106
|
+
export function getLocaleDirection(locale) {
|
|
107
|
+
const neutralLanguageCode = locale.toNeutralLanguageCode();
|
|
113
108
|
if (['ar', 'he', 'ur'].includes(neutralLanguageCode)) {
|
|
114
109
|
return 'rtl';
|
|
115
110
|
}
|
|
116
111
|
return 'ltr';
|
|
117
112
|
}
|
|
118
|
-
exports.getLocaleDirection = getLocaleDirection;
|
|
119
113
|
//# sourceMappingURL=locale.js.map
|
package/build/intl/locale.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale.js","sourceRoot":"","sources":["../../src/intl/locale.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"locale.js","sourceRoot":"","sources":["../../src/intl/locale.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,41 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
-
if (ar || !(i in from)) {
|
|
21
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
-
ar[i] = from[i];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
-
};
|
|
27
2
|
/**
|
|
28
3
|
* This list is pulled from the main Prezly application. The underscores are replaced with dashes.
|
|
29
4
|
* Together with permutation performed lower in the code,
|
|
30
5
|
* the exported list represents all of the possible locale codes that Next.js theme application might accept.
|
|
31
6
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
7
|
+
const supportedLocales = require('./localeList');
|
|
8
|
+
const lowercaseLocales = supportedLocales.map((l) => l.toLowerCase());
|
|
34
9
|
// Get all permutations for the shorter locale codes supported by Prezly (e.g. short region codes and neutral language codes)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
.
|
|
38
|
-
|
|
39
|
-
|
|
10
|
+
const lowercaseLocalPermutations = Array.from(new Set([
|
|
11
|
+
...lowercaseLocales,
|
|
12
|
+
...lowercaseLocales.map((code) => code.split('-')[0]),
|
|
13
|
+
...lowercaseLocales
|
|
14
|
+
.map((code) => code.split('-')[1])
|
|
15
|
+
.filter(Boolean)
|
|
16
|
+
// Remove number-only codes from possible permutations (like `419` for `es-419`)
|
|
17
|
+
.filter((code) => Number.isNaN(Number(code))),
|
|
18
|
+
])).sort();
|
|
40
19
|
module.exports = lowercaseLocalPermutations;
|
|
41
20
|
//# sourceMappingURL=localeConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localeConfig.js","sourceRoot":"","sources":["../../src/intl/localeConfig.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"localeConfig.js","sourceRoot":"","sources":["../../src/intl/localeConfig.js"],"names":[],"mappings":";AAAA;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAEjD,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AAEtE,6HAA6H;AAC7H,MAAM,0BAA0B,GAAG,KAAK,CAAC,IAAI,CACzC,IAAI,GAAG,CAAC;IACJ,GAAG,gBAAgB;IACnB,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACrD,GAAG,gBAAgB;SACd,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SACjC,MAAM,CAAC,OAAO,CAAC;QAChB,gFAAgF;SAC/E,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;CACpD,CAAC,CACL,CAAC,IAAI,EAAE,CAAC;AAET,MAAM,CAAC,OAAO,GAAG,0BAA0B,CAAC"}
|
|
@@ -1,40 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.LocaleObject = void 0;
|
|
23
|
-
var localeConfig_1 = __importDefault(require("./localeConfig"));
|
|
1
|
+
import localeConfig from './localeConfig';
|
|
24
2
|
/**
|
|
25
3
|
* This class is created to simplify working with locales and transforming between different locale code formats.
|
|
26
4
|
* Prezly API uses underscore-codes, while most frontend application tend to use hyphen-codes or slugs.
|
|
27
5
|
* Note that `fromAnyCode` constructor only accepts locales supported by Prezly backend. See `localeConfig` for reference.
|
|
28
6
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
7
|
+
export class LocaleObject {
|
|
8
|
+
/**
|
|
9
|
+
* Hyphen-separated locale code.
|
|
10
|
+
* Examples: `nl-BE`, `en-US`, `fr`, `fil`
|
|
11
|
+
*/
|
|
12
|
+
localeCode;
|
|
13
|
+
constructor(localeCode) {
|
|
31
14
|
if (!/^([a-z]{2,3})(-[a-z\d]{1,4})?$/i.test(localeCode)) {
|
|
32
15
|
throw new Error('Invalid locale code provided!');
|
|
33
16
|
}
|
|
34
|
-
|
|
17
|
+
const [language, region] = localeCode.split('-');
|
|
35
18
|
if (region) {
|
|
36
19
|
// Workaround for `zh-Hant` locale, which is the only locale with non-uppercase region part
|
|
37
|
-
|
|
20
|
+
const regionSuffix = region === 'hant' ? 'Hant' : region.toUpperCase();
|
|
38
21
|
this.localeCode = [language, regionSuffix].join('-');
|
|
39
22
|
}
|
|
40
23
|
else {
|
|
@@ -48,56 +31,54 @@ var LocaleObject = /** @class */ (function () {
|
|
|
48
31
|
* - Underscore-codes: `nl_BE`, `en_US`, `fr`, `fil`
|
|
49
32
|
* - Slugs: `nl-be`, `en-us`, `fr`, `fil`
|
|
50
33
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
34
|
+
static fromAnyCode(localeCode) {
|
|
35
|
+
const lowercaseCode = localeCode.toLowerCase().replace('_', '-');
|
|
36
|
+
const foundCode = localeConfig.find((code) => code === lowercaseCode);
|
|
54
37
|
if (!foundCode) {
|
|
55
|
-
throw new Error(
|
|
38
|
+
throw new Error(`Unsupported locale code provided: "${lowercaseCode}"`);
|
|
56
39
|
}
|
|
57
40
|
return new LocaleObject(foundCode);
|
|
58
|
-
}
|
|
41
|
+
}
|
|
59
42
|
/**
|
|
60
43
|
* @returns Code formatted into hyphen format: `nl-BE`, `en-US`, `fr`, `fil`
|
|
61
44
|
*/
|
|
62
|
-
|
|
45
|
+
toHyphenCode() {
|
|
63
46
|
return this.localeCode;
|
|
64
|
-
}
|
|
47
|
+
}
|
|
65
48
|
/**
|
|
66
49
|
* @returns Code formatted into underscore format, as expected by Prezly API: `nl_BE`, `en_US`, `fr`, `fil`
|
|
67
50
|
*/
|
|
68
|
-
|
|
51
|
+
toUnderscoreCode() {
|
|
69
52
|
return this.localeCode.replace('-', '_');
|
|
70
|
-
}
|
|
53
|
+
}
|
|
71
54
|
/**
|
|
72
55
|
* @returns Code formatted to a URL-friendly lowercase slug format: `nl-be`, `en-us`, `fr`, `fil`
|
|
73
56
|
*/
|
|
74
|
-
|
|
57
|
+
toUrlSlug() {
|
|
75
58
|
return this.localeCode.toLowerCase();
|
|
76
|
-
}
|
|
59
|
+
}
|
|
77
60
|
/**
|
|
78
61
|
* @returns Only the language part of the code without culture/region part: `nl`, `en`, `fr`
|
|
79
62
|
*/
|
|
80
|
-
|
|
81
|
-
|
|
63
|
+
toNeutralLanguageCode() {
|
|
64
|
+
const [language] = this.localeCode.split('-');
|
|
82
65
|
return language;
|
|
83
|
-
}
|
|
66
|
+
}
|
|
84
67
|
/**
|
|
85
68
|
* @returns Only the culture/regtion part without the language part: `be`, `us`, `fr`
|
|
86
69
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
70
|
+
toRegionCode() {
|
|
71
|
+
const [language, region] = this.localeCode.split('-');
|
|
89
72
|
if (!region) {
|
|
90
73
|
return language.toUpperCase();
|
|
91
74
|
}
|
|
92
75
|
return region.toUpperCase();
|
|
93
|
-
}
|
|
76
|
+
}
|
|
94
77
|
/**
|
|
95
78
|
* Check if two LocaleObject instances are representing the same locale code.
|
|
96
79
|
*/
|
|
97
|
-
|
|
80
|
+
isEqual(anotherLocale) {
|
|
98
81
|
return anotherLocale.toHyphenCode() === this.localeCode;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
}());
|
|
102
|
-
exports.LocaleObject = LocaleObject;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
103
84
|
//# sourceMappingURL=localeObject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localeObject.js","sourceRoot":"","sources":["../../src/intl/localeObject.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"localeObject.js","sourceRoot":"","sources":["../../src/intl/localeObject.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C;;;;GAIG;AACH,MAAM,OAAO,YAAY;IACrB;;;OAGG;IACK,UAAU,CAAS;IAE3B,YAAoB,UAAkB;QAClC,IAAI,CAAC,iCAAiC,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;YACrD,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;SACpD;QAED,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAEjD,IAAI,MAAM,EAAE;YACR,2FAA2F;YAC3F,MAAM,YAAY,GAAG,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;YAEvE,IAAI,CAAC,UAAU,GAAG,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACxD;aAAM;YACH,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC;SAC9B;IACL,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,WAAW,CAAC,UAAkB;QACxC,MAAM,aAAa,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACjE,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC;QAEtE,IAAI,CAAC,SAAS,EAAE;YACZ,MAAM,IAAI,KAAK,CAAC,sCAAsC,aAAa,GAAG,CAAC,CAAC;SAC3E;QAED,OAAO,IAAI,YAAY,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACI,YAAY;QACf,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED;;OAEG;IACI,gBAAgB;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACI,SAAS;QACZ,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;IACzC,CAAC;IAED;;OAEG;IACI,qBAAqB;QACxB,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE9C,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED;;OAEG;IACI,YAAY;QACf,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAEtD,IAAI,CAAC,MAAM,EAAE;YACT,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC;SACjC;QAED,OAAO,MAAM,CAAC,WAAW,EAAE,CAAC;IAChC,CAAC;IAED;;OAEG;IACI,OAAO,CAAC,aAA2B;QACtC,OAAO,aAAa,CAAC,YAAY,EAAE,KAAK,IAAI,CAAC,UAAU,CAAC;IAC5D,CAAC;CACJ"}
|
|
@@ -1,40 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.NewsroomContextProvider = exports.NewsroomContext = void 0;
|
|
15
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
-
var react_1 = require("react");
|
|
17
|
-
var intl_1 = require("../intl");
|
|
18
|
-
exports.NewsroomContext = (0, react_1.createContext)(undefined);
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useMemo } from 'react';
|
|
3
|
+
import { DEFAULT_LOCALE, LocaleObject } from '../intl';
|
|
4
|
+
export const NewsroomContext = createContext(undefined);
|
|
19
5
|
/**
|
|
20
6
|
* This context provides common Newsroom information retrieved by `getNewsroomServerSideProps` helper.
|
|
21
7
|
* Please refer to the `NewsroomContextType` definition for more info on what's exposed from the context.
|
|
22
8
|
*/
|
|
23
|
-
function NewsroomContextProvider(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} }, { children: children })));
|
|
9
|
+
export function NewsroomContextProvider({ categories, contacts, newsroom, currentCategory, currentStory, companyInformation, languages, localeCode, themePreset, algoliaSettings, children, }) {
|
|
10
|
+
const locale = useMemo(() => LocaleObject.fromAnyCode(localeCode || DEFAULT_LOCALE), [localeCode]);
|
|
11
|
+
return (_jsx(NewsroomContext.Provider, { value: {
|
|
12
|
+
categories,
|
|
13
|
+
contacts,
|
|
14
|
+
newsroom,
|
|
15
|
+
currentCategory,
|
|
16
|
+
currentStory,
|
|
17
|
+
companyInformation,
|
|
18
|
+
languages,
|
|
19
|
+
locale,
|
|
20
|
+
themePreset,
|
|
21
|
+
algoliaSettings,
|
|
22
|
+
}, children: children }));
|
|
38
23
|
}
|
|
39
|
-
exports.NewsroomContextProvider = NewsroomContextProvider;
|
|
40
24
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/newsroom-context/context.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/newsroom-context/context.tsx"],"names":[],"mappings":";AAUA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAG/C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAoDvD,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAkC,SAAS,CAAC,CAAC;AAEzF;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,EACpC,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,WAAW,EACX,eAAe,EACf,QAAQ,GAC8B;IACtC,MAAM,MAAM,GAAG,OAAO,CAClB,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,CAAC,UAAU,IAAI,cAAc,CAAC,EAC5D,CAAC,UAAU,CAAC,CACf,CAAC;IAEF,OAAO,CACH,KAAC,eAAe,CAAC,QAAQ,IACrB,KAAK,EAAE;YACH,UAAU;YACV,QAAQ;YACR,QAAQ;YACR,eAAe;YACf,YAAY;YACZ,kBAAkB;YAClB,SAAS;YACT,MAAM;YACN,WAAW;YACX,eAAe;SAClB,YAEA,QAAQ,GACc,CAC9B,CAAC;AACN,CAAC"}
|
|
@@ -1,28 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./useAlgoliaSettings"), exports);
|
|
18
|
-
__exportStar(require("./useCategories"), exports);
|
|
19
|
-
__exportStar(require("./useCompanyInformation"), exports);
|
|
20
|
-
__exportStar(require("./useCurrentCategory"), exports);
|
|
21
|
-
__exportStar(require("./useCurrentLocale"), exports);
|
|
22
|
-
__exportStar(require("./useCurrentStory"), exports);
|
|
23
|
-
__exportStar(require("./useGetLinkLocaleSlug"), exports);
|
|
24
|
-
__exportStar(require("./useGetTranslationUrl"), exports);
|
|
25
|
-
__exportStar(require("./useLanguages"), exports);
|
|
26
|
-
__exportStar(require("./useNewsroom"), exports);
|
|
27
|
-
__exportStar(require("./useNewsroomContext"), exports);
|
|
1
|
+
export * from './useAlgoliaSettings';
|
|
2
|
+
export * from './useCategories';
|
|
3
|
+
export * from './useCompanyInformation';
|
|
4
|
+
export * from './useCurrentCategory';
|
|
5
|
+
export * from './useCurrentLocale';
|
|
6
|
+
export * from './useCurrentStory';
|
|
7
|
+
export * from './useGetLinkLocaleSlug';
|
|
8
|
+
export * from './useGetTranslationUrl';
|
|
9
|
+
export * from './useLanguages';
|
|
10
|
+
export * from './useNewsroom';
|
|
11
|
+
export * from './useNewsroomContext';
|
|
28
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var useNewsroomContext_1 = require("./useNewsroomContext");
|
|
5
|
-
function useAlgoliaSettings() {
|
|
6
|
-
var context = (0, useNewsroomContext_1.useNewsroomContext)();
|
|
1
|
+
import { useNewsroomContext } from './useNewsroomContext';
|
|
2
|
+
export function useAlgoliaSettings() {
|
|
3
|
+
const context = useNewsroomContext();
|
|
7
4
|
return context.algoliaSettings;
|
|
8
5
|
}
|
|
9
|
-
exports.useAlgoliaSettings = useAlgoliaSettings;
|
|
10
6
|
//# sourceMappingURL=useAlgoliaSettings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAlgoliaSettings.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useAlgoliaSettings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAlgoliaSettings.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useAlgoliaSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,UAAU,kBAAkB;IAC9B,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IAErC,OAAO,OAAO,CAAC,eAAe,CAAC;AACnC,CAAC"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var useNewsroomContext_1 = require("./useNewsroomContext");
|
|
5
|
-
function useCategories() {
|
|
6
|
-
var context = (0, useNewsroomContext_1.useNewsroomContext)();
|
|
1
|
+
import { useNewsroomContext } from './useNewsroomContext';
|
|
2
|
+
export function useCategories() {
|
|
3
|
+
const context = useNewsroomContext();
|
|
7
4
|
return context.categories;
|
|
8
5
|
}
|
|
9
|
-
exports.useCategories = useCategories;
|
|
10
6
|
//# sourceMappingURL=useCategories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCategories.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useCategories.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCategories.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useCategories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,UAAU,aAAa;IACzB,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IAErC,OAAO,OAAO,CAAC,UAAU,CAAC;AAC9B,CAAC"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var useNewsroomContext_1 = require("./useNewsroomContext");
|
|
5
|
-
function useCompanyInformation() {
|
|
6
|
-
var context = (0, useNewsroomContext_1.useNewsroomContext)();
|
|
1
|
+
import { useNewsroomContext } from './useNewsroomContext';
|
|
2
|
+
export function useCompanyInformation() {
|
|
3
|
+
const context = useNewsroomContext();
|
|
7
4
|
return context.companyInformation;
|
|
8
5
|
}
|
|
9
|
-
exports.useCompanyInformation = useCompanyInformation;
|
|
10
6
|
//# sourceMappingURL=useCompanyInformation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCompanyInformation.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useCompanyInformation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCompanyInformation.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useCompanyInformation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,UAAU,qBAAqB;IACjC,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IAErC,OAAO,OAAO,CAAC,kBAAkB,CAAC;AACtC,CAAC"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var useNewsroomContext_1 = require("./useNewsroomContext");
|
|
5
|
-
function useCurrentCategory() {
|
|
6
|
-
var context = (0, useNewsroomContext_1.useNewsroomContext)();
|
|
1
|
+
import { useNewsroomContext } from './useNewsroomContext';
|
|
2
|
+
export function useCurrentCategory() {
|
|
3
|
+
const context = useNewsroomContext();
|
|
7
4
|
return context.currentCategory;
|
|
8
5
|
}
|
|
9
|
-
exports.useCurrentCategory = useCurrentCategory;
|
|
10
6
|
//# sourceMappingURL=useCurrentCategory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrentCategory.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useCurrentCategory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCurrentCategory.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useCurrentCategory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,UAAU,kBAAkB;IAC9B,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IAErC,OAAO,OAAO,CAAC,eAAe,CAAC;AACnC,CAAC"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var useNewsroomContext_1 = require("./useNewsroomContext");
|
|
5
|
-
function useCurrentLocale() {
|
|
6
|
-
var context = (0, useNewsroomContext_1.useNewsroomContext)();
|
|
1
|
+
import { useNewsroomContext } from './useNewsroomContext';
|
|
2
|
+
export function useCurrentLocale() {
|
|
3
|
+
const context = useNewsroomContext();
|
|
7
4
|
return context.locale;
|
|
8
5
|
}
|
|
9
|
-
exports.useCurrentLocale = useCurrentLocale;
|
|
10
6
|
//# sourceMappingURL=useCurrentLocale.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrentLocale.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useCurrentLocale.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCurrentLocale.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useCurrentLocale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,UAAU,gBAAgB;IAC5B,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IAErC,OAAO,OAAO,CAAC,MAAM,CAAC;AAC1B,CAAC"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var useNewsroomContext_1 = require("./useNewsroomContext");
|
|
5
|
-
function useCurrentStory() {
|
|
6
|
-
var context = (0, useNewsroomContext_1.useNewsroomContext)();
|
|
1
|
+
import { useNewsroomContext } from './useNewsroomContext';
|
|
2
|
+
export function useCurrentStory() {
|
|
3
|
+
const context = useNewsroomContext();
|
|
7
4
|
return context.currentStory;
|
|
8
5
|
}
|
|
9
|
-
exports.useCurrentStory = useCurrentStory;
|
|
10
6
|
//# sourceMappingURL=useCurrentStory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrentStory.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useCurrentStory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCurrentStory.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useCurrentStory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,UAAU,eAAe;IAC3B,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IAErC,OAAO,OAAO,CAAC,YAAY,CAAC;AAChC,CAAC"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var intl_1 = require("../../intl");
|
|
6
|
-
var useCurrentLocale_1 = require("./useCurrentLocale");
|
|
7
|
-
var useLanguages_1 = require("./useLanguages");
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { getShortestLocaleCode, LocaleObject } from '../../intl';
|
|
3
|
+
import { useCurrentLocale } from './useCurrentLocale';
|
|
4
|
+
import { useLanguages } from './useLanguages';
|
|
8
5
|
/**
|
|
9
6
|
* Determines correct locale slug for the link (trying to shorten the locale code if possible).
|
|
10
7
|
* E.g. if newsroom has a single locale for Dutch (`nl_BE`), it will be shortened to `nl`.
|
|
@@ -12,18 +9,17 @@ var useLanguages_1 = require("./useLanguages");
|
|
|
12
9
|
* `false` means that a default locale should be used (no locale in URL required).
|
|
13
10
|
*/
|
|
14
11
|
function getLinkLocaleSlug(languages, locale) {
|
|
15
|
-
|
|
12
|
+
const shortestLocaleCode = getShortestLocaleCode(languages, locale);
|
|
16
13
|
// When navigating to default language, we don't append the locale to the URL.
|
|
17
14
|
if (!shortestLocaleCode) {
|
|
18
15
|
return shortestLocaleCode;
|
|
19
16
|
}
|
|
20
|
-
return
|
|
17
|
+
return LocaleObject.fromAnyCode(shortestLocaleCode).toUrlSlug();
|
|
21
18
|
}
|
|
22
|
-
function useGetLinkLocaleSlug() {
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
export function useGetLinkLocaleSlug() {
|
|
20
|
+
const currentLocale = useCurrentLocale();
|
|
21
|
+
const languages = useLanguages();
|
|
25
22
|
// The `locale` parameter is mainly used for Language Dropdown
|
|
26
|
-
return
|
|
23
|
+
return useCallback((locale) => getLinkLocaleSlug(languages, locale || currentLocale), [languages, currentLocale]);
|
|
27
24
|
}
|
|
28
|
-
exports.useGetLinkLocaleSlug = useGetLinkLocaleSlug;
|
|
29
25
|
//# sourceMappingURL=useGetLinkLocaleSlug.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetLinkLocaleSlug.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useGetLinkLocaleSlug.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useGetLinkLocaleSlug.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useGetLinkLocaleSlug.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;;GAKG;AACH,SAAS,iBAAiB,CACtB,SAAqC,EACrC,MAAoB;IAEpB,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACpE,8EAA8E;IAC9E,IAAI,CAAC,kBAAkB,EAAE;QACrB,OAAO,kBAAkB,CAAC;KAC7B;IAED,OAAO,YAAY,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,SAAS,EAAE,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,oBAAoB;IAChC,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;IACzC,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IAEjC,8DAA8D;IAC9D,OAAO,WAAW,CACd,CAAC,MAAqB,EAAE,EAAE,CAAC,iBAAiB,CAAC,SAAS,EAAE,MAAM,IAAI,aAAa,CAAC,EAChF,CAAC,SAAS,EAAE,aAAa,CAAC,CAC7B,CAAC;AACN,CAAC"}
|