@prezly/theme-kit-nextjs 2.0.1-0 → 2.0.1-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/@types/global.d.js +1 -1
- package/build/adapter-nextjs/api-handlers/fetchGalleries.js +9 -3
- package/build/adapter-nextjs/api-handlers/fetchStories.js +9 -3
- package/build/adapter-nextjs/api-handlers/index.js +19 -2
- package/build/adapter-nextjs/getNewsroomServerSideProps.js +9 -3
- package/build/adapter-nextjs/getNewsroomStaticProps.js +9 -3
- package/build/adapter-nextjs/index.js +71 -6
- package/build/adapter-nextjs/page-props/category.js +27 -19
- package/build/adapter-nextjs/page-props/gallery.js +20 -13
- package/build/adapter-nextjs/page-props/galleryAlbum.js +21 -13
- package/build/adapter-nextjs/page-props/home.js +20 -13
- package/build/adapter-nextjs/page-props/index.js +138 -8
- package/build/adapter-nextjs/page-props/lib/types.js +1 -1
- package/build/adapter-nextjs/page-props/search.js +17 -10
- package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js +9 -2
- package/build/adapter-nextjs/page-props/sitemap/createPaths.js +7 -1
- package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js +13 -7
- package/build/adapter-nextjs/page-props/sitemap/index.js +43 -4
- package/build/adapter-nextjs/page-props/sitemap/types.js +1 -1
- package/build/adapter-nextjs/page-props/story.js +25 -17
- package/build/adapter-nextjs/page-props/storyPreview.js +13 -7
- package/build/adapter-nextjs/processRequest.js +11 -5
- package/build/adapter-nextjs/processStaticRequest.js +7 -1
- package/build/components-nextjs/PageSeo/PageSeo.js +30 -24
- package/build/components-nextjs/PageSeo/index.js +27 -2
- package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js +7 -1
- package/build/components-nextjs/PageSeo/lib/types.js +1 -1
- package/build/components-nextjs/StorySeo/StorySeo.js +12 -6
- package/build/components-nextjs/StorySeo/index.js +12 -1
- package/build/components-nextjs/document.js +19 -10
- package/build/components-nextjs/index.js +26 -3
- package/build/data-fetching/api/PrezlyApi.js +37 -30
- package/build/data-fetching/api/getPrezlyApi.js +11 -5
- package/build/data-fetching/api/index.js +16 -1
- package/build/data-fetching/api/queries.js +15 -5
- package/build/data-fetching/index.js +38 -3
- package/build/data-fetching/lib/getAlgoliaSettings.js +9 -3
- package/build/data-fetching/lib/getEnvVariables.js +10 -3
- package/build/data-fetching/lib/index.js +33 -4
- package/build/data-fetching/lib/isSdkError.js +7 -1
- package/build/data-fetching/lib/isUuid.js +7 -1
- package/build/data-fetching/types.js +1 -1
- package/build/index.js +104 -9
- package/build/infinite-loading/index.js +43 -4
- package/build/infinite-loading/types.js +1 -1
- package/build/infinite-loading/useInfiniteGalleriesLoading.js +9 -3
- package/build/infinite-loading/useInfiniteLoading.js +15 -9
- package/build/infinite-loading/useInfiniteStoriesLoading.js +13 -7
- package/build/intl/index.js +49 -4
- package/build/intl/languages.js +39 -23
- package/build/intl/locale.js +20 -10
- package/build/intl/localeConfig.js +14 -5
- package/build/intl/localeList.js +8 -1
- package/build/intl/localeObject.js +11 -4
- package/build/newsroom-context/context.js +13 -5
- package/build/newsroom-context/hooks/index.js +126 -11
- package/build/newsroom-context/hooks/useAlgoliaSettings.js +9 -3
- package/build/newsroom-context/hooks/useCategories.js +9 -3
- package/build/newsroom-context/hooks/useCompanyInformation.js +9 -3
- package/build/newsroom-context/hooks/useCurrentCategory.js +9 -3
- package/build/newsroom-context/hooks/useCurrentLocale.js +9 -3
- package/build/newsroom-context/hooks/useCurrentStory.js +9 -3
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js +16 -10
- package/build/newsroom-context/hooks/useGetTranslationUrl.js +26 -20
- package/build/newsroom-context/hooks/useLanguages.js +9 -3
- package/build/newsroom-context/hooks/useNewsroom.js +9 -3
- package/build/newsroom-context/hooks/useNewsroomContext.js +10 -4
- package/build/newsroom-context/index.js +34 -2
- package/build/sentry/client.js +9 -3
- package/build/sentry/common.js +7 -1
- package/build/sentry/index.js +19 -2
- package/build/sentry/server.js +9 -3
- package/build/types.js +1 -1
- package/build/utils/boilerplate.js +11 -3
- package/build/utils/constants.js +12 -3
- package/build/utils/getAssetsUrl.js +9 -3
- package/build/utils/getDataRequestLink.js +9 -3
- package/build/utils/getLocalizedCategoryData.js +11 -3
- package/build/utils/getNewsroomLogoUrl.js +12 -5
- package/build/utils/getPrivacyPortalUrl.js +7 -1
- package/build/utils/getStoryPublicationDate.js +7 -1
- package/build/utils/getUploadcareGroupUrl.js +9 -3
- package/build/utils/index.js +115 -10
- package/build/utils/isEmbargoStory.js +7 -1
- package/package.json +2 -3
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PrezlyApi = void 0;
|
|
7
|
+
var _sdk = require("@prezly/sdk");
|
|
8
|
+
var _index = require("../../intl/index.js");
|
|
9
|
+
var _index2 = require("../../utils/index.js");
|
|
10
|
+
var _index3 = require("../lib/index.js");
|
|
11
|
+
var _queries = require("./queries.js");
|
|
6
12
|
const CATEGORIES_SORT_ORDER = '+order';
|
|
7
13
|
const DEFAULT_SORT_ORDER = 'desc';
|
|
8
14
|
const ERROR_CODE_NOT_FOUND = 404;
|
|
9
15
|
const ERROR_CODE_FORBIDDEN = 403;
|
|
10
16
|
const ERROR_CODE_GONE = 410;
|
|
11
|
-
|
|
17
|
+
class PrezlyApi {
|
|
12
18
|
constructor(accessToken, newsroomUuid, themeUuid) {
|
|
13
19
|
const baseUrl = process.env.API_BASE_URL_OVERRIDE ?? undefined;
|
|
14
|
-
this.sdk = createPrezlyClient({
|
|
20
|
+
this.sdk = (0, _sdk.createPrezlyClient)({
|
|
15
21
|
accessToken,
|
|
16
22
|
baseUrl,
|
|
17
23
|
// This returns stories created by legacy version of the editor in a format that can be displayed by the Prezly Content Renderer.
|
|
@@ -23,14 +29,14 @@ export class PrezlyApi {
|
|
|
23
29
|
this.themeUuid = themeUuid;
|
|
24
30
|
}
|
|
25
31
|
async getStory(uuid) {
|
|
26
|
-
if (!isUuid(uuid)) {
|
|
32
|
+
if (!(0, _index3.isUuid)(uuid)) {
|
|
27
33
|
return undefined;
|
|
28
34
|
}
|
|
29
35
|
try {
|
|
30
36
|
const story = await this.sdk.stories.get(uuid);
|
|
31
37
|
return story;
|
|
32
38
|
} catch (error) {
|
|
33
|
-
if (isSdkError(error) && (error.status === ERROR_CODE_NOT_FOUND || error.status === ERROR_CODE_GONE || error.status === ERROR_CODE_FORBIDDEN)) {
|
|
39
|
+
if ((0, _index3.isSdkError)(error) && (error.status === ERROR_CODE_NOT_FOUND || error.status === ERROR_CODE_GONE || error.status === ERROR_CODE_FORBIDDEN)) {
|
|
34
40
|
return null;
|
|
35
41
|
}
|
|
36
42
|
throw error;
|
|
@@ -41,7 +47,7 @@ export class PrezlyApi {
|
|
|
41
47
|
}
|
|
42
48
|
async getNewsroomContacts() {
|
|
43
49
|
return this.sdk.newsroomContacts.search(this.newsroomUuid, {
|
|
44
|
-
query: JSON.stringify(getContactsQuery())
|
|
50
|
+
query: JSON.stringify((0, _queries.getContactsQuery)())
|
|
45
51
|
});
|
|
46
52
|
}
|
|
47
53
|
async getNewsroomLanguages() {
|
|
@@ -52,9 +58,9 @@ export class PrezlyApi {
|
|
|
52
58
|
* Note: this method returns ALL stories from the newsroom. It's intended to be used for sitemaps and not to display actual content.
|
|
53
59
|
*/
|
|
54
60
|
async getAllStories(order = DEFAULT_SORT_ORDER) {
|
|
55
|
-
const sortOrder = getSortByPublishedDate(order);
|
|
61
|
+
const sortOrder = (0, _queries.getSortByPublishedDate)(order);
|
|
56
62
|
const newsroom = await this.getNewsroom();
|
|
57
|
-
const query = JSON.stringify(getStoriesQuery(newsroom.uuid));
|
|
63
|
+
const query = JSON.stringify((0, _queries.getStoriesQuery)(newsroom.uuid));
|
|
58
64
|
const maxStories = newsroom.stories_number;
|
|
59
65
|
const chunkSize = 200;
|
|
60
66
|
const pages = Math.ceil(maxStories / chunkSize);
|
|
@@ -71,13 +77,13 @@ export class PrezlyApi {
|
|
|
71
77
|
}
|
|
72
78
|
async getStories({
|
|
73
79
|
page = undefined,
|
|
74
|
-
pageSize = DEFAULT_PAGE_SIZE,
|
|
80
|
+
pageSize = _index2.DEFAULT_PAGE_SIZE,
|
|
75
81
|
order = DEFAULT_SORT_ORDER,
|
|
76
82
|
include,
|
|
77
83
|
localeCode
|
|
78
84
|
} = {}) {
|
|
79
|
-
const sortOrder = getSortByPublishedDate(order);
|
|
80
|
-
const query = JSON.stringify(getStoriesQuery(this.newsroomUuid, undefined, localeCode));
|
|
85
|
+
const sortOrder = (0, _queries.getSortByPublishedDate)(order);
|
|
86
|
+
const query = JSON.stringify((0, _queries.getStoriesQuery)(this.newsroomUuid, undefined, localeCode));
|
|
81
87
|
const {
|
|
82
88
|
stories,
|
|
83
89
|
pagination
|
|
@@ -96,13 +102,13 @@ export class PrezlyApi {
|
|
|
96
102
|
}
|
|
97
103
|
async getStoriesFromCategory(category, {
|
|
98
104
|
page = undefined,
|
|
99
|
-
pageSize = DEFAULT_PAGE_SIZE,
|
|
105
|
+
pageSize = _index2.DEFAULT_PAGE_SIZE,
|
|
100
106
|
order = DEFAULT_SORT_ORDER,
|
|
101
107
|
include,
|
|
102
108
|
localeCode
|
|
103
109
|
} = {}) {
|
|
104
|
-
const sortOrder = getSortByPublishedDate(order);
|
|
105
|
-
const query = JSON.stringify(getStoriesQuery(this.newsroomUuid, category.id, localeCode));
|
|
110
|
+
const sortOrder = (0, _queries.getSortByPublishedDate)(order);
|
|
111
|
+
const query = JSON.stringify((0, _queries.getStoriesQuery)(this.newsroomUuid, category.id, localeCode));
|
|
106
112
|
const {
|
|
107
113
|
stories,
|
|
108
114
|
pagination
|
|
@@ -120,7 +126,7 @@ export class PrezlyApi {
|
|
|
120
126
|
};
|
|
121
127
|
}
|
|
122
128
|
async getStoryBySlug(slug) {
|
|
123
|
-
const query = JSON.stringify(getSlugQuery(this.newsroomUuid, slug));
|
|
129
|
+
const query = JSON.stringify((0, _queries.getSlugQuery)(this.newsroomUuid, slug));
|
|
124
130
|
const {
|
|
125
131
|
stories
|
|
126
132
|
} = await this.searchStories({
|
|
@@ -150,11 +156,11 @@ export class PrezlyApi {
|
|
|
150
156
|
return this.sdk.newsroomGalleries.search(this.newsroomUuid, {
|
|
151
157
|
limit: pageSize,
|
|
152
158
|
offset: typeof page === 'undefined' || typeof pageSize === 'undefined' ? undefined : (page - 1) * pageSize,
|
|
153
|
-
query: getGalleriesQuery()
|
|
159
|
+
query: (0, _queries.getGalleriesQuery)()
|
|
154
160
|
});
|
|
155
161
|
}
|
|
156
162
|
async getGallery(uuid) {
|
|
157
|
-
if (!isUuid(uuid)) {
|
|
163
|
+
if (!(0, _index3.isUuid)(uuid)) {
|
|
158
164
|
// Check for legacy number ID reference, which is also supported for back-compat.
|
|
159
165
|
if (Number.isNaN(Number(uuid))) {
|
|
160
166
|
return undefined;
|
|
@@ -164,7 +170,7 @@ export class PrezlyApi {
|
|
|
164
170
|
const gallery = await this.sdk.newsroomGalleries.get(this.newsroomUuid, uuid);
|
|
165
171
|
return gallery;
|
|
166
172
|
} catch (error) {
|
|
167
|
-
if (isSdkError(error) && error.status === 404) {
|
|
173
|
+
if ((0, _index3.isSdkError)(error) && error.status === 404) {
|
|
168
174
|
return null;
|
|
169
175
|
}
|
|
170
176
|
throw error;
|
|
@@ -182,17 +188,17 @@ export class PrezlyApi {
|
|
|
182
188
|
}
|
|
183
189
|
async getNewsroomServerSideProps(request, nextLocaleIsoCode, story) {
|
|
184
190
|
const [newsroom, languages, categories, themePreset] = await Promise.all([this.getNewsroom(), this.getNewsroomLanguages(), this.getCategories(), this.getThemePreset()]);
|
|
185
|
-
const currentLanguage = story ? getLanguageFromStory(languages, story) : getLanguageFromNextLocaleIsoCode(languages, nextLocaleIsoCode);
|
|
186
|
-
const defaultLanguage = getDefaultLanguage(languages);
|
|
191
|
+
const currentLanguage = story ? (0, _index.getLanguageFromStory)(languages, story) : (0, _index.getLanguageFromNextLocaleIsoCode)(languages, nextLocaleIsoCode);
|
|
192
|
+
const defaultLanguage = (0, _index.getDefaultLanguage)(languages);
|
|
187
193
|
const {
|
|
188
194
|
code: localeCode
|
|
189
195
|
} = currentLanguage || defaultLanguage;
|
|
190
|
-
const locale = LocaleObject.fromAnyCode(localeCode);
|
|
196
|
+
const locale = _index.LocaleObject.fromAnyCode(localeCode);
|
|
191
197
|
|
|
192
198
|
// TODO: if no information given for current language, show boilerplate from default language
|
|
193
|
-
const companyInformation = getCompanyInformation(languages, locale);
|
|
194
|
-
const notifications = getNotifications(languages, locale);
|
|
195
|
-
const algoliaSettings = getAlgoliaSettings(request);
|
|
199
|
+
const companyInformation = (0, _index.getCompanyInformation)(languages, locale);
|
|
200
|
+
const notifications = (0, _index.getNotifications)(languages, locale);
|
|
201
|
+
const algoliaSettings = (0, _index3.getAlgoliaSettings)(request);
|
|
196
202
|
return {
|
|
197
203
|
newsroomContextProps: {
|
|
198
204
|
newsroom,
|
|
@@ -209,6 +215,7 @@ export class PrezlyApi {
|
|
|
209
215
|
}
|
|
210
216
|
async getNewsroomDefaultLanguage() {
|
|
211
217
|
const languages = await this.getNewsroomLanguages();
|
|
212
|
-
return getDefaultLanguage(languages);
|
|
218
|
+
return (0, _index.getDefaultLanguage)(languages);
|
|
213
219
|
}
|
|
214
|
-
}
|
|
220
|
+
}
|
|
221
|
+
exports.PrezlyApi = PrezlyApi;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getPrezlyApi = getPrezlyApi;
|
|
7
|
+
var _getEnvVariables = require("../lib/getEnvVariables.js");
|
|
8
|
+
var _PrezlyApi = require("./PrezlyApi.js");
|
|
9
|
+
function getPrezlyApi(req) {
|
|
4
10
|
if (typeof window !== 'undefined') {
|
|
5
11
|
throw new Error('"getPrezlyApi" should only be used on back-end side.');
|
|
6
12
|
}
|
|
@@ -10,12 +16,12 @@ export function getPrezlyApi(req) {
|
|
|
10
16
|
PREZLY_ACCESS_TOKEN,
|
|
11
17
|
PREZLY_NEWSROOM_UUID,
|
|
12
18
|
PREZLY_THEME_UUID
|
|
13
|
-
} = getEnvVariables(req);
|
|
19
|
+
} = (0, _getEnvVariables.getEnvVariables)(req);
|
|
14
20
|
if (!PREZLY_ACCESS_TOKEN) {
|
|
15
21
|
throw new Error('"PREZLY_ACCESS_TOKEN" is not set in env variables.');
|
|
16
22
|
}
|
|
17
23
|
if (!PREZLY_NEWSROOM_UUID) {
|
|
18
24
|
throw new Error('"PREZLY_NEWSROOM_UUID" is not set in env variables.');
|
|
19
25
|
}
|
|
20
|
-
return new PrezlyApi(PREZLY_ACCESS_TOKEN, PREZLY_NEWSROOM_UUID, PREZLY_THEME_UUID);
|
|
26
|
+
return new _PrezlyApi.PrezlyApi(PREZLY_ACCESS_TOKEN, PREZLY_NEWSROOM_UUID, PREZLY_THEME_UUID);
|
|
21
27
|
}
|
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _getPrezlyApi = require("./getPrezlyApi.js");
|
|
7
|
+
Object.keys(_getPrezlyApi).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _getPrezlyApi[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _getPrezlyApi[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getContactsQuery = getContactsQuery;
|
|
7
|
+
exports.getGalleriesQuery = getGalleriesQuery;
|
|
8
|
+
exports.getSlugQuery = getSlugQuery;
|
|
9
|
+
exports.getSortByPublishedDate = getSortByPublishedDate;
|
|
10
|
+
exports.getStoriesQuery = getStoriesQuery;
|
|
1
11
|
const publishedAndAccessible = [{
|
|
2
12
|
lifecycle_status: {
|
|
3
13
|
$in: ['published', 'embargo']
|
|
@@ -16,7 +26,7 @@ const publishedAndPublic = [{
|
|
|
16
26
|
$in: ['public']
|
|
17
27
|
}
|
|
18
28
|
}];
|
|
19
|
-
|
|
29
|
+
function getSlugQuery(newsroomUuid, slug) {
|
|
20
30
|
return {
|
|
21
31
|
$and: [{
|
|
22
32
|
'newsroom.uuid': {
|
|
@@ -29,7 +39,7 @@ export function getSlugQuery(newsroomUuid, slug) {
|
|
|
29
39
|
}, ...publishedAndAccessible]
|
|
30
40
|
};
|
|
31
41
|
}
|
|
32
|
-
|
|
42
|
+
function getStoriesQuery(newsroomUuid, categoryId, localeCode) {
|
|
33
43
|
const query = {
|
|
34
44
|
$and: [...publishedAndPublic, {
|
|
35
45
|
'newsroom.uuid': {
|
|
@@ -53,10 +63,10 @@ export function getStoriesQuery(newsroomUuid, categoryId, localeCode) {
|
|
|
53
63
|
}
|
|
54
64
|
return query;
|
|
55
65
|
}
|
|
56
|
-
|
|
66
|
+
function getSortByPublishedDate(order) {
|
|
57
67
|
return order === 'desc' ? '-published_at' : 'published_at';
|
|
58
68
|
}
|
|
59
|
-
|
|
69
|
+
function getGalleriesQuery() {
|
|
60
70
|
return {
|
|
61
71
|
$and: [{
|
|
62
72
|
status: {
|
|
@@ -69,7 +79,7 @@ export function getGalleriesQuery() {
|
|
|
69
79
|
}]
|
|
70
80
|
};
|
|
71
81
|
}
|
|
72
|
-
|
|
82
|
+
function getContactsQuery() {
|
|
73
83
|
return {
|
|
74
84
|
$and: [{
|
|
75
85
|
is_featured: {
|
|
@@ -1,3 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _index = require("./api/index.js");
|
|
7
|
+
Object.keys(_index).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _index[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _index[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _index2 = require("./lib/index.js");
|
|
18
|
+
Object.keys(_index2).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _index2[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _index2[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _types = require("./types.js");
|
|
29
|
+
Object.keys(_types).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _types[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getAlgoliaSettings = getAlgoliaSettings;
|
|
7
|
+
var _getEnvVariables = require("./getEnvVariables.js");
|
|
8
|
+
function getAlgoliaSettings(req) {
|
|
3
9
|
if (typeof window !== 'undefined') {
|
|
4
10
|
throw new Error('"getAlgoliaSettings" should only be used on back-end side.');
|
|
5
11
|
}
|
|
@@ -9,7 +15,7 @@ export function getAlgoliaSettings(req) {
|
|
|
9
15
|
ALGOLIA_API_KEY = '',
|
|
10
16
|
ALGOLIA_APP_ID = 'UI4CNRAHQB',
|
|
11
17
|
ALGOLIA_INDEX = 'public_stories_prod'
|
|
12
|
-
} = getEnvVariables(req);
|
|
18
|
+
} = (0, _getEnvVariables.getEnvVariables)(req);
|
|
13
19
|
if (!ALGOLIA_API_KEY) {
|
|
14
20
|
// eslint-disable-next-line no-console
|
|
15
21
|
console.error('"ALGOLIA_API_KEY" is not set in env variables. Search will not be enabled');
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getEnvVariables = getEnvVariables;
|
|
7
|
+
var _parseDataUrl = _interopRequireDefault(require("parse-data-url"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
9
|
function decodeJson(json) {
|
|
3
10
|
try {
|
|
4
11
|
const decoded = JSON.parse(json);
|
|
@@ -12,7 +19,7 @@ function decodeJson(json) {
|
|
|
12
19
|
}
|
|
13
20
|
function decodeHttpEnv(header) {
|
|
14
21
|
if (header.startsWith('data:')) {
|
|
15
|
-
const parsed =
|
|
22
|
+
const parsed = (0, _parseDataUrl.default)(header);
|
|
16
23
|
if (parsed && parsed.contentType === 'application/json') {
|
|
17
24
|
const data = parsed.toBuffer().toString('utf-8');
|
|
18
25
|
return decodeJson(data);
|
|
@@ -22,7 +29,7 @@ function decodeHttpEnv(header) {
|
|
|
22
29
|
|
|
23
30
|
return decodeJson(header);
|
|
24
31
|
}
|
|
25
|
-
|
|
32
|
+
function getEnvVariables(req) {
|
|
26
33
|
if (typeof window !== 'undefined') {
|
|
27
34
|
throw new Error('"getEnvVariables" should only be used on back-end side.');
|
|
28
35
|
}
|
|
@@ -1,4 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "getAlgoliaSettings", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _getAlgoliaSettings.getAlgoliaSettings;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "getEnvVariables", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _getEnvVariables.getEnvVariables;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "isSdkError", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _isSdkError.isSdkError;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "isUuid", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _isUuid.isUuid;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
var _getAlgoliaSettings = require("./getAlgoliaSettings.js");
|
|
31
|
+
var _getEnvVariables = require("./getEnvVariables.js");
|
|
32
|
+
var _isSdkError = require("./isSdkError.js");
|
|
33
|
+
var _isUuid = require("./isUuid.js");
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isUuid = isUuid;
|
|
1
7
|
const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
2
|
-
|
|
8
|
+
function isUuid(input) {
|
|
3
9
|
return UUID_REGEX.test(input);
|
|
4
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
package/build/index.js
CHANGED
|
@@ -1,9 +1,104 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _index = require("./adapter-nextjs/index.js");
|
|
7
|
+
Object.keys(_index).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _index[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _index[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _index2 = require("./components-nextjs/index.js");
|
|
18
|
+
Object.keys(_index2).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _index2[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _index2[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _index3 = require("./data-fetching/index.js");
|
|
29
|
+
Object.keys(_index3).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _index3[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _index3[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _index4 = require("./infinite-loading/index.js");
|
|
40
|
+
Object.keys(_index4).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _index4[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _index4[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var _index5 = require("./intl/index.js");
|
|
51
|
+
Object.keys(_index5).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _index5[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _index5[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
var _index6 = require("./newsroom-context/index.js");
|
|
62
|
+
Object.keys(_index6).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (key in exports && exports[key] === _index6[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _index6[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
var _index7 = require("./sentry/index.js");
|
|
73
|
+
Object.keys(_index7).forEach(function (key) {
|
|
74
|
+
if (key === "default" || key === "__esModule") return;
|
|
75
|
+
if (key in exports && exports[key] === _index7[key]) return;
|
|
76
|
+
Object.defineProperty(exports, key, {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () {
|
|
79
|
+
return _index7[key];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
var _types = require("./types.js");
|
|
84
|
+
Object.keys(_types).forEach(function (key) {
|
|
85
|
+
if (key === "default" || key === "__esModule") return;
|
|
86
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
87
|
+
Object.defineProperty(exports, key, {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return _types[key];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
var _index8 = require("./utils/index.js");
|
|
95
|
+
Object.keys(_index8).forEach(function (key) {
|
|
96
|
+
if (key === "default" || key === "__esModule") return;
|
|
97
|
+
if (key in exports && exports[key] === _index8[key]) return;
|
|
98
|
+
Object.defineProperty(exports, key, {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () {
|
|
101
|
+
return _index8[key];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -1,4 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
useInfiniteLoading: true,
|
|
8
|
+
useInfiniteStoriesLoading: true,
|
|
9
|
+
useInfiniteGalleriesLoading: true
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "useInfiniteGalleriesLoading", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () {
|
|
14
|
+
return _useInfiniteGalleriesLoading.useInfiniteGalleriesLoading;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "useInfiniteLoading", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () {
|
|
20
|
+
return _useInfiniteLoading.useInfiniteLoading;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "useInfiniteStoriesLoading", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () {
|
|
26
|
+
return _useInfiniteStoriesLoading.useInfiniteStoriesLoading;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
var _useInfiniteLoading = require("./useInfiniteLoading.js");
|
|
30
|
+
var _useInfiniteStoriesLoading = require("./useInfiniteStoriesLoading.js");
|
|
31
|
+
var _useInfiniteGalleriesLoading = require("./useInfiniteGalleriesLoading.js");
|
|
32
|
+
var _types = require("./types.js");
|
|
33
|
+
Object.keys(_types).forEach(function (key) {
|
|
34
|
+
if (key === "default" || key === "__esModule") return;
|
|
35
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
36
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
37
|
+
Object.defineProperty(exports, key, {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () {
|
|
40
|
+
return _types[key];
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useInfiniteGalleriesLoading = useInfiniteGalleriesLoading;
|
|
7
|
+
var _useInfiniteLoading = require("./useInfiniteLoading.js");
|
|
2
8
|
async function fetchGalleries(page, pageSize) {
|
|
3
9
|
const result = await fetch('/api/fetch-galleries', {
|
|
4
10
|
method: 'POST',
|
|
@@ -24,13 +30,13 @@ async function fetchGalleries(page, pageSize) {
|
|
|
24
30
|
* The handler for this route is exported from `apiHandlers/fetchGalleries.ts` file.
|
|
25
31
|
* See https://github.com/prezly/theme-nextjs-bea/blob/d381e9878187ca98815d240d3ffdf10a75993c14/pages/media/index.tsx#L23 for usage example
|
|
26
32
|
*/
|
|
27
|
-
|
|
33
|
+
function useInfiniteGalleriesLoading(initialGalleries, pagination) {
|
|
28
34
|
const {
|
|
29
35
|
canLoadMore,
|
|
30
36
|
data,
|
|
31
37
|
isLoading,
|
|
32
38
|
loadMore
|
|
33
|
-
} = useInfiniteLoading({
|
|
39
|
+
} = (0, _useInfiniteLoading.useInfiniteLoading)({
|
|
34
40
|
fetchingFn: async (nextPage, pageSize) => {
|
|
35
41
|
const {
|
|
36
42
|
galleries
|