@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.
Files changed (95) hide show
  1. package/README.md +8 -13
  2. package/build/@types/global.d.js +1 -0
  3. package/build/adapter-nextjs/api-handlers/fetchGalleries.js +26 -18
  4. package/build/adapter-nextjs/api-handlers/fetchStories.js +36 -20
  5. package/build/adapter-nextjs/api-handlers/index.js +2 -3
  6. package/build/adapter-nextjs/getNewsroomServerSideProps.js +15 -10
  7. package/build/adapter-nextjs/getNewsroomStaticProps.js +14 -10
  8. package/build/adapter-nextjs/index.js +6 -7
  9. package/build/adapter-nextjs/page-props/category.js +115 -91
  10. package/build/adapter-nextjs/page-props/gallery.js +85 -61
  11. package/build/adapter-nextjs/page-props/galleryAlbum.js +61 -44
  12. package/build/adapter-nextjs/page-props/home.js +81 -62
  13. package/build/adapter-nextjs/page-props/index.js +8 -9
  14. package/build/adapter-nextjs/page-props/lib/types.js +1 -2
  15. package/build/adapter-nextjs/page-props/search.js +23 -24
  16. package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js +28 -45
  17. package/build/adapter-nextjs/page-props/sitemap/createPaths.js +12 -14
  18. package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js +32 -30
  19. package/build/adapter-nextjs/page-props/sitemap/index.js +4 -5
  20. package/build/adapter-nextjs/page-props/sitemap/types.js +1 -2
  21. package/build/adapter-nextjs/page-props/story.js +74 -55
  22. package/build/adapter-nextjs/page-props/storyPreview.js +26 -21
  23. package/build/adapter-nextjs/processRequest.js +33 -20
  24. package/build/adapter-nextjs/processStaticRequest.js +18 -11
  25. package/build/components-nextjs/PageSeo/PageSeo.js +81 -71
  26. package/build/components-nextjs/PageSeo/index.js +2 -3
  27. package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js +4 -5
  28. package/build/components-nextjs/PageSeo/lib/types.js +1 -2
  29. package/build/components-nextjs/StorySeo/StorySeo.js +67 -41
  30. package/build/components-nextjs/StorySeo/index.js +1 -2
  31. package/build/components-nextjs/document.js +29 -19
  32. package/build/components-nextjs/index.js +3 -4
  33. package/build/data-fetching/api/PrezlyApi.js +205 -185
  34. package/build/data-fetching/api/getPrezlyApi.js +20 -16
  35. package/build/data-fetching/api/index.js +1 -2
  36. package/build/data-fetching/api/queries.js +71 -34
  37. package/build/data-fetching/index.js +3 -4
  38. package/build/data-fetching/lib/getAlgoliaSettings.js +21 -17
  39. package/build/data-fetching/lib/getEnvVariables.js +33 -29
  40. package/build/data-fetching/lib/index.js +4 -5
  41. package/build/data-fetching/lib/isSdkError.js +2 -3
  42. package/build/data-fetching/lib/isUuid.js +2 -3
  43. package/build/data-fetching/types.js +1 -2
  44. package/build/index.js +9 -10
  45. package/build/infinite-loading/index.js +4 -5
  46. package/build/infinite-loading/types.js +1 -2
  47. package/build/infinite-loading/useInfiniteGalleriesLoading.js +41 -32
  48. package/build/infinite-loading/useInfiniteLoading.js +48 -37
  49. package/build/infinite-loading/useInfiniteStoriesLoading.js +54 -44
  50. package/build/intl/index.d.ts +1 -1
  51. package/build/intl/index.js +4 -5
  52. package/build/intl/index.js.map +1 -1
  53. package/build/intl/languages.js +135 -97
  54. package/build/intl/languages.js.map +1 -1
  55. package/build/intl/locale.d.ts +0 -1
  56. package/build/intl/locale.js +47 -97
  57. package/build/intl/locale.js.map +1 -1
  58. package/build/intl/localeConfig.d.ts +3 -1
  59. package/build/intl/localeConfig.js +20 -13
  60. package/build/intl/localeConfig.js.map +1 -1
  61. package/build/intl/localeList.js +1 -108
  62. package/build/intl/localeObject.js +79 -74
  63. package/build/intl/localeObject.js.map +1 -1
  64. package/build/newsroom-context/context.js +34 -20
  65. package/build/newsroom-context/hooks/index.js +11 -12
  66. package/build/newsroom-context/hooks/useAlgoliaSettings.js +4 -5
  67. package/build/newsroom-context/hooks/useCategories.js +4 -5
  68. package/build/newsroom-context/hooks/useCompanyInformation.js +4 -5
  69. package/build/newsroom-context/hooks/useCurrentCategory.js +4 -5
  70. package/build/newsroom-context/hooks/useCurrentLocale.js +4 -5
  71. package/build/newsroom-context/hooks/useCurrentStory.js +4 -5
  72. package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js +15 -15
  73. package/build/newsroom-context/hooks/useGetTranslationUrl.js +48 -44
  74. package/build/newsroom-context/hooks/useLanguages.js +4 -5
  75. package/build/newsroom-context/hooks/useNewsroom.js +4 -5
  76. package/build/newsroom-context/hooks/useNewsroomContext.js +9 -10
  77. package/build/newsroom-context/index.js +2 -3
  78. package/build/sentry/client.js +3 -4
  79. package/build/sentry/common.js +25 -24
  80. package/build/sentry/index.js +2 -3
  81. package/build/sentry/server.js +3 -4
  82. package/build/types.js +1 -2
  83. package/build/utils/boilerplate.js +4 -13
  84. package/build/utils/constants.js +1 -2
  85. package/build/utils/getAssetsUrl.js +3 -4
  86. package/build/utils/getDataRequestLink.js +5 -7
  87. package/build/utils/getLocalizedCategoryData.js +30 -24
  88. package/build/utils/getNewsroomLogoUrl.js +12 -13
  89. package/build/utils/getPrivacyPortalUrl.js +10 -8
  90. package/build/utils/getStoryPublicationDate.js +8 -9
  91. package/build/utils/getUploadcareGroupUrl.js +4 -5
  92. package/build/utils/index.js +10 -11
  93. package/build/utils/isEmbargoStory.js +2 -3
  94. package/package.json +17 -2
  95. package/build/tsconfig.tsbuildinfo +0 -1
@@ -1,3 +1,2 @@
1
- export { NewsroomContext, NewsroomContextProvider } from './context';
2
- export * from './hooks';
3
- //# sourceMappingURL=index.js.map
1
+ export { NewsroomContext, NewsroomContextProvider, NewsroomContextProps } from "./context.js";
2
+ export * from "./hooks/index.js";
@@ -1,5 +1,4 @@
1
- import { getCommonClientOptions } from './common';
1
+ import { getCommonClientOptions } from "./common.js";
2
2
  export function getSentryClientOptions(dsn, themeName) {
3
- return getCommonClientOptions(dsn, themeName);
4
- }
5
- //# sourceMappingURL=client.js.map
3
+ return getCommonClientOptions(dsn, themeName);
4
+ }
@@ -1,25 +1,26 @@
1
1
  export function getCommonClientOptions(dsn, themeName) {
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
- ignoreErrors: [
11
- // This particular error is coming from Microsoft Outlook SafeLink crawler.
12
- // It doesn't affect the user experience in any way, but produces a lot of unwanted Sentry events.
13
- // See https://forum.sentry.io/t/unhandledrejection-non-error-promise-rejection-captured-with-value/14062
14
- 'Object Not Found Matching Id',
15
- // This error is caused by `beacon.min.js` polyfill in Cloudflare Insights. From what we see, it doesn't affect the user experience.
16
- 'Illegal invocation',
17
- ],
18
- // Attach theme tag to each event
19
- initialScope: (scope) => {
20
- scope.setTags({ prezly_theme: themeName });
21
- return scope;
22
- },
23
- };
24
- }
25
- //# sourceMappingURL=common.js.map
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
+ }
@@ -1,3 +1,2 @@
1
- export { getSentryClientOptions } from './client';
2
- export { getSentryServerOptions } from './server';
3
- //# sourceMappingURL=index.js.map
1
+ export { getSentryClientOptions } from "./client.js";
2
+ export { getSentryServerOptions } from "./server.js";
@@ -1,5 +1,4 @@
1
- import { getCommonClientOptions } from './common';
1
+ import { getCommonClientOptions } from "./common.js";
2
2
  export function getSentryServerOptions(dsn, themeName) {
3
- return getCommonClientOptions(dsn, themeName);
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
- return Boolean(companyInformation.facebook ||
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
- return Boolean(companyInformation.about ||
12
- companyInformation.website ||
13
- hasAnySocialMedia(companyInformation));
5
+ return Boolean(companyInformation.about || companyInformation.website || hasAnySocialMedia(companyInformation));
14
6
  }
15
7
  export function hasAnyContactInformation(companyInformation) {
16
- return Boolean(companyInformation.address || companyInformation.phone || companyInformation.email);
17
- }
18
- //# sourceMappingURL=boilerplate.js.map
8
+ return Boolean(companyInformation.address || companyInformation.phone || companyInformation.email);
9
+ }
@@ -1,4 +1,3 @@
1
1
  export const ASSETS_URL = 'https://cdn.uc.assets.prezly.com';
2
2
  export const DEFAULT_PAGE_SIZE = 12;
3
- export const DEFAULT_GALLERY_PAGE_SIZE = 6;
4
- //# sourceMappingURL=constants.js.map
3
+ export const DEFAULT_GALLERY_PAGE_SIZE = 6;
@@ -1,9 +1,8 @@
1
- import { ASSETS_URL } from './constants';
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
- return `${ASSETS_URL}/${uuid}/`;
8
- }
9
- //# sourceMappingURL=getAssetsUrl.js.map
7
+ return `${ASSETS_URL}/${uuid}/`;
8
+ }
@@ -1,8 +1,6 @@
1
- import { getPrivacyPortalUrl } from './getPrivacyPortalUrl';
1
+ import { getPrivacyPortalUrl } from "./getPrivacyPortalUrl.js";
2
2
  export function getDataRequestLink(newsroom, currentLocale) {
3
- return (newsroom.custom_data_request_link ||
4
- getPrivacyPortalUrl(newsroom, currentLocale, {
5
- action: 'data-request',
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
- return 'name' in category && 'slug' in category;
2
+ return 'name' in category && 'slug' in category;
3
3
  }
4
4
  export function getLocalizedCategoryData(category, locale) {
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 { i18n } = category;
14
- const populatedLocales = Object.keys(i18n).filter((localeCode) => i18n[localeCode].name);
15
- const targetLocale = populatedLocales.find((localeCode) => localeCode === targetLocaleCode) ||
16
- populatedLocales.find((localeCode) => i18n[localeCode].name === category.display_name) ||
17
- populatedLocales[0];
18
- const { locale: _, ...localizedData } = i18n[targetLocale];
19
- return localizedData;
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
- const { slug } = getLocalizedCategoryData(category, locale);
23
- return `/category/${slug}`;
25
+ const {
26
+ slug
27
+ } = getLocalizedCategoryData(category, locale);
28
+ return `/category/${slug}`;
24
29
  }
25
30
  export function getCategoryHasTranslation(category, locale) {
26
- const targetLocaleCode = locale.toUnderscoreCode();
27
- const { i18n } = category;
28
- const populatedLocales = Object.keys(i18n).filter((localeCode) => i18n[localeCode].name);
29
- return Boolean(populatedLocales.find((localeCode) => localeCode === targetLocaleCode));
30
- }
31
- //# sourceMappingURL=getLocalizedCategoryData.js.map
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
- if (newsroom.newsroom_logo) {
4
- const image = UploadcareImage.createFromPrezlyStoragePayload(newsroom.newsroom_logo);
5
- return image.cdnUrl;
6
- }
7
- return '';
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
- 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
- }
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
- const { email, action = 'subscribe' } = options || {};
3
- const url = new URL(`/${locale.toUrlSlug()}/newsroom/${newsroom.uuid}/${action}`, 'https://privacy.prezly.com');
4
- if (email) {
5
- url.searchParams.append('email', email);
6
- }
7
- return url.toString();
8
- }
9
- //# sourceMappingURL=getPrivacyPortalUrl.js.map
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
- const { published_at } = story;
3
- if (!published_at) {
4
- return null;
5
- }
6
- return typeof published_at === 'string'
7
- ? new Date(published_at)
8
- : new Date(published_at * 1000);
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 './constants';
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
- // UploadCare doesn't like slashes in filenames even in encoded form.
11
- return `${ASSETS_URL}/${uuid}/archive/zip/${encodeURIComponent(title.replace('/', '_'))}.zip`;
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
+ }
@@ -1,11 +1,10 @@
1
- export * from './boilerplate';
2
- export * from './constants';
3
- export * from './getAssetsUrl';
4
- export * from './getDataRequestLink';
5
- export * from './getLocalizedCategoryData';
6
- export * from './getNewsroomLogoUrl';
7
- export * from './getPrivacyPortalUrl';
8
- export * from './getStoryPublicationDate';
9
- export * from './getUploadcareGroupUrl';
10
- export * from './isEmbargoStory';
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";
@@ -1,4 +1,3 @@
1
1
  export function isEmbargoStory(story) {
2
- return story.is_embargo && Boolean(story.published_at);
3
- }
4
- //# sourceMappingURL=isEmbargoStory.js.map
2
+ return story.is_embargo && Boolean(story.published_at);
3
+ }
package/package.json CHANGED
@@ -1,10 +1,17 @@
1
1
  {
2
2
  "name": "@prezly/theme-kit-nextjs",
3
- "version": "2.0.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
- "build": "tsc --project .",
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",