@prezly/theme-kit-nextjs 1.15.1 → 1.16.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 (144) hide show
  1. package/build/adapter-nextjs/api-handlers/fetchGalleries.js +16 -66
  2. package/build/adapter-nextjs/api-handlers/fetchGalleries.js.map +1 -1
  3. package/build/adapter-nextjs/api-handlers/fetchStories.js +18 -68
  4. package/build/adapter-nextjs/api-handlers/fetchStories.js.map +1 -1
  5. package/build/adapter-nextjs/getNewsroomServerSideProps.js +9 -59
  6. package/build/adapter-nextjs/getNewsroomServerSideProps.js.map +1 -1
  7. package/build/adapter-nextjs/getNewsroomStaticProps.js +9 -59
  8. package/build/adapter-nextjs/getNewsroomStaticProps.js.map +1 -1
  9. package/build/adapter-nextjs/page-props/category.d.ts +1 -1
  10. package/build/adapter-nextjs/page-props/category.js +94 -195
  11. package/build/adapter-nextjs/page-props/category.js.map +1 -1
  12. package/build/adapter-nextjs/page-props/gallery.d.ts +1 -1
  13. package/build/adapter-nextjs/page-props/gallery.js +58 -135
  14. package/build/adapter-nextjs/page-props/gallery.js.map +1 -1
  15. package/build/adapter-nextjs/page-props/galleryAlbum.d.ts +1 -1
  16. package/build/adapter-nextjs/page-props/galleryAlbum.js +40 -132
  17. package/build/adapter-nextjs/page-props/galleryAlbum.js.map +1 -1
  18. package/build/adapter-nextjs/page-props/home.d.ts +1 -1
  19. package/build/adapter-nextjs/page-props/home.js +56 -135
  20. package/build/adapter-nextjs/page-props/home.js.map +1 -1
  21. package/build/adapter-nextjs/page-props/search.d.ts +2 -2
  22. package/build/adapter-nextjs/page-props/search.js +19 -96
  23. package/build/adapter-nextjs/page-props/search.js.map +1 -1
  24. package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js +18 -18
  25. package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js.map +1 -1
  26. package/build/adapter-nextjs/page-props/sitemap/createPaths.js +9 -40
  27. package/build/adapter-nextjs/page-props/sitemap/createPaths.js.map +1 -1
  28. package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js +28 -76
  29. package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js.map +1 -1
  30. package/build/adapter-nextjs/page-props/story.d.ts +1 -1
  31. package/build/adapter-nextjs/page-props/story.js +57 -159
  32. package/build/adapter-nextjs/page-props/story.js.map +1 -1
  33. package/build/adapter-nextjs/page-props/storyPreview.js +20 -81
  34. package/build/adapter-nextjs/page-props/storyPreview.js.map +1 -1
  35. package/build/adapter-nextjs/processRequest.js +8 -19
  36. package/build/adapter-nextjs/processRequest.js.map +1 -1
  37. package/build/adapter-nextjs/processStaticRequest.js +2 -13
  38. package/build/adapter-nextjs/processStaticRequest.js.map +1 -1
  39. package/build/components-nextjs/PageSeo/PageSeo.js +41 -52
  40. package/build/components-nextjs/PageSeo/PageSeo.js.map +1 -1
  41. package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js +1 -1
  42. package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js.map +1 -1
  43. package/build/components-nextjs/StorySeo/StorySeo.js +27 -31
  44. package/build/components-nextjs/StorySeo/StorySeo.js.map +1 -1
  45. package/build/components-nextjs/document.d.ts +6 -0
  46. package/build/components-nextjs/document.js +48 -0
  47. package/build/components-nextjs/document.js.map +1 -0
  48. package/build/components-nextjs/index.d.ts +1 -0
  49. package/build/components-nextjs/index.js +3 -1
  50. package/build/components-nextjs/index.js.map +1 -1
  51. package/build/data-fetching/api/PrezlyApi.js +170 -355
  52. package/build/data-fetching/api/PrezlyApi.js.map +1 -1
  53. package/build/data-fetching/api/getPrezlyApi.js +3 -3
  54. package/build/data-fetching/api/getPrezlyApi.js.map +1 -1
  55. package/build/data-fetching/api/queries.js +8 -32
  56. package/build/data-fetching/api/queries.js.map +1 -1
  57. package/build/data-fetching/lib/getAlgoliaSettings.js +5 -5
  58. package/build/data-fetching/lib/getAlgoliaSettings.js.map +1 -1
  59. package/build/data-fetching/lib/getEnvVariables.js +10 -21
  60. package/build/data-fetching/lib/getEnvVariables.js.map +1 -1
  61. package/build/data-fetching/lib/isUuid.js +1 -1
  62. package/build/data-fetching/lib/isUuid.js.map +1 -1
  63. package/build/index.d.ts +1 -0
  64. package/build/index.js +1 -0
  65. package/build/index.js.map +1 -1
  66. package/build/infinite-loading/useInfiniteGalleriesLoading.js +25 -79
  67. package/build/infinite-loading/useInfiniteGalleriesLoading.js.map +1 -1
  68. package/build/infinite-loading/useInfiniteLoading.js +22 -94
  69. package/build/infinite-loading/useInfiniteLoading.js.map +1 -1
  70. package/build/infinite-loading/useInfiniteStoriesLoading.js +36 -95
  71. package/build/infinite-loading/useInfiniteStoriesLoading.js.map +1 -1
  72. package/build/intl/languages.js +35 -68
  73. package/build/intl/languages.js.map +1 -1
  74. package/build/intl/locale.js +13 -13
  75. package/build/intl/locale.js.map +1 -1
  76. package/build/intl/localeConfig.js +11 -32
  77. package/build/intl/localeConfig.js.map +1 -1
  78. package/build/intl/localeObject.js +30 -42
  79. package/build/intl/localeObject.js.map +1 -1
  80. package/build/newsroom-context/context.js +17 -29
  81. package/build/newsroom-context/context.js.map +1 -1
  82. package/build/newsroom-context/hooks/useAlgoliaSettings.js +2 -2
  83. package/build/newsroom-context/hooks/useAlgoliaSettings.js.map +1 -1
  84. package/build/newsroom-context/hooks/useCategories.js +2 -2
  85. package/build/newsroom-context/hooks/useCategories.js.map +1 -1
  86. package/build/newsroom-context/hooks/useCompanyInformation.js +2 -2
  87. package/build/newsroom-context/hooks/useCompanyInformation.js.map +1 -1
  88. package/build/newsroom-context/hooks/useCurrentCategory.js +2 -2
  89. package/build/newsroom-context/hooks/useCurrentCategory.js.map +1 -1
  90. package/build/newsroom-context/hooks/useCurrentLocale.js +2 -2
  91. package/build/newsroom-context/hooks/useCurrentLocale.js.map +1 -1
  92. package/build/newsroom-context/hooks/useCurrentStory.js +2 -2
  93. package/build/newsroom-context/hooks/useCurrentStory.js.map +1 -1
  94. package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js +8 -8
  95. package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js.map +1 -1
  96. package/build/newsroom-context/hooks/useGetTranslationUrl.js +14 -19
  97. package/build/newsroom-context/hooks/useGetTranslationUrl.js.map +1 -1
  98. package/build/newsroom-context/hooks/useLanguages.js +2 -2
  99. package/build/newsroom-context/hooks/useLanguages.js.map +1 -1
  100. package/build/newsroom-context/hooks/useNewsroom.js +2 -2
  101. package/build/newsroom-context/hooks/useNewsroom.js.map +1 -1
  102. package/build/newsroom-context/hooks/useNewsroomContext.js +3 -3
  103. package/build/newsroom-context/hooks/useNewsroomContext.js.map +1 -1
  104. package/build/sentry/client.d.ts +2 -0
  105. package/build/sentry/client.js +9 -0
  106. package/build/sentry/client.js.map +1 -0
  107. package/build/sentry/common.d.ts +2 -0
  108. package/build/sentry/common.js +29 -0
  109. package/build/sentry/common.js.map +1 -0
  110. package/build/sentry/index.d.ts +2 -0
  111. package/build/sentry/index.js +8 -0
  112. package/build/sentry/index.js.map +1 -0
  113. package/build/sentry/server.d.ts +2 -0
  114. package/build/sentry/server.js +9 -0
  115. package/build/sentry/server.js.map +1 -0
  116. package/build/tsconfig.tsbuildinfo +1 -1
  117. package/build/utils/getAssetsUrl.js +2 -2
  118. package/build/utils/getAssetsUrl.js.map +1 -1
  119. package/build/utils/getDataRequestLink.js +1 -1
  120. package/build/utils/getDataRequestLink.js.map +1 -1
  121. package/build/utils/getLocalizedCategoryData.js +12 -23
  122. package/build/utils/getLocalizedCategoryData.js.map +1 -1
  123. package/build/utils/getNewsroomLogoUrl.js +4 -5
  124. package/build/utils/getNewsroomLogoUrl.js.map +1 -1
  125. package/build/utils/getPrivacyPortalUrl.js +2 -2
  126. package/build/utils/getPrivacyPortalUrl.js.map +1 -1
  127. package/build/utils/getStoryPublicationDate.js +1 -1
  128. package/build/utils/getStoryPublicationDate.js.map +1 -1
  129. package/build/utils/getUploadcareGroupUrl.js +2 -2
  130. package/build/utils/getUploadcareGroupUrl.js.map +1 -1
  131. package/package.json +2 -1
  132. package/src/adapter-nextjs/page-props/category.ts +1 -1
  133. package/src/adapter-nextjs/page-props/gallery.ts +1 -1
  134. package/src/adapter-nextjs/page-props/galleryAlbum.ts +1 -1
  135. package/src/adapter-nextjs/page-props/home.ts +1 -1
  136. package/src/adapter-nextjs/page-props/search.ts +1 -1
  137. package/src/adapter-nextjs/page-props/story.ts +1 -1
  138. package/src/components-nextjs/document.tsx +38 -0
  139. package/src/components-nextjs/index.ts +1 -0
  140. package/src/index.ts +1 -0
  141. package/src/sentry/client.ts +7 -0
  142. package/src/sentry/common.ts +27 -0
  143. package/src/sentry/index.ts +2 -0
  144. package/src/sentry/server.ts +7 -0
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.getCategoryHasTranslation = exports.getCategoryUrl = exports.getLocalizedCategoryData = void 0;
15
4
  function isAlgoliaCategory(category) {
@@ -23,26 +12,26 @@ function getLocalizedCategoryData(category, locale) {
23
12
  slug: category.slug,
24
13
  };
25
14
  }
26
- var targetLocaleCode = locale.toUnderscoreCode();
27
- var i18n = category.i18n;
28
- var populatedLocales = Object.keys(i18n).filter(function (localeCode) { return i18n[localeCode].name; });
29
- var targetLocale = populatedLocales.find(function (localeCode) { return localeCode === targetLocaleCode; }) ||
30
- populatedLocales.find(function (localeCode) { return i18n[localeCode].name === category.display_name; }) ||
15
+ const targetLocaleCode = locale.toUnderscoreCode();
16
+ const { i18n } = category;
17
+ const populatedLocales = Object.keys(i18n).filter((localeCode) => i18n[localeCode].name);
18
+ const targetLocale = populatedLocales.find((localeCode) => localeCode === targetLocaleCode) ||
19
+ populatedLocales.find((localeCode) => i18n[localeCode].name === category.display_name) ||
31
20
  populatedLocales[0];
32
- var _a = i18n[targetLocale], _ = _a.locale, localizedData = __rest(_a, ["locale"]);
21
+ const { locale: _, ...localizedData } = i18n[targetLocale];
33
22
  return localizedData;
34
23
  }
35
24
  exports.getLocalizedCategoryData = getLocalizedCategoryData;
36
25
  function getCategoryUrl(category, locale) {
37
- var slug = getLocalizedCategoryData(category, locale).slug;
38
- return "/category/".concat(slug);
26
+ const { slug } = getLocalizedCategoryData(category, locale);
27
+ return `/category/${slug}`;
39
28
  }
40
29
  exports.getCategoryUrl = getCategoryUrl;
41
30
  function getCategoryHasTranslation(category, locale) {
42
- var targetLocaleCode = locale.toUnderscoreCode();
43
- var i18n = category.i18n;
44
- var populatedLocales = Object.keys(i18n).filter(function (localeCode) { return i18n[localeCode].name; });
45
- return Boolean(populatedLocales.find(function (localeCode) { return localeCode === targetLocaleCode; }));
31
+ const targetLocaleCode = locale.toUnderscoreCode();
32
+ const { i18n } = category;
33
+ const populatedLocales = Object.keys(i18n).filter((localeCode) => i18n[localeCode].name);
34
+ return Boolean(populatedLocales.find((localeCode) => localeCode === targetLocaleCode));
46
35
  }
47
36
  exports.getCategoryHasTranslation = getCategoryHasTranslation;
48
37
  //# sourceMappingURL=getLocalizedCategoryData.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getLocalizedCategoryData.js","sourceRoot":"","sources":["../../src/utils/getLocalizedCategoryData.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAKA,SAAS,iBAAiB,CACtB,QAAuC;IAEvC,OAAO,MAAM,IAAI,QAAQ,IAAI,MAAM,IAAI,QAAQ,CAAC;AACpD,CAAC;AAED,SAAgB,wBAAwB,CACpC,QAAuC,EACvC,MAAoB;IAEpB,IAAI,iBAAiB,CAA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gB,CAAC,CAAC,CAAC,CAAC;IAExB,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,aAAa,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC;IAE3D,OAAO,aAAa,CAAC;AACzB,CAAC;AAvBD,4DAuBC;AAED,SAAgB,cAAc,CAAC,QAAuC,EAAE,MAAoB;IACxF,MAAM,EAAE,IAAI,EAAE,GAAG,wBAAwB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC5D,OAAO,aAAa,IAAI,EAAE,CAAC;AAC/B,CAAC;AAHD,wCAGC;AAED,SAAgB,yBAAyB,CAAC,QAAkB,EAAE,MAAoB;IAC9E,MAAM,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;IACnD,MAAM,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC;IAC1B,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC;IACzF,OAAO,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,KAAK,gBAAgB,CAAC,CAAC,CAAC;AAC3F,CAAC;AALD,8DAKC"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getNewsroomFaviconUrl = exports.getNewsroomLogoUrl = void 0;
4
- var getAssetsUrl_1 = require("./getAssetsUrl");
4
+ const getAssetsUrl_1 = require("./getAssetsUrl");
5
5
  function getNewsroomLogoUrl(newsroom) {
6
6
  if (newsroom.newsroom_logo) {
7
7
  return (0, getAssetsUrl_1.getAssetsUrl)(newsroom.newsroom_logo.uuid);
@@ -9,11 +9,10 @@ function getNewsroomLogoUrl(newsroom) {
9
9
  return '';
10
10
  }
11
11
  exports.getNewsroomLogoUrl = getNewsroomLogoUrl;
12
- function getNewsroomFaviconUrl(newsroom, previewSize) {
13
- if (previewSize === void 0) { previewSize = 400; }
14
- var image = newsroom.icon || newsroom.square_logo;
12
+ function getNewsroomFaviconUrl(newsroom, previewSize = 400) {
13
+ const image = newsroom.icon || newsroom.square_logo;
15
14
  if (image) {
16
- return "".concat((0, getAssetsUrl_1.getAssetsUrl)(image.uuid), "-/preview/").concat(previewSize, "x").concat(previewSize, "/-/quality/best/");
15
+ return `${(0, getAssetsUrl_1.getAssetsUrl)(image.uuid)}-/preview/${previewSize}x${previewSize}/-/quality/best/`;
17
16
  }
18
17
  return '';
19
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getNewsroomLogoUrl.js","sourceRoot":"","sources":["../../src/utils/getNewsroomLogoUrl.ts"],"names":[],"mappings":";;;AAEA,+CAA8C;AAE9C,SAAgB,kBAAkB,CAAC,QAAkB;IACjD,IAAI,QAAQ,CAAC,aAAa,EAAE;QACxB,OAAO,IAAA,2BAAY,EAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;KACpD;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AAND,gDAMC;AAED,SAAgB,qBAAqB,CAAC,QAAkB,EAAE,WAAiB;IAAjB,4BAAA,EAAA,iBAAiB;IACvE,IAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,WAAW,CAAC;IACpD,IAAI,KAAK,EAAE;QACP,OAAO,UAAG,IAAA,2BAAY,EAAC,KAAK,CAAC,IAAI,CAAC,uBAAa,WAAW,cAAI,WAAW,qBAAkB,CAAC;KAC/F;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AAPD,sDAOC"}
1
+ {"version":3,"file":"getNewsroomLogoUrl.js","sourceRoot":"","sources":["../../src/utils/getNewsroomLogoUrl.ts"],"names":[],"mappings":";;;AAEA,iDAA8C;AAE9C,SAAgB,kBAAkB,CAAC,QAAkB;IACjD,IAAI,QAAQ,CAAC,aAAa,EAAE;QACxB,OAAO,IAAA,2BAAY,EAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;KACpD;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AAND,gDAMC;AAED,SAAgB,qBAAqB,CAAC,QAAkB,EAAE,WAAW,GAAG,GAAG;IACvE,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,WAAW,CAAC;IACpD,IAAI,KAAK,EAAE;QACP,OAAO,GAAG,IAAA,2BAAY,EAAC,KAAK,CAAC,IAAI,CAAC,aAAa,WAAW,IAAI,WAAW,kBAAkB,CAAC;KAC/F;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AAPD,sDAOC"}
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPrivacyPortalUrl = void 0;
4
4
  function getPrivacyPortalUrl(newsroom, locale, options) {
5
- var _a = options || {}, email = _a.email, _b = _a.action, action = _b === void 0 ? 'subscribe' : _b;
6
- var url = new URL("/".concat(locale.toUrlSlug(), "/newsroom/").concat(newsroom.uuid, "/").concat(action), 'https://privacy.prezly.com');
5
+ const { email, action = 'subscribe' } = options || {};
6
+ const url = new URL(`/${locale.toUrlSlug()}/newsroom/${newsroom.uuid}/${action}`, 'https://privacy.prezly.com');
7
7
  if (email) {
8
8
  url.searchParams.append('email', email);
9
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getPrivacyPortalUrl.js","sourceRoot":"","sources":["../../src/utils/getPrivacyPortalUrl.ts"],"names":[],"mappings":";;;AASA,SAAgB,mBAAmB,CAC/B,QAAkB,EAClB,MAAoB,EACpB,OAAiC;IAE3B,IAAA,KAAkC,OAAO,IAAI,EAAE,EAA7C,KAAK,WAAA,EAAE,cAAoB,EAApB,MAAM,mBAAG,WAAW,KAAkB,CAAC;IAEtD,IAAM,GAAG,GAAG,IAAI,GAAG,CACf,WAAI,MAAM,CAAC,SAAS,EAAE,uBAAa,QAAQ,CAAC,IAAI,cAAI,MAAM,CAAE,EAC5D,4BAA4B,CAC/B,CAAC;IACF,IAAI,KAAK,EAAE;QACP,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KAC3C;IACD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AAC1B,CAAC;AAfD,kDAeC"}
1
+ {"version":3,"file":"getPrivacyPortalUrl.js","sourceRoot":"","sources":["../../src/utils/getPrivacyPortalUrl.ts"],"names":[],"mappings":";;;AASA,SAAgB,mBAAmB,CAC/B,QAAkB,EAClB,MAAoB,EACpB,OAAiC;IAEjC,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAEtD,MAAM,GAAG,GAAG,IAAI,GAAG,CACf,IAAI,MAAM,CAAC,SAAS,EAAE,aAAa,QAAQ,CAAC,IAAI,IAAI,MAAM,EAAE,EAC5D,4BAA4B,CAC/B,CAAC;IACF,IAAI,KAAK,EAAE;QACP,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KAC3C;IACD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AAC1B,CAAC;AAfD,kDAeC"}
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getStoryPublicationDate = void 0;
4
4
  function getStoryPublicationDate(story) {
5
- var published_at = story.published_at;
5
+ const { published_at } = story;
6
6
  if (!published_at) {
7
7
  return null;
8
8
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getStoryPublicationDate.js","sourceRoot":"","sources":["../../src/utils/getStoryPublicationDate.tsx"],"names":[],"mappings":";;;AAIA,SAAgB,uBAAuB,CAAC,KAA2B;IACvD,IAAA,YAAY,GAAK,KAAK,aAAV,CAAW;IAE/B,IAAI,CAAC,YAAY,EAAE;QACf,OAAO,IAAI,CAAC;KACf;IAED,OAAO,OAAO,YAAY,KAAK,QAAQ;QACnC,CAAC,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC;QACxB,CAAC,CAAC,IAAI,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;AACxC,CAAC;AAVD,0DAUC"}
1
+ {"version":3,"file":"getStoryPublicationDate.js","sourceRoot":"","sources":["../../src/utils/getStoryPublicationDate.tsx"],"names":[],"mappings":";;;AAIA,SAAgB,uBAAuB,CAAC,KAA2B;IAC/D,MAAM,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;IAE/B,IAAI,CAAC,YAAY,EAAE;QACf,OAAO,IAAI,CAAC;KACf;IAED,OAAO,OAAO,YAAY,KAAK,QAAQ;QACnC,CAAC,CAAC,IAAI,IAAI,CAAC,YAAY,CAAC;QACxB,CAAC,CAAC,IAAI,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;AACxC,CAAC;AAVD,0DAUC"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getUploadcareGroupUrl = void 0;
4
- var constants_1 = require("./constants");
4
+ const constants_1 = require("./constants");
5
5
  /**
6
6
  * This method constructs a URL to download all images in the Gallery as a single archive.
7
7
  *
@@ -10,7 +10,7 @@ var constants_1 = require("./constants");
10
10
  * @returns URL to an archive containing all of the images in the Gallery.
11
11
  */
12
12
  function getUploadcareGroupUrl(uuid, title) {
13
- return "".concat(constants_1.ASSETS_URL, "/").concat(uuid, "/archive/zip/").concat(encodeURI(title), ".zip");
13
+ return `${constants_1.ASSETS_URL}/${uuid}/archive/zip/${encodeURI(title)}.zip`;
14
14
  }
15
15
  exports.getUploadcareGroupUrl = getUploadcareGroupUrl;
16
16
  //# sourceMappingURL=getUploadcareGroupUrl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getUploadcareGroupUrl.js","sourceRoot":"","sources":["../../src/utils/getUploadcareGroupUrl.ts"],"names":[],"mappings":";;;AAAA,yCAAyC;AAEzC;;;;;;GAMG;AACH,SAAgB,qBAAqB,CAAC,IAAY,EAAE,KAAa;IAC7D,OAAO,UAAG,sBAAU,cAAI,IAAI,0BAAgB,SAAS,CAAC,KAAK,CAAC,SAAM,CAAC;AACvE,CAAC;AAFD,sDAEC"}
1
+ {"version":3,"file":"getUploadcareGroupUrl.js","sourceRoot":"","sources":["../../src/utils/getUploadcareGroupUrl.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AAEzC;;;;;;GAMG;AACH,SAAgB,qBAAqB,CAAC,IAAY,EAAE,KAAa;IAC7D,OAAO,GAAG,sBAAU,IAAI,IAAI,gBAAgB,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC;AACvE,CAAC;AAFD,sDAEC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prezly/theme-kit-nextjs",
3
- "version": "1.15.1",
3
+ "version": "1.16.0-2",
4
4
  "description": "Data layer and utility library for developing Prezly themes with NextJS",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -55,6 +55,7 @@
55
55
  },
56
56
  "devDependencies": {
57
57
  "@prezly/eslint-config": "4.2.0",
58
+ "@sentry/nextjs": "^7.7.0",
58
59
  "@types/jest": "28.1.6",
59
60
  "@types/node": "17.0.14",
60
61
  "@types/parse-data-url": "3.0.0",
@@ -87,7 +87,7 @@ export function getCategoryPageServerSideProps<
87
87
  export function getCategoryPageStaticProps<
88
88
  CustomProps extends Record<string, any>,
89
89
  StoryType extends Story = Story,
90
- >(customProps: CustomProps | PropsFunction<CustomProps>, options?: Options) {
90
+ >(customProps: CustomProps | PropsFunction<CustomProps, GetStaticPropsContext>, options?: Options) {
91
91
  const { pageSize = DEFAULT_PAGE_SIZE, extraStoryFields } = options || {};
92
92
 
93
93
  return async function getStaticProps(
@@ -71,7 +71,7 @@ export function getGalleryPageServerSideProps<CustomProps extends Record<string,
71
71
  }
72
72
 
73
73
  export function getGalleryPageStaticProps<CustomProps extends Record<string, any>>(
74
- customProps: CustomProps | PropsFunction<CustomProps>,
74
+ customProps: CustomProps | PropsFunction<CustomProps, GetStaticPropsContext>,
75
75
  options?: Options,
76
76
  ) {
77
77
  const { pageSize = DEFAULT_GALLERY_PAGE_SIZE } = options || {};
@@ -49,7 +49,7 @@ export function getGalleryAlbumPageServerSideProps<CustomProps extends Record<st
49
49
  }
50
50
 
51
51
  export function getGalleryAlbumPageStaticProps<CustomProps extends Record<string, any>>(
52
- customProps: CustomProps | PropsFunction<CustomProps>,
52
+ customProps: CustomProps | PropsFunction<CustomProps, GetStaticPropsContext>,
53
53
  ) {
54
54
  return async function getStaticProps(
55
55
  context: GetStaticPropsContext,
@@ -74,7 +74,7 @@ export function getHomepageServerSideProps<
74
74
  export function getHomepageStaticProps<
75
75
  CustomProps extends Record<string, any>,
76
76
  StoryType extends Story = Story,
77
- >(customProps: CustomProps | PropsFunction<CustomProps>, options?: Options) {
77
+ >(customProps: CustomProps | PropsFunction<CustomProps, GetStaticPropsContext>, options?: Options) {
78
78
  const { pageSize = DEFAULT_PAGE_SIZE, extraStoryFields } = options || {};
79
79
 
80
80
  return async function getStaticProps(
@@ -33,7 +33,7 @@ export function getSearchPageServerSideProps<CustomProps extends Record<string,
33
33
  }
34
34
 
35
35
  export function getSearchPageStaticProps<CustomProps extends Record<string, any>>(
36
- customProps: CustomProps | PropsFunction<CustomProps>,
36
+ customProps: CustomProps | PropsFunction<CustomProps, GetStaticPropsContext>,
37
37
  ) {
38
38
  return async function getStaticProps(
39
39
  context: GetServerSidePropsContext,
@@ -54,7 +54,7 @@ export function getStoryPageServerSideProps<CustomProps extends Record<string, a
54
54
  }
55
55
 
56
56
  export function getStoryPageStaticProps<CustomProps extends Record<string, any>>(
57
- customProps: CustomProps | PropsFunction<CustomProps>,
57
+ customProps: CustomProps | PropsFunction<CustomProps, GetStaticPropsContext>,
58
58
  ) {
59
59
  return async function getStaticProps(
60
60
  context: GetStaticPropsContext,
@@ -0,0 +1,38 @@
1
+ import Document, { Head, Html, Main, NextScript } from 'next/document';
2
+
3
+ import { DEFAULT_LOCALE, getLocaleDirection, LocaleObject } from '../intl';
4
+ import type { PageProps } from '../types';
5
+
6
+ export class PrezlyThemeDocument extends Document {
7
+ getLocaleCode() {
8
+ const {
9
+ newsroomContextProps,
10
+ // eslint-disable-next-line no-underscore-dangle
11
+ } = this.props.__NEXT_DATA__.props.pageProps as PageProps;
12
+
13
+ // In some cases (like server errors) the newsroom context props will not be loaded.
14
+ // We need to fall back to default locale to keep the app working.
15
+ const { localeCode } = newsroomContextProps ?? { localeCode: DEFAULT_LOCALE };
16
+
17
+ return localeCode;
18
+ }
19
+
20
+ render() {
21
+ const locale = LocaleObject.fromAnyCode(this.getLocaleCode());
22
+ // TODO: The direction can be pulled from the Language object
23
+ const direction = getLocaleDirection(locale);
24
+
25
+ return (
26
+ <Html lang={locale.toHyphenCode()} dir={direction}>
27
+ <Head>
28
+ <meta name="og:locale" content={locale.toHyphenCode()} />
29
+ {/* TODO: Add alternate locales */}
30
+ </Head>
31
+ <body>
32
+ <Main />
33
+ <NextScript />
34
+ </body>
35
+ </Html>
36
+ );
37
+ }
38
+ }
@@ -1,2 +1,3 @@
1
1
  export { PageSeo } from './PageSeo';
2
2
  export { StorySeo } from './StorySeo';
3
+ export { PrezlyThemeDocument } from './document';
package/src/index.ts CHANGED
@@ -4,5 +4,6 @@ export * from './data-fetching';
4
4
  export * from './infinite-loading';
5
5
  export * from './intl';
6
6
  export * from './newsroom-context';
7
+ export * from './sentry';
7
8
  export * from './types';
8
9
  export * from './utils';
@@ -0,0 +1,7 @@
1
+ import type { init } from '@sentry/nextjs';
2
+
3
+ import { getCommonClientOptions } from './common';
4
+
5
+ export function getSentryClientOptions(dsn: string, themeName: string): Parameters<typeof init>[0] {
6
+ return getCommonClientOptions(dsn, themeName);
7
+ }
@@ -0,0 +1,27 @@
1
+ import type { init } from '@sentry/nextjs';
2
+
3
+ export function getCommonClientOptions(dsn: string, themeName: string): Parameters<typeof init>[0] {
4
+ return {
5
+ dsn,
6
+ // Adjust this value in production, or use tracesSampler for greater control
7
+ tracesSampleRate: 0.02,
8
+ // ...
9
+ // Note: if you want to override the automatic release value, do not set a
10
+ // `release` value here - use the environment variable `SENTRY_RELEASE`, so
11
+ // that it will also get attached to your source maps
12
+
13
+ ignoreErrors: [
14
+ // This particular error is coming from Microsoft Outlook SafeLink crawler.
15
+ // It doesn't affect the user experience in any way, but produces a lot of unwanted Sentry events.
16
+ // See https://forum.sentry.io/t/unhandledrejection-non-error-promise-rejection-captured-with-value/14062
17
+ 'Object Not Found Matching Id',
18
+ // This error is caused by `beacon.min.js` polyfill in Cloudflare Insights. From what we see, it doesn't affect the user experience.
19
+ 'Illegal invocation',
20
+ ],
21
+ // Attach theme tag to each event
22
+ initialScope: (scope) => {
23
+ scope.setTags({ prezly_theme: themeName });
24
+ return scope;
25
+ },
26
+ };
27
+ }
@@ -0,0 +1,2 @@
1
+ export { getSentryClientOptions } from './client';
2
+ export { getSentryServerOptions } from './server';
@@ -0,0 +1,7 @@
1
+ import type { init } from '@sentry/nextjs';
2
+
3
+ import { getCommonClientOptions } from './common';
4
+
5
+ export function getSentryServerOptions(dsn: string, themeName: string): Parameters<typeof init>[0] {
6
+ return getCommonClientOptions(dsn, themeName);
7
+ }