@prezly/theme-kit-nextjs 2.0.1-1 → 2.1.0

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 (259) hide show
  1. package/README.md +15 -15
  2. package/build/adapter-nextjs/api-handlers/fetchGalleries.js +21 -31
  3. package/build/adapter-nextjs/api-handlers/fetchGalleries.js.map +1 -1
  4. package/build/adapter-nextjs/api-handlers/fetchStories.js +23 -41
  5. package/build/adapter-nextjs/api-handlers/fetchStories.js.map +1 -1
  6. package/build/adapter-nextjs/api-handlers/index.js +7 -18
  7. package/build/adapter-nextjs/api-handlers/index.js.map +1 -1
  8. package/build/adapter-nextjs/getNewsroomServerSideProps.js +13 -20
  9. package/build/adapter-nextjs/getNewsroomServerSideProps.js.map +1 -1
  10. package/build/adapter-nextjs/getNewsroomStaticProps.js +13 -19
  11. package/build/adapter-nextjs/getNewsroomStaticProps.js.map +1 -1
  12. package/build/adapter-nextjs/index.js +21 -69
  13. package/build/adapter-nextjs/index.js.map +1 -1
  14. package/build/adapter-nextjs/page-props/category.js +96 -122
  15. package/build/adapter-nextjs/page-props/category.js.map +1 -1
  16. package/build/adapter-nextjs/page-props/gallery.js +65 -91
  17. package/build/adapter-nextjs/page-props/gallery.js.map +1 -1
  18. package/build/adapter-nextjs/page-props/galleryAlbum.js +49 -68
  19. package/build/adapter-nextjs/page-props/galleryAlbum.js.map +1 -1
  20. package/build/adapter-nextjs/page-props/home.js +66 -87
  21. package/build/adapter-nextjs/page-props/home.js.map +1 -1
  22. package/build/adapter-nextjs/page-props/index.js +40 -136
  23. package/build/adapter-nextjs/page-props/index.js.map +1 -1
  24. package/build/adapter-nextjs/page-props/lib/types.js +3 -1
  25. package/build/adapter-nextjs/page-props/search.js +28 -29
  26. package/build/adapter-nextjs/page-props/search.js.map +1 -1
  27. package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js +46 -32
  28. package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js.map +1 -1
  29. package/build/adapter-nextjs/page-props/sitemap/createPaths.js +17 -17
  30. package/build/adapter-nextjs/page-props/sitemap/createPaths.js.map +1 -1
  31. package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js +33 -37
  32. package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js.map +1 -1
  33. package/build/adapter-nextjs/page-props/sitemap/index.js +23 -41
  34. package/build/adapter-nextjs/page-props/sitemap/index.js.map +1 -1
  35. package/build/adapter-nextjs/page-props/sitemap/types.js +3 -1
  36. package/build/adapter-nextjs/page-props/story.js +60 -81
  37. package/build/adapter-nextjs/page-props/story.js.map +1 -1
  38. package/build/adapter-nextjs/page-props/storyPreview.js +24 -31
  39. package/build/adapter-nextjs/page-props/storyPreview.js.map +1 -1
  40. package/build/adapter-nextjs/processRequest.js +23 -38
  41. package/build/adapter-nextjs/processRequest.js.map +1 -1
  42. package/build/adapter-nextjs/processStaticRequest.js +14 -23
  43. package/build/adapter-nextjs/processStaticRequest.js.map +1 -1
  44. package/build/components-nextjs/PageSeo/PageSeo.js +77 -89
  45. package/build/components-nextjs/PageSeo/PageSeo.js.map +1 -1
  46. package/build/components-nextjs/PageSeo/index.js +19 -25
  47. package/build/components-nextjs/PageSeo/index.js.map +1 -1
  48. package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js +8 -9
  49. package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js.map +1 -1
  50. package/build/components-nextjs/PageSeo/lib/types.js +3 -1
  51. package/build/components-nextjs/StorySeo/StorySeo.js +46 -74
  52. package/build/components-nextjs/StorySeo/StorySeo.js.map +1 -1
  53. package/build/components-nextjs/StorySeo/index.js +5 -11
  54. package/build/components-nextjs/StorySeo/index.js.map +1 -1
  55. package/build/components-nextjs/document.js +44 -36
  56. package/build/components-nextjs/document.js.map +1 -1
  57. package/build/components-nextjs/index.js +9 -25
  58. package/build/components-nextjs/index.js.map +1 -1
  59. package/build/data-fetching/api/PrezlyApi.js +187 -210
  60. package/build/data-fetching/api/PrezlyApi.js.map +1 -1
  61. package/build/data-fetching/api/getPrezlyApi.js +19 -25
  62. package/build/data-fetching/api/getPrezlyApi.js.map +1 -1
  63. package/build/data-fetching/api/index.js +16 -14
  64. package/build/data-fetching/api/index.js.map +1 -1
  65. package/build/data-fetching/api/queries.js +41 -80
  66. package/build/data-fetching/api/queries.js.map +1 -1
  67. package/build/data-fetching/index.js +18 -36
  68. package/build/data-fetching/index.js.map +1 -1
  69. package/build/data-fetching/lib/getAlgoliaSettings.js +20 -26
  70. package/build/data-fetching/lib/getAlgoliaSettings.js.map +1 -1
  71. package/build/data-fetching/lib/getEnvVariables.js +36 -40
  72. package/build/data-fetching/lib/getEnvVariables.js.map +1 -1
  73. package/build/data-fetching/lib/index.js +11 -32
  74. package/build/data-fetching/lib/index.js.map +1 -1
  75. package/build/data-fetching/lib/isSdkError.js +6 -7
  76. package/build/data-fetching/lib/isSdkError.js.map +1 -1
  77. package/build/data-fetching/lib/isUuid.js +6 -7
  78. package/build/data-fetching/lib/isUuid.js.map +1 -1
  79. package/build/data-fetching/types.js +3 -1
  80. package/build/index.js +25 -103
  81. package/build/index.js.map +1 -1
  82. package/build/infinite-loading/index.js +23 -41
  83. package/build/infinite-loading/index.js.map +1 -1
  84. package/build/infinite-loading/types.js +3 -1
  85. package/build/infinite-loading/useInfiniteGalleriesLoading.js +35 -46
  86. package/build/infinite-loading/useInfiniteGalleriesLoading.js.map +1 -1
  87. package/build/infinite-loading/useInfiniteLoading.js +41 -54
  88. package/build/infinite-loading/useInfiniteLoading.js.map +1 -1
  89. package/build/infinite-loading/useInfiniteStoriesLoading.js +48 -60
  90. package/build/infinite-loading/useInfiniteStoriesLoading.js.map +1 -1
  91. package/build/intl/index.d.ts +1 -1
  92. package/build/intl/index.js +24 -47
  93. package/build/intl/index.js.map +1 -1
  94. package/build/intl/languages.js +110 -150
  95. package/build/intl/languages.js.map +1 -1
  96. package/build/intl/locale.d.ts +1 -0
  97. package/build/intl/locale.js +104 -58
  98. package/build/intl/locale.js.map +1 -1
  99. package/build/intl/localeConfig.d.ts +2 -3
  100. package/build/intl/localeConfig.js +13 -28
  101. package/build/intl/localeConfig.js.map +1 -1
  102. package/build/intl/localeList.d.ts +2 -4
  103. package/build/intl/localeList.js +108 -7
  104. package/build/intl/localeList.js.map +1 -1
  105. package/build/intl/localeObject.js +78 -83
  106. package/build/intl/localeObject.js.map +1 -1
  107. package/build/newsroom-context/context.js +24 -42
  108. package/build/newsroom-context/context.js.map +1 -1
  109. package/build/newsroom-context/hooks/index.js +27 -125
  110. package/build/newsroom-context/hooks/index.js.map +1 -1
  111. package/build/newsroom-context/hooks/useAlgoliaSettings.js +8 -9
  112. package/build/newsroom-context/hooks/useAlgoliaSettings.js.map +1 -1
  113. package/build/newsroom-context/hooks/useCategories.js +8 -9
  114. package/build/newsroom-context/hooks/useCategories.js.map +1 -1
  115. package/build/newsroom-context/hooks/useCompanyInformation.js +8 -9
  116. package/build/newsroom-context/hooks/useCompanyInformation.js.map +1 -1
  117. package/build/newsroom-context/hooks/useCurrentCategory.js +8 -9
  118. package/build/newsroom-context/hooks/useCurrentCategory.js.map +1 -1
  119. package/build/newsroom-context/hooks/useCurrentLocale.js +8 -9
  120. package/build/newsroom-context/hooks/useCurrentLocale.js.map +1 -1
  121. package/build/newsroom-context/hooks/useCurrentStory.js +8 -9
  122. package/build/newsroom-context/hooks/useCurrentStory.js.map +1 -1
  123. package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js +19 -21
  124. package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js.map +1 -1
  125. package/build/newsroom-context/hooks/useGetTranslationUrl.js +54 -56
  126. package/build/newsroom-context/hooks/useGetTranslationUrl.js.map +1 -1
  127. package/build/newsroom-context/hooks/useLanguages.js +8 -9
  128. package/build/newsroom-context/hooks/useLanguages.js.map +1 -1
  129. package/build/newsroom-context/hooks/useNewsroom.js +8 -9
  130. package/build/newsroom-context/hooks/useNewsroom.js.map +1 -1
  131. package/build/newsroom-context/hooks/useNewsroomContext.js +14 -15
  132. package/build/newsroom-context/hooks/useNewsroomContext.js.map +1 -1
  133. package/build/newsroom-context/index.d.ts +1 -2
  134. package/build/newsroom-context/index.js +20 -32
  135. package/build/newsroom-context/index.js.map +1 -1
  136. package/build/sentry/client.js +7 -8
  137. package/build/sentry/client.js.map +1 -1
  138. package/build/sentry/common.js +27 -30
  139. package/build/sentry/common.js.map +1 -1
  140. package/build/sentry/index.js +7 -18
  141. package/build/sentry/index.js.map +1 -1
  142. package/build/sentry/server.js +7 -8
  143. package/build/sentry/server.js.map +1 -1
  144. package/build/tsconfig.tsbuildinfo +1 -0
  145. package/build/types.js +3 -1
  146. package/build/utils/boilerplate.js +18 -11
  147. package/build/utils/boilerplate.js.map +1 -1
  148. package/build/utils/constants.js +6 -11
  149. package/build/utils/constants.js.map +1 -1
  150. package/build/utils/getAssetsUrl.js +7 -8
  151. package/build/utils/getAssetsUrl.js.map +1 -1
  152. package/build/utils/getDataRequestLink.js +10 -10
  153. package/build/utils/getDataRequestLink.js.map +1 -1
  154. package/build/utils/getLocalizedCategoryData.js +29 -37
  155. package/build/utils/getLocalizedCategoryData.js.map +1 -1
  156. package/build/utils/getNewsroomLogoUrl.js +18 -19
  157. package/build/utils/getNewsroomLogoUrl.js.map +1 -1
  158. package/build/utils/getPrivacyPortalUrl.js +11 -15
  159. package/build/utils/getPrivacyPortalUrl.js.map +1 -1
  160. package/build/utils/getStoryPublicationDate.js +12 -13
  161. package/build/utils/getStoryPublicationDate.js.map +1 -1
  162. package/build/utils/getUploadcareGroupUrl.js +8 -9
  163. package/build/utils/getUploadcareGroupUrl.js.map +1 -1
  164. package/build/utils/index.js +26 -114
  165. package/build/utils/index.js.map +1 -1
  166. package/build/utils/isEmbargoStory.js +6 -7
  167. package/build/utils/isEmbargoStory.js.map +1 -1
  168. package/package.json +12 -26
  169. package/src/@types/global.d.ts +7 -0
  170. package/src/__mocks__/languages.ts +416 -0
  171. package/src/__mocks__/story.ts +359 -0
  172. package/src/adapter-nextjs/api-handlers/fetchGalleries.ts +24 -0
  173. package/src/adapter-nextjs/api-handlers/fetchStories.ts +26 -0
  174. package/src/adapter-nextjs/api-handlers/index.ts +2 -0
  175. package/src/adapter-nextjs/getNewsroomServerSideProps.ts +29 -0
  176. package/src/adapter-nextjs/getNewsroomStaticProps.ts +29 -0
  177. package/src/adapter-nextjs/index.ts +6 -0
  178. package/src/adapter-nextjs/page-props/category.ts +157 -0
  179. package/src/adapter-nextjs/page-props/gallery.ts +114 -0
  180. package/src/adapter-nextjs/page-props/galleryAlbum.ts +89 -0
  181. package/src/adapter-nextjs/page-props/home.ts +113 -0
  182. package/src/adapter-nextjs/page-props/index.ts +26 -0
  183. package/src/adapter-nextjs/page-props/lib/types.ts +8 -0
  184. package/src/adapter-nextjs/page-props/search.ts +53 -0
  185. package/src/adapter-nextjs/page-props/sitemap/SitemapBuilder.ts +56 -0
  186. package/src/adapter-nextjs/page-props/sitemap/createPaths.ts +21 -0
  187. package/src/adapter-nextjs/page-props/sitemap/getServerSideProps.ts +43 -0
  188. package/src/adapter-nextjs/page-props/sitemap/index.ts +5 -0
  189. package/src/adapter-nextjs/page-props/sitemap/types.ts +5 -0
  190. package/src/adapter-nextjs/page-props/story.ts +94 -0
  191. package/src/adapter-nextjs/page-props/storyPreview.ts +33 -0
  192. package/src/adapter-nextjs/processRequest.ts +49 -0
  193. package/src/adapter-nextjs/processStaticRequest.ts +32 -0
  194. package/src/components-nextjs/PageSeo/PageSeo.tsx +131 -0
  195. package/src/components-nextjs/PageSeo/index.ts +2 -0
  196. package/src/components-nextjs/PageSeo/lib/getAbsoluteUrl.ts +7 -0
  197. package/src/components-nextjs/PageSeo/lib/types.ts +4 -0
  198. package/src/components-nextjs/StorySeo/StorySeo.tsx +80 -0
  199. package/src/components-nextjs/StorySeo/index.ts +1 -0
  200. package/src/components-nextjs/document.tsx +38 -0
  201. package/src/components-nextjs/index.ts +3 -0
  202. package/src/data-fetching/api/PrezlyApi.ts +304 -0
  203. package/src/data-fetching/api/getPrezlyApi.ts +24 -0
  204. package/src/data-fetching/api/index.ts +1 -0
  205. package/src/data-fetching/api/queries.ts +51 -0
  206. package/src/data-fetching/index.ts +3 -0
  207. package/src/data-fetching/lib/getAlgoliaSettings.ts +29 -0
  208. package/src/data-fetching/lib/getEnvVariables.ts +46 -0
  209. package/src/data-fetching/lib/index.ts +4 -0
  210. package/src/data-fetching/lib/isSdkError.ts +5 -0
  211. package/src/data-fetching/lib/isUuid.ts +5 -0
  212. package/src/data-fetching/types.ts +14 -0
  213. package/src/index.ts +9 -0
  214. package/src/infinite-loading/index.ts +4 -0
  215. package/src/infinite-loading/types.ts +5 -0
  216. package/src/infinite-loading/useInfiniteGalleriesLoading.ts +53 -0
  217. package/src/infinite-loading/useInfiniteLoading.ts +66 -0
  218. package/src/infinite-loading/useInfiniteStoriesLoading.ts +81 -0
  219. package/src/intl/index.ts +4 -0
  220. package/src/intl/languages.test.ts +232 -0
  221. package/src/intl/languages.ts +233 -0
  222. package/src/intl/locale.test.ts +95 -0
  223. package/src/intl/locale.ts +140 -0
  224. package/src/intl/localeConfig.js +23 -0
  225. package/src/intl/localeList.js +110 -0
  226. package/src/intl/localeObject.test.ts +81 -0
  227. package/src/intl/localeObject.ts +99 -0
  228. package/src/newsroom-context/context.tsx +115 -0
  229. package/src/newsroom-context/hooks/index.ts +11 -0
  230. package/src/newsroom-context/hooks/useAlgoliaSettings.ts +7 -0
  231. package/src/newsroom-context/hooks/useCategories.ts +7 -0
  232. package/src/newsroom-context/hooks/useCompanyInformation.ts +7 -0
  233. package/src/newsroom-context/hooks/useCurrentCategory.ts +7 -0
  234. package/src/newsroom-context/hooks/useCurrentLocale.ts +7 -0
  235. package/src/newsroom-context/hooks/useCurrentStory.ts +7 -0
  236. package/src/newsroom-context/hooks/useGetLinkLocaleSlug.ts +37 -0
  237. package/src/newsroom-context/hooks/useGetTranslationUrl.ts +97 -0
  238. package/src/newsroom-context/hooks/useLanguages.ts +7 -0
  239. package/src/newsroom-context/hooks/useNewsroom.ts +7 -0
  240. package/src/newsroom-context/hooks/useNewsroomContext.ts +15 -0
  241. package/src/newsroom-context/index.ts +2 -0
  242. package/src/sentry/client.ts +7 -0
  243. package/src/sentry/common.ts +27 -0
  244. package/src/sentry/index.ts +2 -0
  245. package/src/sentry/server.ts +7 -0
  246. package/src/types.ts +51 -0
  247. package/src/utils/boilerplate.ts +27 -0
  248. package/src/utils/constants.ts +3 -0
  249. package/src/utils/getAssetsUrl.test.ts +9 -0
  250. package/src/utils/getAssetsUrl.ts +9 -0
  251. package/src/utils/getDataRequestLink.ts +14 -0
  252. package/src/utils/getLocalizedCategoryData.ts +47 -0
  253. package/src/utils/getNewsroomLogoUrl.ts +22 -0
  254. package/src/utils/getPrivacyPortalUrl.ts +25 -0
  255. package/src/utils/getStoryPublicationDate.tsx +15 -0
  256. package/src/utils/getUploadcareGroupUrl.ts +13 -0
  257. package/src/utils/index.ts +10 -0
  258. package/src/utils/isEmbargoStory.ts +10 -0
  259. package/build/@types/global.d.js +0 -1
package/README.md CHANGED
@@ -51,17 +51,12 @@ If you don't have these credentials, you can use one of our [testing newsrooms c
51
51
  In a base setup, you don't have to make any changes to your config.
52
52
  Depending on your use-case, you might need to make some additions to your base config.
53
53
 
54
- #### ⚠️ IMPORTANT: Theme Kit v2 is ESM-only package!
55
-
56
- You should be totally fine if you don't need to import anything from `@prezly/theme-kit-nextjs` in your `next.config.js`, which is a CommonJS file by default.
57
- In order to import from `@prezly/theme-kit-nextjs`, you will need either to set `type` property to `module` in your `package.json`, or rename `next.config.js` to `next.config.mjs`, so that it's treated as ES Module.
58
-
59
54
  #### Using next/image to display images served from Prezly
60
55
 
61
56
  We provide `@prezly/uploadcare-image` package to conveniently display images inside Prezly content, and this is the recommended way to display images in your theme.
62
57
  However, if you need to use the default `next/image` component, you will need to add our CDN url to image domains settings:
63
58
  ```js
64
- export default {
59
+ module.exports = {
65
60
  /* ...your next config... */
66
61
  images: {
67
62
  domains: ['cdn.uc.assets.prezly.com'],
@@ -74,21 +69,26 @@ export default {
74
69
  If you want to support multi-language in your theme, you'll need to make additional changes to the file:
75
70
 
76
71
  ```js
77
- import { localeConfig } from '@prezly/theme-kit-nextjs/localeConfig';
72
+ const { DUMMY_DEFAULT_LOCALE } = require('@prezly/theme-kit-nextjs');
73
+ const locales = require('@prezly/theme-kit-nextjs/build/intl/localeConfig');
78
74
 
79
- export default {
75
+ module.exports = {
80
76
  /* ...your next config... */
81
77
 
82
- i18n: localeConfig,
78
+ i18n: {
79
+ // These are all the locales you want to support in
80
+ // your application
81
+ locales: [...locales, DUMMY_DEFAULT_LOCALE],
82
+ // This is the default locale you want to be used when visiting
83
+ // a non-locale prefixed path e.g. `/media`
84
+ // We use Pseudo locale used for localization testing, to reliably determine if we need to fallback to the default newsroom language
85
+ defaultLocale: DUMMY_DEFAULT_LOCALE,
86
+ // Default locale detection is disabled, since the locales would be determined by Prezly API
87
+ localeDetection: false,
88
+ },
83
89
  };
84
90
  ```
85
91
 
86
- The `localeConfig` sets three properties on `i18n` configuration:
87
-
88
- * `locales` - These are all locales that Prezly Theme can support
89
- * `defaultLocale` - A pseudo locale used for localization testing, to reliably determine if we need to fallback to the default newsroom language. This is needed for internal locale resolution in the Theme Kit
90
- * `localeDetection` is set to `false`, since the locales would be determined by Prezly API
91
-
92
92
  ### pages/_app.tsx
93
93
 
94
94
  In order to provide all the necessary data to the entire application, this library exports the `NewsroomContextProvider` component, which accepts props retrieved by our data-fetching methods (see next section). These props contain data that would be required to display common components like navigation, language picker, boilerplate, etc.
@@ -1,33 +1,23 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.fetchGalleries = fetchGalleries;
7
- var _index = require("../../data-fetching/index.js");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchGalleries = void 0;
4
+ const data_fetching_1 = require("../../data-fetching");
8
5
  async function fetchGalleries(req, res) {
9
- if (req.method !== 'POST') {
10
- res.status(405);
11
- return;
12
- }
13
- const {
14
- page,
15
- pageSize
16
- } = req.body;
17
- try {
18
- const api = (0, _index.getPrezlyApi)(req);
19
- const {
20
- galleries
21
- } = await api.getGalleries({
22
- page,
23
- pageSize
24
- });
25
- res.status(200).json({
26
- galleries
27
- });
28
- } catch (error) {
29
- res.status(500).send({
30
- message: error.message
31
- });
32
- }
33
- }
6
+ if (req.method !== 'POST') {
7
+ res.status(405);
8
+ return;
9
+ }
10
+ const { page, pageSize } = req.body;
11
+ try {
12
+ const api = (0, data_fetching_1.getPrezlyApi)(req);
13
+ const { galleries } = await api.getGalleries({ page, pageSize });
14
+ res.status(200).json({ galleries });
15
+ }
16
+ catch (error) {
17
+ res.status(500).send({
18
+ message: error.message,
19
+ });
20
+ }
21
+ }
22
+ exports.fetchGalleries = fetchGalleries;
23
+ //# sourceMappingURL=fetchGalleries.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetchGalleries.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/api-handlers/fetchGalleries.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,GAAmB,EAAE,GAAoB;IAC1E,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,EAAE;QACvB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChB,OAAO;KACV;IAED,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC;IAEpC,IAAI;QACA,MAAM,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QAE9B,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,GAAG,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;QAEjE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;KACvC;IAAC,OAAO,KAAK,EAAE;QACZ,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACjB,OAAO,EAAG,KAAe,CAAC,OAAO;SACpC,CAAC,CAAC;KACN;AACL,CAAC"}
1
+ {"version":3,"file":"fetchGalleries.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/api-handlers/fetchGalleries.ts"],"names":[],"mappings":";;;AAEA,uDAAmD;AAE5C,KAAK,UAAU,cAAc,CAAC,GAAmB,EAAE,GAAoB;IAC1E,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,EAAE;QACvB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChB,OAAO;KACV;IAED,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC;IAEpC,IAAI;QACA,MAAM,GAAG,GAAG,IAAA,4BAAY,EAAC,GAAG,CAAC,CAAC;QAE9B,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,GAAG,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;QAEjE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;KACvC;IAAC,OAAO,KAAK,EAAE;QACZ,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACjB,OAAO,EAAG,KAAe,CAAC,OAAO;SACpC,CAAC,CAAC;KACN;AACL,CAAC;AAnBD,wCAmBC"}
@@ -1,43 +1,25 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.fetchStories = fetchStories;
7
- var _index = require("../../data-fetching/index.js");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchStories = void 0;
4
+ const data_fetching_1 = require("../../data-fetching");
8
5
  async function fetchStories(req, res) {
9
- if (req.method !== 'POST') {
10
- res.status(405);
11
- return;
12
- }
13
- const {
14
- page,
15
- pageSize,
16
- category,
17
- include,
18
- localeCode
19
- } = req.body;
20
- try {
21
- const api = (0, _index.getPrezlyApi)(req);
22
- const {
23
- stories
24
- } = await (category ? api.getStoriesFromCategory(category, {
25
- page,
26
- pageSize,
27
- include,
28
- localeCode
29
- }) : api.getStories({
30
- page,
31
- pageSize,
32
- include,
33
- localeCode
34
- }));
35
- res.status(200).json({
36
- stories
37
- });
38
- } catch (error) {
39
- res.status(500).send({
40
- message: error.message
41
- });
42
- }
43
- }
6
+ if (req.method !== 'POST') {
7
+ res.status(405);
8
+ return;
9
+ }
10
+ const { page, pageSize, category, include, localeCode } = req.body;
11
+ try {
12
+ const api = (0, data_fetching_1.getPrezlyApi)(req);
13
+ const { stories } = await (category
14
+ ? api.getStoriesFromCategory(category, { page, pageSize, include, localeCode })
15
+ : api.getStories({ page, pageSize, include, localeCode }));
16
+ res.status(200).json({ stories });
17
+ }
18
+ catch (error) {
19
+ res.status(500).send({
20
+ message: error.message,
21
+ });
22
+ }
23
+ }
24
+ exports.fetchStories = fetchStories;
25
+ //# sourceMappingURL=fetchStories.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetchStories.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/api-handlers/fetchStories.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAmB,EAAE,GAAoB;IACxE,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,EAAE;QACvB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChB,OAAO;KACV;IAED,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC;IAEnE,IAAI;QACA,MAAM,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QAE9B,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,QAAQ;YAC/B,CAAC,CAAC,GAAG,CAAC,sBAAsB,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;YAC/E,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;QAE/D,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;KACrC;IAAC,OAAO,KAAK,EAAE;QACZ,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACjB,OAAO,EAAG,KAAe,CAAC,OAAO;SACpC,CAAC,CAAC;KACN;AACL,CAAC"}
1
+ {"version":3,"file":"fetchStories.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/api-handlers/fetchStories.ts"],"names":[],"mappings":";;;AAEA,uDAAmD;AAE5C,KAAK,UAAU,YAAY,CAAC,GAAmB,EAAE,GAAoB;IACxE,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,EAAE;QACvB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChB,OAAO;KACV;IAED,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC;IAEnE,IAAI;QACA,MAAM,GAAG,GAAG,IAAA,4BAAY,EAAC,GAAG,CAAC,CAAC;QAE9B,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,QAAQ;YAC/B,CAAC,CAAC,GAAG,CAAC,sBAAsB,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;YAC/E,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;QAE/D,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;KACrC;IAAC,OAAO,KAAK,EAAE;QACZ,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACjB,OAAO,EAAG,KAAe,CAAC,OAAO;SACpC,CAAC,CAAC;KACN;AACL,CAAC;AArBD,oCAqBC"}
@@ -1,19 +1,8 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "fetchGalleries", {
7
- enumerable: true,
8
- get: function () {
9
- return _fetchGalleries.fetchGalleries;
10
- }
11
- });
12
- Object.defineProperty(exports, "fetchStories", {
13
- enumerable: true,
14
- get: function () {
15
- return _fetchStories.fetchStories;
16
- }
17
- });
18
- var _fetchGalleries = require("./fetchGalleries.js");
19
- var _fetchStories = require("./fetchStories.js");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchStories = exports.fetchGalleries = void 0;
4
+ var fetchGalleries_1 = require("./fetchGalleries");
5
+ Object.defineProperty(exports, "fetchGalleries", { enumerable: true, get: function () { return fetchGalleries_1.fetchGalleries; } });
6
+ var fetchStories_1 = require("./fetchStories");
7
+ Object.defineProperty(exports, "fetchStories", { enumerable: true, get: function () { return fetchStories_1.fetchStories; } });
8
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/api-handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/api-handlers/index.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,+CAA8C;AAArC,4GAAA,YAAY,OAAA"}
@@ -1,26 +1,19 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getNewsroomServerSideProps = getNewsroomServerSideProps;
7
- var _index = require("../data-fetching/index.js");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNewsroomServerSideProps = void 0;
4
+ const data_fetching_1 = require("../data-fetching");
8
5
  /**
9
6
  * Use this function in your `getServerSideProps` page methods to retrieve the data necessary for the NewsroomContextProvider and `processRequest` function.
10
7
  * See README for usage examples.
11
8
  */
12
9
  async function getNewsroomServerSideProps(context, options = {}) {
13
- const {
14
- req: request,
15
- locale
16
- } = context;
17
- const api = (0, _index.getPrezlyApi)(request);
18
- const serverSideProps = await api.getNewsroomServerSideProps(request, locale, options.story);
19
- if (options.loadHomepageContacts) {
20
- serverSideProps.newsroomContextProps.contacts = await api.getNewsroomContacts();
21
- }
22
- return {
23
- api,
24
- serverSideProps
25
- };
26
- }
10
+ const { req: request, locale } = context;
11
+ const api = (0, data_fetching_1.getPrezlyApi)(request);
12
+ const serverSideProps = await api.getNewsroomServerSideProps(request, locale, options.story);
13
+ if (options.loadHomepageContacts) {
14
+ serverSideProps.newsroomContextProps.contacts = await api.getNewsroomContacts();
15
+ }
16
+ return { api, serverSideProps };
17
+ }
18
+ exports.getNewsroomServerSideProps = getNewsroomServerSideProps;
19
+ //# sourceMappingURL=getNewsroomServerSideProps.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getNewsroomServerSideProps.js","sourceRoot":"","sources":["../../src/adapter-nextjs/getNewsroomServerSideProps.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAOhD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC5C,OAAkC,EAClC,UAAmB,EAAE;IAErB,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAEzC,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IAClC,MAAM,eAAe,GAAG,MAAM,GAAG,CAAC,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAE7F,IAAI,OAAO,CAAC,oBAAoB,EAAE;QAC9B,eAAe,CAAC,oBAAoB,CAAC,QAAQ,GAAG,MAAM,GAAG,CAAC,mBAAmB,EAAE,CAAC;KACnF;IAED,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,CAAC;AACpC,CAAC"}
1
+ {"version":3,"file":"getNewsroomServerSideProps.js","sourceRoot":"","sources":["../../src/adapter-nextjs/getNewsroomServerSideProps.ts"],"names":[],"mappings":";;;AAGA,oDAAgD;AAOhD;;;GAGG;AACI,KAAK,UAAU,0BAA0B,CAC5C,OAAkC,EAClC,UAAmB,EAAE;IAErB,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAEzC,MAAM,GAAG,GAAG,IAAA,4BAAY,EAAC,OAAO,CAAC,CAAC;IAClC,MAAM,eAAe,GAAG,MAAM,GAAG,CAAC,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAE7F,IAAI,OAAO,CAAC,oBAAoB,EAAE;QAC9B,eAAe,CAAC,oBAAoB,CAAC,QAAQ,GAAG,MAAM,GAAG,CAAC,mBAAmB,EAAE,CAAC;KACnF;IAED,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,CAAC;AACpC,CAAC;AAdD,gEAcC"}
@@ -1,25 +1,19 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getNewsroomStaticProps = getNewsroomStaticProps;
7
- var _index = require("../data-fetching/index.js");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNewsroomStaticProps = void 0;
4
+ const data_fetching_1 = require("../data-fetching");
8
5
  /**
9
6
  * Use this function in your `getNewsroomStaticProps` page methods to retrieve the data necessary for the NewsroomContextProvider and `processRequest` function.
10
7
  * See README for usage examples.
11
8
  */
12
9
  async function getNewsroomStaticProps(context, options = {}) {
13
- const {
14
- locale
15
- } = context;
16
- const api = (0, _index.getPrezlyApi)();
17
- const staticProps = await api.getNewsroomServerSideProps(undefined, locale, options.story);
18
- if (options.loadHomepageContacts) {
19
- staticProps.newsroomContextProps.contacts = await api.getNewsroomContacts();
20
- }
21
- return {
22
- api,
23
- staticProps
24
- };
25
- }
10
+ const { locale } = context;
11
+ const api = (0, data_fetching_1.getPrezlyApi)();
12
+ const staticProps = await api.getNewsroomServerSideProps(undefined, locale, options.story);
13
+ if (options.loadHomepageContacts) {
14
+ staticProps.newsroomContextProps.contacts = await api.getNewsroomContacts();
15
+ }
16
+ return { api, staticProps };
17
+ }
18
+ exports.getNewsroomStaticProps = getNewsroomStaticProps;
19
+ //# sourceMappingURL=getNewsroomStaticProps.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getNewsroomStaticProps.js","sourceRoot":"","sources":["../../src/adapter-nextjs/getNewsroomStaticProps.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAOhD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CACxC,OAA8B,EAC9B,UAAmB,EAAE;IAErB,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE3B,MAAM,GAAG,GAAG,YAAY,EAAE,CAAC;IAC3B,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,0BAA0B,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAE3F,IAAI,OAAO,CAAC,oBAAoB,EAAE;QAC9B,WAAW,CAAC,oBAAoB,CAAC,QAAQ,GAAG,MAAM,GAAG,CAAC,mBAAmB,EAAE,CAAC;KAC/E;IAED,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC;AAChC,CAAC"}
1
+ {"version":3,"file":"getNewsroomStaticProps.js","sourceRoot":"","sources":["../../src/adapter-nextjs/getNewsroomStaticProps.ts"],"names":[],"mappings":";;;AAGA,oDAAgD;AAOhD;;;GAGG;AACI,KAAK,UAAU,sBAAsB,CACxC,OAA8B,EAC9B,UAAmB,EAAE;IAErB,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE3B,MAAM,GAAG,GAAG,IAAA,4BAAY,GAAE,CAAC;IAC3B,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,0BAA0B,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAE3F,IAAI,OAAO,CAAC,oBAAoB,EAAE;QAC9B,WAAW,CAAC,oBAAoB,CAAC,QAAQ,GAAG,MAAM,GAAG,CAAC,mBAAmB,EAAE,CAAC;KAC/E;IAED,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC;AAChC,CAAC;AAdD,wDAcC"}
@@ -1,71 +1,23 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _index = require("./api-handlers/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];
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
7
  }
15
- });
16
- });
17
- var _getNewsroomServerSideProps = require("./getNewsroomServerSideProps.js");
18
- Object.keys(_getNewsroomServerSideProps).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _getNewsroomServerSideProps[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _getNewsroomServerSideProps[key];
25
- }
26
- });
27
- });
28
- var _getNewsroomStaticProps = require("./getNewsroomStaticProps.js");
29
- Object.keys(_getNewsroomStaticProps).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _getNewsroomStaticProps[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function () {
35
- return _getNewsroomStaticProps[key];
36
- }
37
- });
38
- });
39
- var _index2 = require("./page-props/index.js");
40
- Object.keys(_index2).forEach(function (key) {
41
- if (key === "default" || key === "__esModule") return;
42
- if (key in exports && exports[key] === _index2[key]) return;
43
- Object.defineProperty(exports, key, {
44
- enumerable: true,
45
- get: function () {
46
- return _index2[key];
47
- }
48
- });
49
- });
50
- var _processRequest = require("./processRequest.js");
51
- Object.keys(_processRequest).forEach(function (key) {
52
- if (key === "default" || key === "__esModule") return;
53
- if (key in exports && exports[key] === _processRequest[key]) return;
54
- Object.defineProperty(exports, key, {
55
- enumerable: true,
56
- get: function () {
57
- return _processRequest[key];
58
- }
59
- });
60
- });
61
- var _processStaticRequest = require("./processStaticRequest.js");
62
- Object.keys(_processStaticRequest).forEach(function (key) {
63
- if (key === "default" || key === "__esModule") return;
64
- if (key in exports && exports[key] === _processStaticRequest[key]) return;
65
- Object.defineProperty(exports, key, {
66
- enumerable: true,
67
- get: function () {
68
- return _processStaticRequest[key];
69
- }
70
- });
71
- });
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./api-handlers"), exports);
18
+ __exportStar(require("./getNewsroomServerSideProps"), exports);
19
+ __exportStar(require("./getNewsroomStaticProps"), exports);
20
+ __exportStar(require("./page-props"), exports);
21
+ __exportStar(require("./processRequest"), exports);
22
+ __exportStar(require("./processStaticRequest"), exports);
23
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapter-nextjs/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapter-nextjs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,+DAA6C;AAC7C,2DAAyC;AACzC,+CAA6B;AAC7B,mDAAiC;AACjC,yDAAuC"}