@prezly/theme-kit-core 7.1.0 → 8.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/boilerplate.cjs +17 -0
- package/build/boilerplate.d.ts +8 -0
- package/build/boilerplate.mjs +9 -0
- package/build/constants.cjs +11 -0
- package/build/{utils/constants.d.ts → constants.d.ts} +2 -1
- package/build/constants.mjs +5 -0
- package/build/content-delivery/ContentDelivery.cjs +348 -0
- package/build/content-delivery/ContentDelivery.d.ts +8 -4
- package/build/content-delivery/ContentDelivery.mjs +342 -0
- package/build/content-delivery/cache/index.cjs +35 -0
- package/build/content-delivery/cache/index.d.ts +3 -0
- package/build/content-delivery/cache/index.mjs +3 -0
- package/build/content-delivery/cache/memory.cjs +65 -0
- package/build/content-delivery/cache/memory.d.ts +3 -0
- package/build/content-delivery/cache/memory.mjs +58 -0
- package/build/content-delivery/cache/memory.test.cjs +54 -0
- package/build/content-delivery/cache/memory.test.mjs +52 -0
- package/build/content-delivery/cache/stacked.cjs +32 -0
- package/build/content-delivery/cache/stacked.d.ts +2 -0
- package/build/content-delivery/cache/stacked.mjs +26 -0
- package/build/content-delivery/cache/type.cjs +1 -0
- package/build/content-delivery/cache/type.d.ts +8 -0
- package/build/content-delivery/cache/type.mjs +1 -0
- package/build/content-delivery/index.cjs +27 -0
- package/build/content-delivery/index.d.ts +2 -1
- package/build/content-delivery/index.mjs +2 -0
- package/build/environment.cjs +42 -0
- package/build/environment.d.ts +2 -0
- package/build/environment.mjs +36 -0
- package/build/galleries.cjs +38 -0
- package/build/galleries.d.ts +11 -0
- package/build/galleries.mjs +30 -0
- package/build/http/HttpClient.cjs +66 -0
- package/build/http/HttpClient.d.ts +20 -0
- package/build/http/HttpClient.mjs +59 -0
- package/build/http/index.cjs +10 -0
- package/build/http/index.d.ts +1 -0
- package/build/http/index.mjs +2 -0
- package/build/index.cjs +88 -0
- package/build/index.d.ts +15 -4
- package/build/index.mjs +26 -0
- package/build/intl/getLanguageDisplayName.cjs +37 -0
- package/build/intl/getLanguageDisplayName.d.ts +20 -0
- package/build/intl/getLanguageDisplayName.mjs +32 -0
- package/build/intl/getLanguageDisplayName.test.cjs +46 -0
- package/build/intl/getLanguageDisplayName.test.mjs +44 -0
- package/build/intl/index.cjs +12 -0
- package/build/intl/index.d.ts +1 -5
- package/build/intl/index.mjs +1 -0
- package/build/metadata/getAlternateLanguageLinks.cjs +76 -0
- package/build/{seo → metadata}/getAlternateLanguageLinks.d.ts +2 -2
- package/build/metadata/getAlternateLanguageLinks.mjs +72 -0
- package/build/metadata/getAlternateLanguageLinks.test.cjs +198 -0
- package/build/metadata/getAlternateLanguageLinks.test.mjs +196 -0
- package/build/metadata/index.cjs +12 -0
- package/build/metadata/index.d.ts +2 -0
- package/build/metadata/index.mjs +1 -0
- package/build/metadata/types.cjs +1 -0
- package/build/metadata/types.d.ts +6 -0
- package/build/metadata/types.mjs +1 -0
- package/build/newsrooms.cjs +36 -0
- package/build/newsrooms.d.ts +5 -0
- package/build/newsrooms.mjs +28 -0
- package/build/privacy-portal.cjs +28 -0
- package/build/privacy-portal.d.ts +9 -0
- package/build/privacy-portal.mjs +21 -0
- package/build/resolvable.cjs +38 -0
- package/build/resolvable.d.ts +71 -0
- package/build/resolvable.mjs +32 -0
- package/build/routing/Route.cjs +46 -0
- package/build/routing/Route.d.ts +37 -0
- package/build/routing/Route.mjs +40 -0
- package/build/routing/Router.cjs +51 -0
- package/build/routing/Router.d.ts +23 -0
- package/build/routing/Router.mjs +45 -0
- package/build/routing/Routing.cjs +24 -0
- package/build/routing/Routing.d.ts +1 -0
- package/build/routing/Routing.mjs +2 -0
- package/build/routing/UrlGenerator.cjs +13 -0
- package/build/routing/UrlGenerator.d.ts +39 -0
- package/build/routing/UrlGenerator.mjs +7 -0
- package/build/routing/index.cjs +24 -0
- package/build/routing/index.d.ts +4 -0
- package/build/routing/index.mjs +4 -0
- package/build/routing/types.cjs +1 -0
- package/build/routing/types.d.ts +14 -0
- package/build/routing/types.mjs +1 -0
- package/build/routing/utils/generateUrlFromPattern.cjs +52 -0
- package/build/routing/utils/generateUrlFromPattern.d.ts +12 -0
- package/build/routing/utils/generateUrlFromPattern.mjs +47 -0
- package/build/routing/utils/generateUrlFromPattern.test.cjs +44 -0
- package/build/routing/utils/generateUrlFromPattern.test.mjs +42 -0
- package/build/routing/utils/getShortestLocaleSlug.cjs +60 -0
- package/build/routing/utils/getShortestLocaleSlug.d.ts +11 -0
- package/build/routing/utils/getShortestLocaleSlug.mjs +53 -0
- package/build/routing/utils/getShortestLocaleSlug.test.cjs +37 -0
- package/build/routing/utils/getShortestLocaleSlug.test.mjs +35 -0
- package/build/routing/utils/index.cjs +40 -0
- package/build/routing/utils/index.d.ts +5 -0
- package/build/routing/utils/index.mjs +5 -0
- package/build/routing/utils/isNumberCode.cjs +12 -0
- package/build/routing/utils/isNumberCode.d.ts +4 -0
- package/build/routing/utils/isNumberCode.mjs +6 -0
- package/build/routing/utils/matchLocaleSlug.cjs +41 -0
- package/build/routing/utils/matchLocaleSlug.d.ts +15 -0
- package/build/routing/utils/matchLocaleSlug.mjs +34 -0
- package/build/routing/utils/matchLocaleSlug.test.cjs +43 -0
- package/build/routing/utils/matchLocaleSlug.test.mjs +40 -0
- package/build/routing/utils/normalizeUrl.cjs +9 -0
- package/build/routing/utils/normalizeUrl.d.ts +1 -0
- package/build/routing/utils/normalizeUrl.mjs +3 -0
- package/build/search.cjs +1 -0
- package/build/{types.d.ts → search.d.ts} +3 -3
- package/build/search.mjs +1 -0
- package/build/sitemap/build.cjs +33 -0
- package/build/sitemap/build.d.ts +6 -0
- package/build/sitemap/build.mjs +27 -0
- package/build/sitemap/generate.cjs +192 -0
- package/build/sitemap/generate.d.ts +37 -0
- package/build/sitemap/generate.mjs +183 -0
- package/build/sitemap/index.cjs +38 -0
- package/build/sitemap/index.d.ts +4 -0
- package/build/sitemap/index.mjs +3 -0
- package/build/sitemap/stringify.cjs +24 -0
- package/build/sitemap/stringify.d.ts +2 -0
- package/build/sitemap/stringify.mjs +18 -0
- package/build/sitemap/types.cjs +1 -0
- package/build/sitemap/types.d.ts +67 -0
- package/build/sitemap/types.mjs +1 -0
- package/build/uploads.cjs +14 -0
- package/build/{utils/getAssetsUrl.d.ts → uploads.d.ts} +1 -1
- package/build/uploads.mjs +8 -0
- package/build/uploads.test.cjs +10 -0
- package/build/uploads.test.mjs +8 -0
- package/package.json +23 -26
- package/build/content-delivery/ContentDelivery.js +0 -238
- package/build/content-delivery/ContentDelivery.js.map +0 -1
- package/build/content-delivery/index.js +0 -28
- package/build/content-delivery/index.js.map +0 -1
- package/build/data-fetching/api/index.d.ts +0 -1
- package/build/data-fetching/api/index.js +0 -6
- package/build/data-fetching/api/index.js.map +0 -1
- package/build/data-fetching/api/initContentDeliveryClient.d.ts +0 -4
- package/build/data-fetching/api/initContentDeliveryClient.js +0 -25
- package/build/data-fetching/api/initContentDeliveryClient.js.map +0 -1
- package/build/data-fetching/index.d.ts +0 -3
- package/build/data-fetching/index.js +0 -20
- package/build/data-fetching/index.js.map +0 -1
- package/build/data-fetching/lib/getAlgoliaSettings.d.ts +0 -4
- package/build/data-fetching/lib/getAlgoliaSettings.js +0 -21
- package/build/data-fetching/lib/getAlgoliaSettings.js.map +0 -1
- package/build/data-fetching/lib/getEnvVariables.d.ts +0 -4
- package/build/data-fetching/lib/getEnvVariables.js +0 -43
- package/build/data-fetching/lib/getEnvVariables.js.map +0 -1
- package/build/data-fetching/lib/index.d.ts +0 -3
- package/build/data-fetching/lib/index.js +0 -10
- package/build/data-fetching/lib/index.js.map +0 -1
- package/build/data-fetching/lib/isUuid.d.ts +0 -1
- package/build/data-fetching/lib/isUuid.js +0 -9
- package/build/data-fetching/lib/isUuid.js.map +0 -1
- package/build/data-fetching/types.d.ts +0 -13
- package/build/data-fetching/types.js +0 -3
- package/build/data-fetching/types.js.map +0 -1
- package/build/index.js +0 -21
- package/build/index.js.map +0 -1
- package/build/intl/getFallbackLocale.d.ts +0 -10
- package/build/intl/getFallbackLocale.js +0 -24
- package/build/intl/getFallbackLocale.js.map +0 -1
- package/build/intl/index.js +0 -27
- package/build/intl/index.js.map +0 -1
- package/build/intl/languages.d.ts +0 -57
- package/build/intl/languages.js +0 -191
- package/build/intl/languages.js.map +0 -1
- package/build/intl/locale.d.ts +0 -11
- package/build/intl/locale.js +0 -41
- package/build/intl/locale.js.map +0 -1
- package/build/intl/localeConfig.d.ts +0 -2
- package/build/intl/localeConfig.js +0 -22
- package/build/intl/localeConfig.js.map +0 -1
- package/build/intl/localeList.d.ts +0 -2
- package/build/intl/localeList.js +0 -114
- package/build/intl/localeList.js.map +0 -1
- package/build/intl/localeObject.d.ts +0 -51
- package/build/intl/localeObject.js +0 -98
- package/build/intl/localeObject.js.map +0 -1
- package/build/seo/getAlternateLanguageLinks.js +0 -85
- package/build/seo/getAlternateLanguageLinks.js.map +0 -1
- package/build/seo/index.d.ts +0 -2
- package/build/seo/index.js +0 -19
- package/build/seo/index.js.map +0 -1
- package/build/seo/types.d.ts +0 -4
- package/build/seo/types.js +0 -3
- package/build/seo/types.js.map +0 -1
- package/build/seo/utils/bindLanguagesWithLocales.d.ts +0 -11
- package/build/seo/utils/bindLanguagesWithLocales.js +0 -23
- package/build/seo/utils/bindLanguagesWithLocales.js.map +0 -1
- package/build/seo/utils/createAlternateLanguageLink.d.ts +0 -5
- package/build/seo/utils/createAlternateLanguageLink.js +0 -15
- package/build/seo/utils/createAlternateLanguageLink.js.map +0 -1
- package/build/seo/utils/index.d.ts +0 -2
- package/build/seo/utils/index.js +0 -8
- package/build/seo/utils/index.js.map +0 -1
- package/build/server.d.ts +0 -2
- package/build/server.js +0 -21
- package/build/server.js.map +0 -1
- package/build/types.js +0 -3
- package/build/types.js.map +0 -1
- package/build/utils/assertServerEnv.d.ts +0 -1
- package/build/utils/assertServerEnv.js +0 -10
- package/build/utils/assertServerEnv.js.map +0 -1
- package/build/utils/boilerplate.d.ts +0 -8
- package/build/utils/boilerplate.js +0 -27
- package/build/utils/boilerplate.js.map +0 -1
- package/build/utils/constants.js +0 -8
- package/build/utils/constants.js.map +0 -1
- package/build/utils/getAssetsUrl.js +0 -13
- package/build/utils/getAssetsUrl.js.map +0 -1
- package/build/utils/getDataRequestLink.d.ts +0 -3
- package/build/utils/getDataRequestLink.js +0 -12
- package/build/utils/getDataRequestLink.js.map +0 -1
- package/build/utils/getGalleryThumbnail.d.ts +0 -2
- package/build/utils/getGalleryThumbnail.js +0 -15
- package/build/utils/getGalleryThumbnail.js.map +0 -1
- package/build/utils/getLocalizedCategoryData.d.ts +0 -12
- package/build/utils/getLocalizedCategoryData.js +0 -34
- package/build/utils/getLocalizedCategoryData.js.map +0 -1
- package/build/utils/getNewsroomLogoUrl.d.ts +0 -5
- package/build/utils/getNewsroomLogoUrl.js +0 -30
- package/build/utils/getNewsroomLogoUrl.js.map +0 -1
- package/build/utils/getPrivacyPortalUrl.d.ts +0 -8
- package/build/utils/getPrivacyPortalUrl.js +0 -13
- package/build/utils/getPrivacyPortalUrl.js.map +0 -1
- package/build/utils/getStoryPublicationDate.d.ts +0 -3
- package/build/utils/getStoryPublicationDate.js +0 -14
- package/build/utils/getStoryPublicationDate.js.map +0 -1
- package/build/utils/getUploadcareGroupUrl.d.ts +0 -8
- package/build/utils/getUploadcareGroupUrl.js +0 -17
- package/build/utils/getUploadcareGroupUrl.js.map +0 -1
- package/build/utils/index.d.ts +0 -14
- package/build/utils/index.js +0 -31
- package/build/utils/index.js.map +0 -1
- package/build/utils/isEmbargoStory.d.ts +0 -6
- package/build/utils/isEmbargoStory.js +0 -9
- package/build/utils/isEmbargoStory.js.map +0 -1
- package/build/utils/isGalleryEmpty.d.ts +0 -2
- package/build/utils/isGalleryEmpty.js +0 -8
- package/build/utils/isGalleryEmpty.js.map +0 -1
- package/build/utils/sdkHelpers.d.ts +0 -32
- package/build/utils/sdkHelpers.js +0 -42
- package/build/utils/sdkHelpers.js.map +0 -1
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAlgoliaSettings = void 0;
|
|
4
|
-
const utils_1 = require("../../utils");
|
|
5
|
-
const getEnvVariables_1 = require("./getEnvVariables");
|
|
6
|
-
function getAlgoliaSettings(req) {
|
|
7
|
-
(0, utils_1.assertServerEnv)('getAlgoliaSettings');
|
|
8
|
-
// `getEnvVariables` handles both cases for envs parsing - .env and request headers
|
|
9
|
-
const { ALGOLIA_API_KEY = '', ALGOLIA_APP_ID = 'UI4CNRAHQB', ALGOLIA_INDEX = 'public_stories_prod', } = (0, getEnvVariables_1.getEnvVariables)(req);
|
|
10
|
-
if (!ALGOLIA_API_KEY) {
|
|
11
|
-
// eslint-disable-next-line no-console
|
|
12
|
-
console.error('"ALGOLIA_API_KEY" is not set in env variables. Search will not be enabled');
|
|
13
|
-
}
|
|
14
|
-
return {
|
|
15
|
-
ALGOLIA_API_KEY,
|
|
16
|
-
ALGOLIA_APP_ID,
|
|
17
|
-
ALGOLIA_INDEX,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
exports.getAlgoliaSettings = getAlgoliaSettings;
|
|
21
|
-
//# sourceMappingURL=getAlgoliaSettings.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getAlgoliaSettings.js","sourceRoot":"","sources":["../../../src/data-fetching/lib/getAlgoliaSettings.ts"],"names":[],"mappings":";;;AAEA,uCAA8C;AAG9C,uDAAoD;AAEpD,SAAgB,kBAAkB,CAAC,GAAqB;IACpD,IAAA,uBAAe,EAAC,oBAAoB,CAAC,CAAC;IAEtC,mFAAmF;IACnF,MAAM,EACF,eAAe,GAAG,EAAE,EACpB,cAAc,GAAG,YAAY,EAC7B,aAAa,GAAG,qBAAqB,GACxC,GAAG,IAAA,iCAAe,EAAC,GAAG,CAAC,CAAC;IAEzB,IAAI,CAAC,eAAe,EAAE,CAAC;QACnB,sCAAsC;QACtC,OAAO,CAAC,KAAK,CAAC,2EAA2E,CAAC,CAAC;IAC/F,CAAC;IAED,OAAO;QACH,eAAe;QACf,cAAc;QACd,aAAa;KAChB,CAAC;AACN,CAAC;AApBD,gDAoBC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getEnvVariables = void 0;
|
|
7
|
-
const parse_data_url_1 = __importDefault(require("parse-data-url"));
|
|
8
|
-
const utils_1 = require("../../utils");
|
|
9
|
-
function decodeJson(json) {
|
|
10
|
-
try {
|
|
11
|
-
const decoded = JSON.parse(json);
|
|
12
|
-
if (decoded && typeof decoded === 'object') {
|
|
13
|
-
return decoded;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
// passthru
|
|
18
|
-
}
|
|
19
|
-
return {};
|
|
20
|
-
}
|
|
21
|
-
function decodeHttpEnv(header) {
|
|
22
|
-
if (header.startsWith('data:')) {
|
|
23
|
-
const parsed = (0, parse_data_url_1.default)(header);
|
|
24
|
-
if (parsed && parsed.contentType === 'application/json') {
|
|
25
|
-
const data = parsed.toBuffer().toString('utf-8');
|
|
26
|
-
return decodeJson(data);
|
|
27
|
-
}
|
|
28
|
-
return {}; // unsupported data-uri
|
|
29
|
-
}
|
|
30
|
-
return decodeJson(header);
|
|
31
|
-
}
|
|
32
|
-
function getEnvVariables(req) {
|
|
33
|
-
(0, utils_1.assertServerEnv)('getEnvVariables');
|
|
34
|
-
const headerName = (process.env.HTTP_ENV_HEADER || '').toLowerCase();
|
|
35
|
-
if (headerName && req) {
|
|
36
|
-
const header = req.headers[headerName];
|
|
37
|
-
const httpEnv = decodeHttpEnv(header || '');
|
|
38
|
-
return { ...process.env, ...httpEnv };
|
|
39
|
-
}
|
|
40
|
-
return { ...process.env };
|
|
41
|
-
}
|
|
42
|
-
exports.getEnvVariables = getEnvVariables;
|
|
43
|
-
//# sourceMappingURL=getEnvVariables.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getEnvVariables.js","sourceRoot":"","sources":["../../../src/data-fetching/lib/getEnvVariables.ts"],"names":[],"mappings":";;;;;;AACA,oEAA0C;AAE1C,uCAA8C;AAG9C,SAAS,UAAU,CAAC,IAAY;IAC5B,IAAI,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YACzC,OAAO,OAAO,CAAC;QACnB,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACL,WAAW;IACf,CAAC;IACD,OAAO,EAAE,CAAC;AACd,CAAC;AAED,SAAS,aAAa,CAAC,MAAc;IACjC,IAAI,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,IAAA,wBAAY,EAAC,MAAM,CAAC,CAAC;QACpC,IAAI,MAAM,IAAI,MAAM,CAAC,WAAW,KAAK,kBAAkB,EAAE,CAAC;YACtD,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YACjD,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO,EAAE,CAAC,CAAC,uBAAuB;IACtC,CAAC;IACD,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED,SAAgB,eAAe,CAC3B,GAAqB;IAErB,IAAA,uBAAe,EAAC,iBAAiB,CAAC,CAAC;IAEnC,MAAM,UAAU,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAErE,IAAI,UAAU,IAAI,GAAG,EAAE,CAAC;QACpB,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,UAAU,CAAuB,CAAC;QAC7D,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;QAC5C,OAAO,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,OAAO,EAAiC,CAAC;IACzE,CAAC;IAED,OAAO,EAAE,GAAG,OAAO,CAAC,GAAG,EAAiC,CAAC;AAC7D,CAAC;AAdD,0CAcC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isUuid = exports.getEnvVariables = exports.getAlgoliaSettings = void 0;
|
|
4
|
-
var getAlgoliaSettings_1 = require("./getAlgoliaSettings");
|
|
5
|
-
Object.defineProperty(exports, "getAlgoliaSettings", { enumerable: true, get: function () { return getAlgoliaSettings_1.getAlgoliaSettings; } });
|
|
6
|
-
var getEnvVariables_1 = require("./getEnvVariables");
|
|
7
|
-
Object.defineProperty(exports, "getEnvVariables", { enumerable: true, get: function () { return getEnvVariables_1.getEnvVariables; } });
|
|
8
|
-
var isUuid_1 = require("./isUuid");
|
|
9
|
-
Object.defineProperty(exports, "isUuid", { enumerable: true, get: function () { return isUuid_1.isUuid; } });
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/data-fetching/lib/index.ts"],"names":[],"mappings":";;;AAAA,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA;AAC3B,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,mCAAkC;AAAzB,gGAAA,MAAM,OAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isUuid(input: string): boolean;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isUuid = void 0;
|
|
4
|
-
const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
5
|
-
function isUuid(input) {
|
|
6
|
-
return UUID_REGEX.test(input);
|
|
7
|
-
}
|
|
8
|
-
exports.isUuid = isUuid;
|
|
9
|
-
//# sourceMappingURL=isUuid.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isUuid.js","sourceRoot":"","sources":["../../../src/data-fetching/lib/isUuid.ts"],"names":[],"mappings":";;;AAAA,MAAM,UAAU,GAAG,gEAAgE,CAAC;AAEpF,SAAgB,MAAM,CAAC,KAAa;IAChC,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC;AAFD,wBAEC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface AlgoliaSettings {
|
|
2
|
-
ALGOLIA_API_KEY: string;
|
|
3
|
-
ALGOLIA_APP_ID: string;
|
|
4
|
-
ALGOLIA_INDEX: string;
|
|
5
|
-
}
|
|
6
|
-
export interface PrezlyNewsroomEnv {
|
|
7
|
-
PREZLY_ACCESS_TOKEN: string;
|
|
8
|
-
PREZLY_NEWSROOM_UUID: string;
|
|
9
|
-
PREZLY_THEME_UUID?: string;
|
|
10
|
-
PREZLY_MODE?: 'preview';
|
|
11
|
-
}
|
|
12
|
-
export interface PrezlyEnv extends PrezlyNewsroomEnv, AlgoliaSettings {
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/data-fetching/types.ts"],"names":[],"mappings":""}
|
package/build/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
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("./intl"), exports);
|
|
18
|
-
__exportStar(require("./seo"), exports);
|
|
19
|
-
__exportStar(require("./types"), exports);
|
|
20
|
-
__exportStar(require("./utils"), exports);
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,wCAAsB;AACtB,0CAAwB;AACxB,0CAAwB"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { LangCode } from './locale';
|
|
2
|
-
import { LocaleObject } from './localeObject';
|
|
3
|
-
/**
|
|
4
|
-
* Fallback locales for each region independent locale.
|
|
5
|
-
* For example, a story has en-CA en-AU and en-GB locales. As you can see there is no region independent locale.
|
|
6
|
-
* We will use a list of possible fallbacks to determine region independent locale alias.
|
|
7
|
-
* In the provided example the result will be en-GB since it is defined in the localeFallback list
|
|
8
|
-
* If the list will be en-CA en-AU and en-US then the result will be en-US since it is the first one and hence takes precedence.
|
|
9
|
-
*/
|
|
10
|
-
export declare function getFallbackLocale(langCode: LangCode, availableLocales: LocaleObject[]): LocaleObject | undefined;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFallbackLocale = void 0;
|
|
4
|
-
const localeObject_1 = require("./localeObject");
|
|
5
|
-
const localeFallback = {
|
|
6
|
-
en: [localeObject_1.LocaleObject.fromAnyCode('en-US'), localeObject_1.LocaleObject.fromAnyCode('en-GB')],
|
|
7
|
-
fr: [localeObject_1.LocaleObject.fromAnyCode('fr-FR'), localeObject_1.LocaleObject.fromAnyCode('fr-CA')],
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Fallback locales for each region independent locale.
|
|
11
|
-
* For example, a story has en-CA en-AU and en-GB locales. As you can see there is no region independent locale.
|
|
12
|
-
* We will use a list of possible fallbacks to determine region independent locale alias.
|
|
13
|
-
* In the provided example the result will be en-GB since it is defined in the localeFallback list
|
|
14
|
-
* If the list will be en-CA en-AU and en-US then the result will be en-US since it is the first one and hence takes precedence.
|
|
15
|
-
*/
|
|
16
|
-
function getFallbackLocale(langCode, availableLocales) {
|
|
17
|
-
const fallbacks = localeFallback[langCode];
|
|
18
|
-
if (!fallbacks) {
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
return fallbacks.find((fallback) => Boolean(availableLocales.find((available) => available.isEqual(fallback))));
|
|
22
|
-
}
|
|
23
|
-
exports.getFallbackLocale = getFallbackLocale;
|
|
24
|
-
//# sourceMappingURL=getFallbackLocale.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getFallbackLocale.js","sourceRoot":"","sources":["../../src/intl/getFallbackLocale.ts"],"names":[],"mappings":";;;AACA,iDAA8C;AAE9C,MAAM,cAAc,GAAqC;IACrD,EAAE,EAAE,CAAC,2BAAY,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,2BAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC1E,EAAE,EAAE,CAAC,2BAAY,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,2BAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;CAC7E,CAAC;AAEF;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAC7B,QAAkB,EAClB,gBAAgC;IAEhC,MAAM,SAAS,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IAE3C,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAC/B,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAC7E,CAAC;AACN,CAAC;AAbD,8CAaC"}
|
package/build/intl/index.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.localeConfig = void 0;
|
|
21
|
-
__exportStar(require("./getFallbackLocale"), exports);
|
|
22
|
-
__exportStar(require("./languages"), exports);
|
|
23
|
-
var localeConfig_1 = require("./localeConfig");
|
|
24
|
-
Object.defineProperty(exports, "localeConfig", { enumerable: true, get: function () { return __importDefault(localeConfig_1).default; } });
|
|
25
|
-
__exportStar(require("./locale"), exports);
|
|
26
|
-
__exportStar(require("./localeObject"), exports);
|
|
27
|
-
//# sourceMappingURL=index.js.map
|
package/build/intl/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/intl/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,8CAA4B;AAC5B,+CAAyD;AAAhD,6HAAA,OAAO,OAAgB;AAChC,2CAAyB;AACzB,iDAA+B"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { NewsroomLanguageSettings, Story } from '@prezly/sdk';
|
|
2
|
-
import { LocaleObject } from './localeObject';
|
|
3
|
-
/**
|
|
4
|
-
* @param mode - defaults to 'native', determines whether to return the native language name or the english language name
|
|
5
|
-
*
|
|
6
|
-
* @returns the display name of the locale in its native language
|
|
7
|
-
*
|
|
8
|
-
* If there's only one culture used in a specific language,
|
|
9
|
-
* we strip the culture name completely.
|
|
10
|
-
*
|
|
11
|
-
* Examples:
|
|
12
|
-
* - English (Global), Spanish (Spain)
|
|
13
|
-
* - -> English, Spanish
|
|
14
|
-
* - English (Global), English (UK), Spanish (Spain)
|
|
15
|
-
* - -> English (Global), English (UK), Spanish
|
|
16
|
-
*/
|
|
17
|
-
export declare function getLanguageDisplayName(language: Pick<NewsroomLanguageSettings, 'locale'>, languages: Pick<NewsroomLanguageSettings, 'locale'>[], mode?: 'native' | 'english'): string;
|
|
18
|
-
/**
|
|
19
|
-
* @returns Language set as default in the Newsroom Settings.
|
|
20
|
-
*/
|
|
21
|
-
export declare function getDefaultLanguage<Language extends Pick<NewsroomLanguageSettings, 'is_default'>>(languages: Language[]): Language;
|
|
22
|
-
/**
|
|
23
|
-
* @returns Only languages having at least one published story
|
|
24
|
-
*/
|
|
25
|
-
export declare function getUsedLanguages<Language extends Pick<NewsroomLanguageSettings, 'public_stories_count'>>(languages: Language[]): Language[];
|
|
26
|
-
export declare function getLanguageByExactLocaleCode<Language extends Pick<NewsroomLanguageSettings, 'code'>>(languages: Language[], locale: LocaleObject): Language | undefined;
|
|
27
|
-
export declare function getLanguageByNeutralLocaleCode<Language extends Pick<NewsroomLanguageSettings, 'is_default' | 'code' | 'public_stories_count'>>(languages: Language[], locale: LocaleObject): Language | undefined;
|
|
28
|
-
export declare function getLanguageByShortRegionCode<Language extends Pick<NewsroomLanguageSettings, 'is_default' | 'code' | 'public_stories_count'>>(languages: Language[], locale: LocaleObject): Language | undefined;
|
|
29
|
-
export declare function getLanguageFromStory<Language extends Pick<NewsroomLanguageSettings, 'code'>>(languages: Language[], story: Pick<Story, 'culture'>): Language | undefined;
|
|
30
|
-
/**
|
|
31
|
-
* Extracts company information for the selected locale
|
|
32
|
-
*/
|
|
33
|
-
export declare function getCompanyInformation<Language extends Pick<NewsroomLanguageSettings, 'is_default' | 'code' | 'company_information'>>(languages: Language[], locale: LocaleObject): Language['company_information'];
|
|
34
|
-
/**
|
|
35
|
-
* Get newsroom notifications for the selected locale
|
|
36
|
-
*/
|
|
37
|
-
export declare function getNotifications<Language extends Pick<NewsroomLanguageSettings, 'code' | 'is_default' | 'notifications'>>(languages: Language[], locale: LocaleObject): Language['notifications'];
|
|
38
|
-
/**
|
|
39
|
-
* Get the shortest locale code possible from full locale code
|
|
40
|
-
* First: try shorting to neutral language code (there should be no locales with the same language code)
|
|
41
|
-
* Then: try shorting to region code (there should be no locales with the same region code)
|
|
42
|
-
* Finally: return the original locale code (shorting is not possible)
|
|
43
|
-
*
|
|
44
|
-
* @param locale A LocaleObject constructed from FULL locale code (taken straight from the selected language)
|
|
45
|
-
*/
|
|
46
|
-
export declare function getShortestLocaleCode<Language extends Pick<NewsroomLanguageSettings, 'code' | 'is_default'>>(languages: Language[], locale: LocaleObject): string | false;
|
|
47
|
-
/**
|
|
48
|
-
* Get matching language for the requested locale
|
|
49
|
-
* The logic is reversed from `getShortestLocaleCode`, so that it "unwraps" the possible variants with no collisions
|
|
50
|
-
*
|
|
51
|
-
* First: get by exact match
|
|
52
|
-
* Then: get by matching region code part
|
|
53
|
-
* Finally: get by matching language code part
|
|
54
|
-
*
|
|
55
|
-
* @param locale A LocaleObject constructed from the requested locale code (taken straight from the URL)
|
|
56
|
-
*/
|
|
57
|
-
export declare function getLanguageFromLocaleIsoCode<Language extends Pick<NewsroomLanguageSettings, 'is_default' | 'code' | 'public_stories_count'>>(languages: Language[], locale: LocaleObject): Language | undefined;
|
package/build/intl/languages.js
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getLanguageFromLocaleIsoCode = exports.getShortestLocaleCode = exports.getNotifications = exports.getCompanyInformation = exports.getLanguageFromStory = exports.getLanguageByShortRegionCode = exports.getLanguageByNeutralLocaleCode = exports.getLanguageByExactLocaleCode = exports.getUsedLanguages = exports.getDefaultLanguage = exports.getLanguageDisplayName = void 0;
|
|
4
|
-
const localeObject_1 = require("./localeObject");
|
|
5
|
-
function isOnlyCulture(culture, languages) {
|
|
6
|
-
const numberOfLanguages = languages.filter(({ locale: { language_code } }) => language_code === culture.language_code).length;
|
|
7
|
-
return numberOfLanguages === 1;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* @param mode - defaults to 'native', determines whether to return the native language name or the english language name
|
|
11
|
-
*
|
|
12
|
-
* @returns the display name of the locale in its native language
|
|
13
|
-
*
|
|
14
|
-
* If there's only one culture used in a specific language,
|
|
15
|
-
* we strip the culture name completely.
|
|
16
|
-
*
|
|
17
|
-
* Examples:
|
|
18
|
-
* - English (Global), Spanish (Spain)
|
|
19
|
-
* - -> English, Spanish
|
|
20
|
-
* - English (Global), English (UK), Spanish (Spain)
|
|
21
|
-
* - -> English (Global), English (UK), Spanish
|
|
22
|
-
*/
|
|
23
|
-
function getLanguageDisplayName(language, languages, mode = 'native') {
|
|
24
|
-
const { locale } = language;
|
|
25
|
-
const displayedName = mode === 'native' ? locale.native_name : locale.name;
|
|
26
|
-
if (isOnlyCulture(locale, languages)) {
|
|
27
|
-
const cultureNameIndex = displayedName.indexOf('(');
|
|
28
|
-
if (cultureNameIndex !== -1) {
|
|
29
|
-
return displayedName.slice(0, cultureNameIndex - 1);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return displayedName;
|
|
33
|
-
}
|
|
34
|
-
exports.getLanguageDisplayName = getLanguageDisplayName;
|
|
35
|
-
/**
|
|
36
|
-
* @returns Language set as default in the Newsroom Settings.
|
|
37
|
-
*/
|
|
38
|
-
function getDefaultLanguage(languages) {
|
|
39
|
-
return languages.find(({ is_default }) => is_default) || languages[0];
|
|
40
|
-
}
|
|
41
|
-
exports.getDefaultLanguage = getDefaultLanguage;
|
|
42
|
-
/**
|
|
43
|
-
* @returns Only languages having at least one published story
|
|
44
|
-
*/
|
|
45
|
-
function getUsedLanguages(languages) {
|
|
46
|
-
return languages.filter((language) => language.public_stories_count > 0);
|
|
47
|
-
}
|
|
48
|
-
exports.getUsedLanguages = getUsedLanguages;
|
|
49
|
-
function getLanguageByExactLocaleCode(languages, locale) {
|
|
50
|
-
const localeCode = locale.toUnderscoreCode();
|
|
51
|
-
return languages.find(({ code }) => code === localeCode);
|
|
52
|
-
}
|
|
53
|
-
exports.getLanguageByExactLocaleCode = getLanguageByExactLocaleCode;
|
|
54
|
-
// See https://github.com/prezly/prezly/blob/master/lib/model/CulturePeer.php#L123
|
|
55
|
-
function getLanguageByNeutralLocaleCode(languages, locale) {
|
|
56
|
-
const neutralLanguageCode = locale.toNeutralLanguageCode();
|
|
57
|
-
// Try to look in used cultures first (giving priority to used ones)
|
|
58
|
-
const usedLanguages = getUsedLanguages(languages);
|
|
59
|
-
const usedLanguage = usedLanguages.find(({ code }) => localeObject_1.LocaleObject.fromAnyCode(code).toNeutralLanguageCode() === neutralLanguageCode);
|
|
60
|
-
if (usedLanguage) {
|
|
61
|
-
return usedLanguage;
|
|
62
|
-
}
|
|
63
|
-
// Search in all languages
|
|
64
|
-
return languages.find(({ code }) => localeObject_1.LocaleObject.fromAnyCode(code).toNeutralLanguageCode() === neutralLanguageCode);
|
|
65
|
-
}
|
|
66
|
-
exports.getLanguageByNeutralLocaleCode = getLanguageByNeutralLocaleCode;
|
|
67
|
-
// See https://github.com/prezly/prezly/blob/master/lib/model/CulturePeer.php#L159
|
|
68
|
-
function getLanguageByShortRegionCode(languages, locale) {
|
|
69
|
-
const shortRegionCode = locale.toRegionCode();
|
|
70
|
-
// Try to look in used cultures first (giving priority to used ones)
|
|
71
|
-
const usedLanguages = getUsedLanguages(languages);
|
|
72
|
-
const usedLanguage = usedLanguages.find(({ code }) => localeObject_1.LocaleObject.fromAnyCode(code).toRegionCode() === shortRegionCode);
|
|
73
|
-
if (usedLanguage) {
|
|
74
|
-
return usedLanguage;
|
|
75
|
-
}
|
|
76
|
-
// Search in all languages
|
|
77
|
-
return languages.find(({ code }) => localeObject_1.LocaleObject.fromAnyCode(code).toRegionCode() === shortRegionCode);
|
|
78
|
-
}
|
|
79
|
-
exports.getLanguageByShortRegionCode = getLanguageByShortRegionCode;
|
|
80
|
-
function getLanguageFromStory(languages, story) {
|
|
81
|
-
const { code: storyLocaleCode } = story.culture;
|
|
82
|
-
return languages.find(({ code }) => code === storyLocaleCode);
|
|
83
|
-
}
|
|
84
|
-
exports.getLanguageFromStory = getLanguageFromStory;
|
|
85
|
-
/**
|
|
86
|
-
* Extracts company information for the selected locale
|
|
87
|
-
*/
|
|
88
|
-
function getCompanyInformation(languages, locale) {
|
|
89
|
-
const currentLanguage = getLanguageByExactLocaleCode(languages, locale) || getDefaultLanguage(languages);
|
|
90
|
-
return currentLanguage.company_information;
|
|
91
|
-
}
|
|
92
|
-
exports.getCompanyInformation = getCompanyInformation;
|
|
93
|
-
/**
|
|
94
|
-
* Get newsroom notifications for the selected locale
|
|
95
|
-
*/
|
|
96
|
-
function getNotifications(languages, locale) {
|
|
97
|
-
const currentLanguage = getLanguageByExactLocaleCode(languages, locale) || getDefaultLanguage(languages);
|
|
98
|
-
return currentLanguage.notifications;
|
|
99
|
-
}
|
|
100
|
-
exports.getNotifications = getNotifications;
|
|
101
|
-
/**
|
|
102
|
-
* Get the shortest locale code possible from full locale code
|
|
103
|
-
* First: try shorting to neutral language code (there should be no locales with the same language code)
|
|
104
|
-
* Then: try shorting to region code (there should be no locales with the same region code)
|
|
105
|
-
* Finally: return the original locale code (shorting is not possible)
|
|
106
|
-
*
|
|
107
|
-
* @param locale A LocaleObject constructed from FULL locale code (taken straight from the selected language)
|
|
108
|
-
*/
|
|
109
|
-
function getShortestLocaleCode(languages, locale) {
|
|
110
|
-
const localeCode = locale.toUnderscoreCode();
|
|
111
|
-
const defaultLanguage = getDefaultLanguage(languages);
|
|
112
|
-
// If it's a default locale, return false (no locale needed in URL)
|
|
113
|
-
if (localeCode === defaultLanguage.code) {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
// Undocumented feature: you can completely disable locale shortening by setting `NEXT_PUBLIC_BYPASS_LOCALE_CODE_SHORTENING` env variable.
|
|
117
|
-
// Currently used by a custom theme.
|
|
118
|
-
if (process.env.NEXT_PUBLIC_BYPASS_LOCALE_CODE_SHORTENING) {
|
|
119
|
-
return localeCode;
|
|
120
|
-
}
|
|
121
|
-
// Try shorting to neutral language code
|
|
122
|
-
const neutralLanguageCode = locale.toNeutralLanguageCode();
|
|
123
|
-
const matchingLanguagesByNeutralCode = languages.filter(({ code }) => localeObject_1.LocaleObject.fromAnyCode(code).toNeutralLanguageCode() === neutralLanguageCode ||
|
|
124
|
-
code === neutralLanguageCode);
|
|
125
|
-
if (matchingLanguagesByNeutralCode.length === 1) {
|
|
126
|
-
return neutralLanguageCode;
|
|
127
|
-
}
|
|
128
|
-
// Try shorting to region code
|
|
129
|
-
const shortRegionCode = locale.toRegionCode();
|
|
130
|
-
const matchingLanguagesByRegionCode = languages.filter(({ code }) => localeObject_1.LocaleObject.fromAnyCode(code).toRegionCode() === shortRegionCode);
|
|
131
|
-
// Prevent collision with neutral language codes
|
|
132
|
-
const lowerCasedShortRegionCode = shortRegionCode.toLowerCase();
|
|
133
|
-
const matchingNeutralLanguagesByRegionCode = languages.filter(({ code }) => localeObject_1.LocaleObject.fromAnyCode(code).toNeutralLanguageCode() === lowerCasedShortRegionCode ||
|
|
134
|
-
code === lowerCasedShortRegionCode);
|
|
135
|
-
if (matchingLanguagesByRegionCode.length === 1 &&
|
|
136
|
-
// If there are 2 or more matching neutral languages, it means that there are no languages that can be shortened to neutral code
|
|
137
|
-
matchingNeutralLanguagesByRegionCode.length !== 1 &&
|
|
138
|
-
// We don't want just numbers in our region code
|
|
139
|
-
Number.isNaN(Number(shortRegionCode))) {
|
|
140
|
-
return shortRegionCode;
|
|
141
|
-
}
|
|
142
|
-
// Return the original (exact) code if shortening is not possible
|
|
143
|
-
return localeCode;
|
|
144
|
-
}
|
|
145
|
-
exports.getShortestLocaleCode = getShortestLocaleCode;
|
|
146
|
-
/**
|
|
147
|
-
* Get matching language for the requested locale
|
|
148
|
-
* The logic is reversed from `getShortestLocaleCode`, so that it "unwraps" the possible variants with no collisions
|
|
149
|
-
*
|
|
150
|
-
* First: get by exact match
|
|
151
|
-
* Then: get by matching region code part
|
|
152
|
-
* Finally: get by matching language code part
|
|
153
|
-
*
|
|
154
|
-
* @param locale A LocaleObject constructed from the requested locale code (taken straight from the URL)
|
|
155
|
-
*/
|
|
156
|
-
function getLanguageFromLocaleIsoCode(languages, locale) {
|
|
157
|
-
// Prefer exact match
|
|
158
|
-
const exactMatchedLanguage = getLanguageByExactLocaleCode(languages, locale);
|
|
159
|
-
if (exactMatchedLanguage) {
|
|
160
|
-
return exactMatchedLanguage;
|
|
161
|
-
}
|
|
162
|
-
// If locale code is not region independent, it means that it's not a shortened code (consists of two parts).
|
|
163
|
-
// If it didn't match by exact code, there's no reason to check for region/language code match
|
|
164
|
-
if (!locale.isRegionIndependent) {
|
|
165
|
-
return undefined;
|
|
166
|
-
}
|
|
167
|
-
// We're excluding the default language, since it shouldn't have a URL slug
|
|
168
|
-
const languagesWithoutDefault = languages.filter(({ is_default }) => !is_default);
|
|
169
|
-
const shortRegionCode = locale.toRegionCode();
|
|
170
|
-
const neutralLanguageCode = locale.toNeutralLanguageCode();
|
|
171
|
-
const languageWithSameRegionAndNeutralCode = languagesWithoutDefault.find(({ code }) => {
|
|
172
|
-
const comparingLocale = localeObject_1.LocaleObject.fromAnyCode(code);
|
|
173
|
-
const hasSameNeutralCode = comparingLocale.toNeutralLanguageCode() === neutralLanguageCode;
|
|
174
|
-
const hasSameRegionCode = comparingLocale.toRegionCode() === shortRegionCode;
|
|
175
|
-
return hasSameNeutralCode && hasSameRegionCode;
|
|
176
|
-
});
|
|
177
|
-
if (languageWithSameRegionAndNeutralCode) {
|
|
178
|
-
return languageWithSameRegionAndNeutralCode;
|
|
179
|
-
}
|
|
180
|
-
const regionMatchedLanguage = getLanguageByShortRegionCode(languagesWithoutDefault, locale);
|
|
181
|
-
if (regionMatchedLanguage) {
|
|
182
|
-
return regionMatchedLanguage;
|
|
183
|
-
}
|
|
184
|
-
const neutralMatchedLanguage = getLanguageByNeutralLocaleCode(languagesWithoutDefault, locale);
|
|
185
|
-
if (neutralMatchedLanguage) {
|
|
186
|
-
return neutralMatchedLanguage;
|
|
187
|
-
}
|
|
188
|
-
return undefined;
|
|
189
|
-
}
|
|
190
|
-
exports.getLanguageFromLocaleIsoCode = getLanguageFromLocaleIsoCode;
|
|
191
|
-
//# sourceMappingURL=languages.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"languages.js","sourceRoot":"","sources":["../../src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AAC,CAAC;IAC5F,IAAI,qBAAqB,EAAE,CAAC;QACxB,OAAO,qBAAqB,CAAC;IACjC,CAAC;IAED,MAAM,sBAAsB,GAAG,8BAA8B,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;IAC/F,IAAI,sBAAsB,EAAE,CAAC;QACzB,OAAO,sBAAsB,CAAC;IAClC,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AA3CD,oEA2CC"}
|
package/build/intl/locale.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { LocaleObject } from './localeObject';
|
|
2
|
-
export declare const DEFAULT_LOCALE = "en";
|
|
3
|
-
export type LangCode = string;
|
|
4
|
-
export type RegionCode = string;
|
|
5
|
-
export type LocaleCode = string;
|
|
6
|
-
/**
|
|
7
|
-
* Use this function to determine which translations file you should load from `@prezly/theme-kit-intl` package.
|
|
8
|
-
* See https://github.com/prezly/theme-nextjs-bea/blob/main/utils/lang.ts for a usage example.
|
|
9
|
-
*/
|
|
10
|
-
export declare function getSupportedLocaleIsoCode(locale: LocaleObject): string;
|
|
11
|
-
export declare function getLocaleDirection(locale: LocaleObject): 'ltr' | 'rtl';
|
package/build/intl/locale.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getLocaleDirection = exports.getSupportedLocaleIsoCode = exports.DEFAULT_LOCALE = void 0;
|
|
4
|
-
const theme_kit_intl_1 = require("@prezly/theme-kit-intl");
|
|
5
|
-
exports.DEFAULT_LOCALE = 'en';
|
|
6
|
-
/**
|
|
7
|
-
* Use this function to determine which translations file you should load from `@prezly/theme-kit-intl` package.
|
|
8
|
-
* See https://github.com/prezly/theme-nextjs-bea/blob/main/utils/lang.ts for a usage example.
|
|
9
|
-
*/
|
|
10
|
-
function getSupportedLocaleIsoCode(locale) {
|
|
11
|
-
const localeIsoCode = locale.toHyphenCode();
|
|
12
|
-
const isSupportedLocale = localeIsoCode.length >= 2 && (0, theme_kit_intl_1.isLocaleSupported)(localeIsoCode);
|
|
13
|
-
if (isSupportedLocale) {
|
|
14
|
-
return localeIsoCode;
|
|
15
|
-
}
|
|
16
|
-
const language = locale.toNeutralLanguageCode();
|
|
17
|
-
if ((0, theme_kit_intl_1.isLocaleSupported)(language)) {
|
|
18
|
-
return language;
|
|
19
|
-
}
|
|
20
|
-
// Custom mapping for Chinese locales
|
|
21
|
-
if (localeIsoCode.toLowerCase() === 'zh-hant') {
|
|
22
|
-
return 'zh-TW';
|
|
23
|
-
}
|
|
24
|
-
if (localeIsoCode.toLowerCase() === 'zh-hk') {
|
|
25
|
-
return 'zh-CN';
|
|
26
|
-
}
|
|
27
|
-
// This code should never be reached, because locale code check is happening in `LocaleObject.fromAnyCode`
|
|
28
|
-
// eslint-disable-next-line no-console
|
|
29
|
-
console.warn('Unsupported locale provided. Please use `LocaleObject.fromAnyCode` to ensure you are using a correct language code');
|
|
30
|
-
return exports.DEFAULT_LOCALE;
|
|
31
|
-
}
|
|
32
|
-
exports.getSupportedLocaleIsoCode = getSupportedLocaleIsoCode;
|
|
33
|
-
function getLocaleDirection(locale) {
|
|
34
|
-
const neutralLanguageCode = locale.toNeutralLanguageCode();
|
|
35
|
-
if (['ar', 'he', 'ur'].includes(neutralLanguageCode)) {
|
|
36
|
-
return 'rtl';
|
|
37
|
-
}
|
|
38
|
-
return 'ltr';
|
|
39
|
-
}
|
|
40
|
-
exports.getLocaleDirection = getLocaleDirection;
|
|
41
|
-
//# sourceMappingURL=locale.js.map
|
package/build/intl/locale.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"locale.js","sourceRoot":"","sources":["../../src/intl/locale.ts"],"names":[],"mappings":";;;AAAA,2DAA2D;AAI9C,QAAA,cAAc,GAAG,IAAI,CAAC;AAMnC;;;GAGG;AACH,SAAgB,yBAAyB,CAAC,MAAoB;IAC1D,MAAM,aAAa,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;IAE5C,MAAM,iBAAiB,GAAG,aAAa,CAAC,MAAM,IAAI,CAAC,IAAI,IAAA,kCAAiB,EAAC,aAAa,CAAC,CAAC;IACxF,IAAI,iBAAiB,EAAE,CAAC;QACpB,OAAO,aAAa,CAAC;IACzB,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,qBAAqB,EAAE,CAAC;IAChD,IAAI,IAAA,kCAAiB,EAAC,QAAQ,CAAC,EAAE,CAAC;QAC9B,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED,qCAAqC;IACrC,IAAI,aAAa,CAAC,WAAW,EAAE,KAAK,SAAS,EAAE,CAAC;QAC5C,OAAO,OAAO,CAAC;IACnB,CAAC;IACD,IAAI,aAAa,CAAC,WAAW,EAAE,KAAK,OAAO,EAAE,CAAC;QAC1C,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,0GAA0G;IAC1G,sCAAsC;IACtC,OAAO,CAAC,IAAI,CACR,oHAAoH,CACvH,CAAC;IACF,OAAO,sBAAc,CAAC;AAC1B,CAAC;AA3BD,8DA2BC;AAED,SAAgB,kBAAkB,CAAC,MAAoB;IACnD,MAAM,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,EAAE,CAAC;IAE3D,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AARD,gDAQC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* This list is pulled from the main Prezly application. The underscores are replaced with dashes.
|
|
4
|
-
* Together with permutation performed lower in the code,
|
|
5
|
-
* the exported list represents all of the possible locale codes that a theme application might accept.
|
|
6
|
-
*/
|
|
7
|
-
const supportedLocales = require('./localeList');
|
|
8
|
-
const lowercaseLocales = supportedLocales.map((l) => l.toLowerCase());
|
|
9
|
-
// Get all permutations for the shorter locale codes supported by Prezly (e.g. short region codes and neutral language codes)
|
|
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
|
-
// Remove codes that are too long to be valid standalone codes (like `hant` for `zh-hant`)
|
|
19
|
-
.filter((code) => code.length <= 3),
|
|
20
|
-
])).sort();
|
|
21
|
-
module.exports = lowercaseLocalPermutations;
|
|
22
|
-
//# sourceMappingURL=localeConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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;QAC7C,0FAA0F;SACzF,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;CAC1C,CAAC,CACL,CAAC,IAAI,EAAE,CAAC;AAET,MAAM,CAAC,OAAO,GAAG,0BAA0B,CAAC"}
|