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