@prezly/theme-kit-nextjs 2.0.0-0 → 2.0.0-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/README.md +8 -13
- package/build/@types/global.d.js +1 -0
- package/build/adapter-nextjs/api-handlers/fetchGalleries.js +26 -18
- package/build/adapter-nextjs/api-handlers/fetchStories.js +36 -20
- package/build/adapter-nextjs/api-handlers/index.js +2 -3
- package/build/adapter-nextjs/getNewsroomServerSideProps.js +15 -10
- package/build/adapter-nextjs/getNewsroomStaticProps.js +14 -10
- package/build/adapter-nextjs/index.js +6 -7
- package/build/adapter-nextjs/page-props/category.js +115 -91
- package/build/adapter-nextjs/page-props/gallery.js +85 -61
- package/build/adapter-nextjs/page-props/galleryAlbum.js +61 -44
- package/build/adapter-nextjs/page-props/home.js +81 -62
- package/build/adapter-nextjs/page-props/index.js +8 -9
- package/build/adapter-nextjs/page-props/lib/types.js +1 -2
- package/build/adapter-nextjs/page-props/search.js +23 -24
- package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js +28 -45
- package/build/adapter-nextjs/page-props/sitemap/createPaths.js +12 -14
- package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js +32 -30
- package/build/adapter-nextjs/page-props/sitemap/index.js +4 -5
- package/build/adapter-nextjs/page-props/sitemap/types.js +1 -2
- package/build/adapter-nextjs/page-props/story.js +74 -55
- package/build/adapter-nextjs/page-props/storyPreview.js +26 -21
- package/build/adapter-nextjs/processRequest.js +33 -20
- package/build/adapter-nextjs/processStaticRequest.js +18 -11
- package/build/components-nextjs/PageSeo/PageSeo.js +81 -71
- package/build/components-nextjs/PageSeo/index.js +2 -3
- package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js +4 -5
- package/build/components-nextjs/PageSeo/lib/types.js +1 -2
- package/build/components-nextjs/StorySeo/StorySeo.js +67 -41
- package/build/components-nextjs/StorySeo/index.js +1 -2
- package/build/components-nextjs/document.js +29 -19
- package/build/components-nextjs/index.js +3 -4
- package/build/data-fetching/api/PrezlyApi.js +205 -185
- package/build/data-fetching/api/getPrezlyApi.js +20 -16
- package/build/data-fetching/api/index.js +1 -2
- package/build/data-fetching/api/queries.js +71 -34
- package/build/data-fetching/index.js +3 -4
- package/build/data-fetching/lib/getAlgoliaSettings.js +21 -17
- package/build/data-fetching/lib/getEnvVariables.js +33 -29
- package/build/data-fetching/lib/index.js +4 -5
- package/build/data-fetching/lib/isSdkError.js +2 -3
- package/build/data-fetching/lib/isUuid.js +2 -3
- package/build/data-fetching/types.js +1 -2
- package/build/index.js +9 -10
- package/build/infinite-loading/index.js +4 -5
- package/build/infinite-loading/types.js +1 -2
- package/build/infinite-loading/useInfiniteGalleriesLoading.js +41 -32
- package/build/infinite-loading/useInfiniteLoading.js +48 -37
- package/build/infinite-loading/useInfiniteStoriesLoading.js +54 -44
- package/build/intl/index.d.ts +1 -1
- package/build/intl/index.js +4 -5
- package/build/intl/index.js.map +1 -1
- package/build/intl/languages.js +135 -97
- package/build/intl/languages.js.map +1 -1
- package/build/intl/locale.d.ts +0 -1
- package/build/intl/locale.js +47 -97
- package/build/intl/locale.js.map +1 -1
- package/build/intl/localeConfig.d.ts +3 -1
- package/build/intl/localeConfig.js +20 -13
- package/build/intl/localeConfig.js.map +1 -1
- package/build/intl/localeList.js +1 -108
- package/build/intl/localeObject.js +79 -74
- package/build/intl/localeObject.js.map +1 -1
- package/build/newsroom-context/context.js +34 -20
- package/build/newsroom-context/hooks/index.js +11 -12
- package/build/newsroom-context/hooks/useAlgoliaSettings.js +4 -5
- package/build/newsroom-context/hooks/useCategories.js +4 -5
- package/build/newsroom-context/hooks/useCompanyInformation.js +4 -5
- package/build/newsroom-context/hooks/useCurrentCategory.js +4 -5
- package/build/newsroom-context/hooks/useCurrentLocale.js +4 -5
- package/build/newsroom-context/hooks/useCurrentStory.js +4 -5
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js +15 -15
- package/build/newsroom-context/hooks/useGetTranslationUrl.js +48 -44
- package/build/newsroom-context/hooks/useLanguages.js +4 -5
- package/build/newsroom-context/hooks/useNewsroom.js +4 -5
- package/build/newsroom-context/hooks/useNewsroomContext.js +9 -10
- package/build/newsroom-context/index.js +2 -3
- package/build/sentry/client.js +3 -4
- package/build/sentry/common.js +25 -24
- package/build/sentry/index.js +2 -3
- package/build/sentry/server.js +3 -4
- package/build/types.js +1 -2
- package/build/utils/boilerplate.js +4 -13
- package/build/utils/constants.js +1 -2
- package/build/utils/getAssetsUrl.js +3 -4
- package/build/utils/getDataRequestLink.js +5 -7
- package/build/utils/getLocalizedCategoryData.js +30 -24
- package/build/utils/getNewsroomLogoUrl.js +12 -13
- package/build/utils/getPrivacyPortalUrl.js +10 -8
- package/build/utils/getStoryPublicationDate.js +8 -9
- package/build/utils/getUploadcareGroupUrl.js +4 -5
- package/build/utils/index.js +10 -11
- package/build/utils/isEmbargoStory.js +2 -3
- package/package.json +17 -2
- package/build/tsconfig.tsbuildinfo +0 -1
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export { NewsroomContext, NewsroomContextProvider } from
|
|
2
|
-
export * from
|
|
3
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { NewsroomContext, NewsroomContextProvider, NewsroomContextProps } from "./context.js";
|
|
2
|
+
export * from "./hooks/index.js";
|
package/build/sentry/client.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { getCommonClientOptions } from
|
|
1
|
+
import { getCommonClientOptions } from "./common.js";
|
|
2
2
|
export function getSentryClientOptions(dsn, themeName) {
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
//# sourceMappingURL=client.js.map
|
|
3
|
+
return getCommonClientOptions(dsn, themeName);
|
|
4
|
+
}
|
package/build/sentry/common.js
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
export function getCommonClientOptions(dsn, themeName) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
2
|
+
return {
|
|
3
|
+
dsn,
|
|
4
|
+
// Adjust this value in production, or use tracesSampler for greater control
|
|
5
|
+
tracesSampleRate: 0.02,
|
|
6
|
+
// ...
|
|
7
|
+
// Note: if you want to override the automatic release value, do not set a
|
|
8
|
+
// `release` value here - use the environment variable `SENTRY_RELEASE`, so
|
|
9
|
+
// that it will also get attached to your source maps
|
|
10
|
+
|
|
11
|
+
ignoreErrors: [
|
|
12
|
+
// This particular error is coming from Microsoft Outlook SafeLink crawler.
|
|
13
|
+
// It doesn't affect the user experience in any way, but produces a lot of unwanted Sentry events.
|
|
14
|
+
// See https://forum.sentry.io/t/unhandledrejection-non-error-promise-rejection-captured-with-value/14062
|
|
15
|
+
'Object Not Found Matching Id',
|
|
16
|
+
// This error is caused by `beacon.min.js` polyfill in Cloudflare Insights. From what we see, it doesn't affect the user experience.
|
|
17
|
+
'Illegal invocation'],
|
|
18
|
+
// Attach theme tag to each event
|
|
19
|
+
initialScope: scope => {
|
|
20
|
+
scope.setTags({
|
|
21
|
+
prezly_theme: themeName
|
|
22
|
+
});
|
|
23
|
+
return scope;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
package/build/sentry/index.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export { getSentryClientOptions } from
|
|
2
|
-
export { getSentryServerOptions } from
|
|
3
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { getSentryClientOptions } from "./client.js";
|
|
2
|
+
export { getSentryServerOptions } from "./server.js";
|
package/build/sentry/server.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { getCommonClientOptions } from
|
|
1
|
+
import { getCommonClientOptions } from "./common.js";
|
|
2
2
|
export function getSentryServerOptions(dsn, themeName) {
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
//# sourceMappingURL=server.js.map
|
|
3
|
+
return getCommonClientOptions(dsn, themeName);
|
|
4
|
+
}
|
package/build/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
//# sourceMappingURL=types.js.map
|
|
1
|
+
export {};
|
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
export function hasAnySocialMedia(companyInformation) {
|
|
2
|
-
|
|
3
|
-
companyInformation.instagram ||
|
|
4
|
-
companyInformation.linkedin ||
|
|
5
|
-
companyInformation.pinterest ||
|
|
6
|
-
companyInformation.tiktok ||
|
|
7
|
-
companyInformation.twitter ||
|
|
8
|
-
companyInformation.youtube);
|
|
2
|
+
return Boolean(companyInformation.facebook || companyInformation.instagram || companyInformation.linkedin || companyInformation.pinterest || companyInformation.tiktok || companyInformation.twitter || companyInformation.youtube);
|
|
9
3
|
}
|
|
10
4
|
export function hasAnyAboutInformation(companyInformation) {
|
|
11
|
-
|
|
12
|
-
companyInformation.website ||
|
|
13
|
-
hasAnySocialMedia(companyInformation));
|
|
5
|
+
return Boolean(companyInformation.about || companyInformation.website || hasAnySocialMedia(companyInformation));
|
|
14
6
|
}
|
|
15
7
|
export function hasAnyContactInformation(companyInformation) {
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=boilerplate.js.map
|
|
8
|
+
return Boolean(companyInformation.address || companyInformation.phone || companyInformation.email);
|
|
9
|
+
}
|
package/build/utils/constants.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { ASSETS_URL } from
|
|
1
|
+
import { ASSETS_URL } from "./constants.js";
|
|
2
2
|
/**
|
|
3
3
|
* @param uuid UUID of the assets hosted on Uploadcare
|
|
4
4
|
* @returns Full asset URL that can be used as a source for <img>, <video> and <a> tags.
|
|
5
5
|
*/
|
|
6
6
|
export function getAssetsUrl(uuid) {
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=getAssetsUrl.js.map
|
|
7
|
+
return `${ASSETS_URL}/${uuid}/`;
|
|
8
|
+
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { getPrivacyPortalUrl } from
|
|
1
|
+
import { getPrivacyPortalUrl } from "./getPrivacyPortalUrl.js";
|
|
2
2
|
export function getDataRequestLink(newsroom, currentLocale) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=getDataRequestLink.js.map
|
|
3
|
+
return newsroom.custom_data_request_link || getPrivacyPortalUrl(newsroom, currentLocale, {
|
|
4
|
+
action: 'data-request'
|
|
5
|
+
});
|
|
6
|
+
}
|
|
@@ -1,31 +1,37 @@
|
|
|
1
1
|
function isAlgoliaCategory(category) {
|
|
2
|
-
|
|
2
|
+
return 'name' in category && 'slug' in category;
|
|
3
3
|
}
|
|
4
4
|
export function getLocalizedCategoryData(category, locale) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
if (isAlgoliaCategory(category)) {
|
|
6
|
+
return {
|
|
7
|
+
description: null,
|
|
8
|
+
name: category.name,
|
|
9
|
+
slug: category.slug
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
const targetLocaleCode = locale.toUnderscoreCode();
|
|
13
|
+
const {
|
|
14
|
+
i18n
|
|
15
|
+
} = category;
|
|
16
|
+
const populatedLocales = Object.keys(i18n).filter(localeCode => i18n[localeCode].name);
|
|
17
|
+
const targetLocale = populatedLocales.find(localeCode => localeCode === targetLocaleCode) || populatedLocales.find(localeCode => i18n[localeCode].name === category.display_name) || populatedLocales[0];
|
|
18
|
+
const {
|
|
19
|
+
locale: _,
|
|
20
|
+
...localizedData
|
|
21
|
+
} = i18n[targetLocale];
|
|
22
|
+
return localizedData;
|
|
20
23
|
}
|
|
21
24
|
export function getCategoryUrl(category, locale) {
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
const {
|
|
26
|
+
slug
|
|
27
|
+
} = getLocalizedCategoryData(category, locale);
|
|
28
|
+
return `/category/${slug}`;
|
|
24
29
|
}
|
|
25
30
|
export function getCategoryHasTranslation(category, locale) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
const targetLocaleCode = locale.toUnderscoreCode();
|
|
32
|
+
const {
|
|
33
|
+
i18n
|
|
34
|
+
} = category;
|
|
35
|
+
const populatedLocales = Object.keys(i18n).filter(localeCode => i18n[localeCode].name);
|
|
36
|
+
return Boolean(populatedLocales.find(localeCode => localeCode === targetLocaleCode));
|
|
37
|
+
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { UploadcareImage } from '@prezly/uploadcare';
|
|
2
2
|
export function getNewsroomLogoUrl(newsroom) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
if (newsroom.newsroom_logo) {
|
|
4
|
+
const image = UploadcareImage.createFromPrezlyStoragePayload(newsroom.newsroom_logo);
|
|
5
|
+
return image.cdnUrl;
|
|
6
|
+
}
|
|
7
|
+
return '';
|
|
8
8
|
}
|
|
9
9
|
export function getNewsroomFaviconUrl(newsroom, previewSize = 400) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=getNewsroomLogoUrl.js.map
|
|
10
|
+
const imageObject = newsroom.icon || newsroom.square_logo;
|
|
11
|
+
if (imageObject) {
|
|
12
|
+
const image = UploadcareImage.createFromPrezlyStoragePayload(imageObject);
|
|
13
|
+
return image.preview(previewSize, previewSize).cdnUrl;
|
|
14
|
+
}
|
|
15
|
+
return '';
|
|
16
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export function getPrivacyPortalUrl(newsroom, locale, options) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
const {
|
|
3
|
+
email,
|
|
4
|
+
action = 'subscribe'
|
|
5
|
+
} = options || {};
|
|
6
|
+
const url = new URL(`/${locale.toUrlSlug()}/newsroom/${newsroom.uuid}/${action}`, 'https://privacy.prezly.com');
|
|
7
|
+
if (email) {
|
|
8
|
+
url.searchParams.append('email', email);
|
|
9
|
+
}
|
|
10
|
+
return url.toString();
|
|
11
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
export function getStoryPublicationDate(story) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=getStoryPublicationDate.js.map
|
|
2
|
+
const {
|
|
3
|
+
published_at
|
|
4
|
+
} = story;
|
|
5
|
+
if (!published_at) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
return typeof published_at === 'string' ? new Date(published_at) : new Date(published_at * 1000);
|
|
9
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ASSETS_URL } from
|
|
1
|
+
import { ASSETS_URL } from "./constants.js";
|
|
2
2
|
/**
|
|
3
3
|
* This method constructs a URL to download all images in the Gallery as a single archive.
|
|
4
4
|
*
|
|
@@ -7,7 +7,6 @@ import { ASSETS_URL } from './constants';
|
|
|
7
7
|
* @returns URL to an archive containing all of the images in the Gallery.
|
|
8
8
|
*/
|
|
9
9
|
export function getUploadcareGroupUrl(uuid, title) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=getUploadcareGroupUrl.js.map
|
|
10
|
+
// UploadCare doesn't like slashes in filenames even in encoded form.
|
|
11
|
+
return `${ASSETS_URL}/${uuid}/archive/zip/${encodeURIComponent(title.replace('/', '_'))}.zip`;
|
|
12
|
+
}
|
package/build/utils/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from "./boilerplate.js";
|
|
2
|
+
export * from "./constants.js";
|
|
3
|
+
export * from "./getAssetsUrl.js";
|
|
4
|
+
export * from "./getDataRequestLink.js";
|
|
5
|
+
export * from "./getLocalizedCategoryData.js";
|
|
6
|
+
export * from "./getNewsroomLogoUrl.js";
|
|
7
|
+
export * from "./getPrivacyPortalUrl.js";
|
|
8
|
+
export * from "./getStoryPublicationDate.js";
|
|
9
|
+
export * from "./getUploadcareGroupUrl.js";
|
|
10
|
+
export * from "./isEmbargoStory.js";
|
package/package.json
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prezly/theme-kit-nextjs",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-2",
|
|
4
4
|
"description": "Data layer and utility library for developing Prezly themes with NextJS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "build/index.js",
|
|
7
7
|
"types": "build/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./build/index.d.ts",
|
|
11
|
+
"import": "./build/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./localeConfig": "./build/intl/localeConfig.js"
|
|
14
|
+
},
|
|
8
15
|
"files": [
|
|
9
16
|
"build"
|
|
10
17
|
],
|
|
@@ -29,7 +36,10 @@
|
|
|
29
36
|
"homepage": "https://github.com/prezly/theme-kit-nextjs#readme",
|
|
30
37
|
"scripts": {
|
|
31
38
|
"clean": "rimraf build/ node_modules/",
|
|
32
|
-
"
|
|
39
|
+
"prebuild": "rimraf build/",
|
|
40
|
+
"build": "npm run build:types && npm run build:es",
|
|
41
|
+
"build:types": "tsc --project .",
|
|
42
|
+
"build:es": "babel ./src --ignore='**/*.test.ts','**/__mocks__/**' --config-file=./babel.config.json --extensions=.ts,.tsx --source-root=./src --out-dir=./build",
|
|
33
43
|
"watch": "tsc --watch --preserveWatchOutput --project .",
|
|
34
44
|
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
35
45
|
"typecheck": "tsc --noEmit --incremental --project .",
|
|
@@ -55,6 +65,10 @@
|
|
|
55
65
|
"parse-data-url": "^4.0.1"
|
|
56
66
|
},
|
|
57
67
|
"devDependencies": {
|
|
68
|
+
"@babel/cli": "7.19.3",
|
|
69
|
+
"@babel/preset-env": "^7.19.4",
|
|
70
|
+
"@babel/preset-react": "7.18.6",
|
|
71
|
+
"@babel/preset-typescript": "7.18.6",
|
|
58
72
|
"@prezly/eslint-config": "4.2.0",
|
|
59
73
|
"@sentry/nextjs": "7.17.1",
|
|
60
74
|
"@types/jest": "29.2.0",
|
|
@@ -62,6 +76,7 @@
|
|
|
62
76
|
"@types/parse-data-url": "3.0.0",
|
|
63
77
|
"@types/react": "18.0.24",
|
|
64
78
|
"@types/react-dom": "18.0.8",
|
|
79
|
+
"babel-plugin-add-import-extension": "1.6.0",
|
|
65
80
|
"eslint": "8.26.0",
|
|
66
81
|
"jest": "29.2.2",
|
|
67
82
|
"np": "7.6.2",
|