@prezly/theme-kit-nextjs 1.18.2 → 2.0.0-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 (261) hide show
  1. package/build/adapter-nextjs/api-handlers/fetchGalleries.js +3 -7
  2. package/build/adapter-nextjs/api-handlers/fetchGalleries.js.map +1 -1
  3. package/build/adapter-nextjs/api-handlers/fetchStories.js +3 -7
  4. package/build/adapter-nextjs/api-handlers/fetchStories.js.map +1 -1
  5. package/build/adapter-nextjs/api-handlers/index.js +2 -7
  6. package/build/adapter-nextjs/api-handlers/index.js.map +1 -1
  7. package/build/adapter-nextjs/getNewsroomServerSideProps.js +3 -7
  8. package/build/adapter-nextjs/getNewsroomServerSideProps.js.map +1 -1
  9. package/build/adapter-nextjs/getNewsroomStaticProps.js +3 -7
  10. package/build/adapter-nextjs/getNewsroomStaticProps.js.map +1 -1
  11. package/build/adapter-nextjs/index.js +6 -22
  12. package/build/adapter-nextjs/index.js.map +1 -1
  13. package/build/adapter-nextjs/page-props/category.d.ts +2 -2
  14. package/build/adapter-nextjs/page-props/category.js +19 -25
  15. package/build/adapter-nextjs/page-props/category.js.map +1 -1
  16. package/build/adapter-nextjs/page-props/gallery.js +13 -18
  17. package/build/adapter-nextjs/page-props/gallery.js.map +1 -1
  18. package/build/adapter-nextjs/page-props/galleryAlbum.js +13 -19
  19. package/build/adapter-nextjs/page-props/galleryAlbum.js.map +1 -1
  20. package/build/adapter-nextjs/page-props/home.d.ts +2 -2
  21. package/build/adapter-nextjs/page-props/home.js +13 -18
  22. package/build/adapter-nextjs/page-props/home.js.map +1 -1
  23. package/build/adapter-nextjs/page-props/index.js +8 -41
  24. package/build/adapter-nextjs/page-props/index.js.map +1 -1
  25. package/build/adapter-nextjs/page-props/lib/types.js +1 -2
  26. package/build/adapter-nextjs/page-props/search.js +10 -15
  27. package/build/adapter-nextjs/page-props/search.js.map +1 -1
  28. package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js +1 -5
  29. package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js.map +1 -1
  30. package/build/adapter-nextjs/page-props/sitemap/createPaths.js +1 -5
  31. package/build/adapter-nextjs/page-props/sitemap/createPaths.js.map +1 -1
  32. package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js +7 -11
  33. package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js.map +1 -1
  34. package/build/adapter-nextjs/page-props/sitemap/index.js +4 -24
  35. package/build/adapter-nextjs/page-props/sitemap/index.js.map +1 -1
  36. package/build/adapter-nextjs/page-props/sitemap/types.js +1 -2
  37. package/build/adapter-nextjs/page-props/story.js +17 -23
  38. package/build/adapter-nextjs/page-props/story.js.map +1 -1
  39. package/build/adapter-nextjs/page-props/storyPreview.js +7 -11
  40. package/build/adapter-nextjs/page-props/storyPreview.js.map +1 -1
  41. package/build/adapter-nextjs/processRequest.js +5 -9
  42. package/build/adapter-nextjs/processRequest.js.map +1 -1
  43. package/build/adapter-nextjs/processStaticRequest.js +1 -5
  44. package/build/adapter-nextjs/processStaticRequest.js.map +1 -1
  45. package/build/components-nextjs/PageSeo/PageSeo.js +25 -29
  46. package/build/components-nextjs/PageSeo/PageSeo.js.map +1 -1
  47. package/build/components-nextjs/PageSeo/index.js +2 -20
  48. package/build/components-nextjs/PageSeo/index.js.map +1 -1
  49. package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js +1 -5
  50. package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js.map +1 -1
  51. package/build/components-nextjs/PageSeo/lib/types.js +1 -2
  52. package/build/components-nextjs/StorySeo/StorySeo.js +7 -11
  53. package/build/components-nextjs/StorySeo/StorySeo.js.map +1 -1
  54. package/build/components-nextjs/StorySeo/index.js +1 -5
  55. package/build/components-nextjs/StorySeo/index.js.map +1 -1
  56. package/build/components-nextjs/document.js +8 -35
  57. package/build/components-nextjs/document.js.map +1 -1
  58. package/build/components-nextjs/index.js +3 -9
  59. package/build/components-nextjs/index.js.map +1 -1
  60. package/build/data-fetching/api/PrezlyApi.d.ts +4 -5
  61. package/build/data-fetching/api/PrezlyApi.js +39 -44
  62. package/build/data-fetching/api/PrezlyApi.js.map +1 -1
  63. package/build/data-fetching/api/getPrezlyApi.js +5 -9
  64. package/build/data-fetching/api/getPrezlyApi.js.map +1 -1
  65. package/build/data-fetching/api/index.js +1 -17
  66. package/build/data-fetching/api/index.js.map +1 -1
  67. package/build/data-fetching/api/queries.js +5 -13
  68. package/build/data-fetching/api/queries.js.map +1 -1
  69. package/build/data-fetching/index.js +3 -19
  70. package/build/data-fetching/index.js.map +1 -1
  71. package/build/data-fetching/lib/getAlgoliaSettings.js +3 -7
  72. package/build/data-fetching/lib/getAlgoliaSettings.js.map +1 -1
  73. package/build/data-fetching/lib/getEnvVariables.js +3 -10
  74. package/build/data-fetching/lib/getEnvVariables.js.map +1 -1
  75. package/build/data-fetching/lib/index.js +4 -11
  76. package/build/data-fetching/lib/index.js.map +1 -1
  77. package/build/data-fetching/lib/isSdkError.js +1 -5
  78. package/build/data-fetching/lib/isSdkError.js.map +1 -1
  79. package/build/data-fetching/lib/isUuid.js +1 -5
  80. package/build/data-fetching/lib/isUuid.js.map +1 -1
  81. package/build/data-fetching/types.js +1 -2
  82. package/build/index.js +9 -25
  83. package/build/index.js.map +1 -1
  84. package/build/infinite-loading/index.js +4 -24
  85. package/build/infinite-loading/index.js.map +1 -1
  86. package/build/infinite-loading/types.js +1 -2
  87. package/build/infinite-loading/useInfiniteGalleriesLoading.js +3 -7
  88. package/build/infinite-loading/useInfiniteGalleriesLoading.js.map +1 -1
  89. package/build/infinite-loading/useInfiniteLoading.js +9 -13
  90. package/build/infinite-loading/useInfiniteLoading.js.map +1 -1
  91. package/build/infinite-loading/useInfiniteStoriesLoading.d.ts +2 -2
  92. package/build/infinite-loading/useInfiniteStoriesLoading.js +7 -11
  93. package/build/infinite-loading/useInfiniteStoriesLoading.js.map +1 -1
  94. package/build/intl/index.d.ts +1 -1
  95. package/build/intl/index.js +4 -25
  96. package/build/intl/index.js.map +1 -1
  97. package/build/intl/languages.d.ts +1 -1
  98. package/build/intl/languages.js +23 -37
  99. package/build/intl/languages.js.map +1 -1
  100. package/build/intl/locale.js +11 -17
  101. package/build/intl/locale.js.map +1 -1
  102. package/build/intl/localeConfig.d.ts +1 -2
  103. package/build/intl/localeConfig.js +3 -4
  104. package/build/intl/localeConfig.js.map +1 -1
  105. package/build/intl/localeList.d.ts +4 -2
  106. package/build/intl/localeList.js +1 -2
  107. package/build/intl/localeList.js.map +1 -1
  108. package/build/intl/localeObject.js +3 -10
  109. package/build/intl/localeObject.js.map +1 -1
  110. package/build/newsroom-context/context.js +7 -11
  111. package/build/newsroom-context/context.js.map +1 -1
  112. package/build/newsroom-context/hooks/index.js +11 -27
  113. package/build/newsroom-context/hooks/index.js.map +1 -1
  114. package/build/newsroom-context/hooks/useAlgoliaSettings.js +3 -7
  115. package/build/newsroom-context/hooks/useAlgoliaSettings.js.map +1 -1
  116. package/build/newsroom-context/hooks/useCategories.js +3 -7
  117. package/build/newsroom-context/hooks/useCategories.js.map +1 -1
  118. package/build/newsroom-context/hooks/useCompanyInformation.js +3 -7
  119. package/build/newsroom-context/hooks/useCompanyInformation.js.map +1 -1
  120. package/build/newsroom-context/hooks/useCurrentCategory.js +3 -7
  121. package/build/newsroom-context/hooks/useCurrentCategory.js.map +1 -1
  122. package/build/newsroom-context/hooks/useCurrentLocale.js +3 -7
  123. package/build/newsroom-context/hooks/useCurrentLocale.js.map +1 -1
  124. package/build/newsroom-context/hooks/useCurrentStory.js +3 -7
  125. package/build/newsroom-context/hooks/useCurrentStory.js.map +1 -1
  126. package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js +10 -14
  127. package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js.map +1 -1
  128. package/build/newsroom-context/hooks/useGetTranslationUrl.js +24 -31
  129. package/build/newsroom-context/hooks/useGetTranslationUrl.js.map +1 -1
  130. package/build/newsroom-context/hooks/useLanguages.js +3 -7
  131. package/build/newsroom-context/hooks/useLanguages.js.map +1 -1
  132. package/build/newsroom-context/hooks/useNewsroom.js +3 -7
  133. package/build/newsroom-context/hooks/useNewsroom.js.map +1 -1
  134. package/build/newsroom-context/hooks/useNewsroomContext.js +4 -8
  135. package/build/newsroom-context/hooks/useNewsroomContext.js.map +1 -1
  136. package/build/newsroom-context/index.js +2 -21
  137. package/build/newsroom-context/index.js.map +1 -1
  138. package/build/sentry/client.js +3 -7
  139. package/build/sentry/client.js.map +1 -1
  140. package/build/sentry/common.js +1 -5
  141. package/build/sentry/common.js.map +1 -1
  142. package/build/sentry/index.js +2 -7
  143. package/build/sentry/index.js.map +1 -1
  144. package/build/sentry/server.js +3 -7
  145. package/build/sentry/server.js.map +1 -1
  146. package/build/tsconfig.tsbuildinfo +1 -1
  147. package/build/types.d.ts +2 -2
  148. package/build/types.js +1 -2
  149. package/build/utils/boilerplate.js +3 -9
  150. package/build/utils/boilerplate.js.map +1 -1
  151. package/build/utils/constants.js +3 -6
  152. package/build/utils/constants.js.map +1 -1
  153. package/build/utils/getAssetsUrl.js +3 -7
  154. package/build/utils/getAssetsUrl.js.map +1 -1
  155. package/build/utils/getDataRequestLink.js +3 -7
  156. package/build/utils/getDataRequestLink.js.map +1 -1
  157. package/build/utils/getLocalizedCategoryData.js +3 -9
  158. package/build/utils/getLocalizedCategoryData.js.map +1 -1
  159. package/build/utils/getNewsroomLogoUrl.js +5 -10
  160. package/build/utils/getNewsroomLogoUrl.js.map +1 -1
  161. package/build/utils/getPrivacyPortalUrl.js +1 -5
  162. package/build/utils/getPrivacyPortalUrl.js.map +1 -1
  163. package/build/utils/getStoryPublicationDate.js +1 -5
  164. package/build/utils/getStoryPublicationDate.js.map +1 -1
  165. package/build/utils/getUploadcareGroupUrl.js +3 -7
  166. package/build/utils/getUploadcareGroupUrl.js.map +1 -1
  167. package/build/utils/index.js +10 -26
  168. package/build/utils/index.js.map +1 -1
  169. package/build/utils/isEmbargoStory.js +1 -5
  170. package/build/utils/isEmbargoStory.js.map +1 -1
  171. package/package.json +17 -17
  172. package/src/@types/global.d.ts +0 -7
  173. package/src/__mocks__/languages.ts +0 -417
  174. package/src/__mocks__/story.ts +0 -351
  175. package/src/adapter-nextjs/api-handlers/fetchGalleries.ts +0 -24
  176. package/src/adapter-nextjs/api-handlers/fetchStories.ts +0 -26
  177. package/src/adapter-nextjs/api-handlers/index.ts +0 -2
  178. package/src/adapter-nextjs/getNewsroomServerSideProps.ts +0 -29
  179. package/src/adapter-nextjs/getNewsroomStaticProps.ts +0 -29
  180. package/src/adapter-nextjs/index.ts +0 -6
  181. package/src/adapter-nextjs/page-props/category.ts +0 -157
  182. package/src/adapter-nextjs/page-props/gallery.ts +0 -114
  183. package/src/adapter-nextjs/page-props/galleryAlbum.ts +0 -89
  184. package/src/adapter-nextjs/page-props/home.ts +0 -113
  185. package/src/adapter-nextjs/page-props/index.ts +0 -26
  186. package/src/adapter-nextjs/page-props/lib/types.ts +0 -8
  187. package/src/adapter-nextjs/page-props/search.ts +0 -53
  188. package/src/adapter-nextjs/page-props/sitemap/SitemapBuilder.ts +0 -56
  189. package/src/adapter-nextjs/page-props/sitemap/createPaths.ts +0 -21
  190. package/src/adapter-nextjs/page-props/sitemap/getServerSideProps.ts +0 -43
  191. package/src/adapter-nextjs/page-props/sitemap/index.ts +0 -5
  192. package/src/adapter-nextjs/page-props/sitemap/types.ts +0 -5
  193. package/src/adapter-nextjs/page-props/story.ts +0 -94
  194. package/src/adapter-nextjs/page-props/storyPreview.ts +0 -33
  195. package/src/adapter-nextjs/processRequest.ts +0 -49
  196. package/src/adapter-nextjs/processStaticRequest.ts +0 -32
  197. package/src/components-nextjs/PageSeo/PageSeo.tsx +0 -131
  198. package/src/components-nextjs/PageSeo/index.ts +0 -2
  199. package/src/components-nextjs/PageSeo/lib/getAbsoluteUrl.ts +0 -7
  200. package/src/components-nextjs/PageSeo/lib/types.ts +0 -4
  201. package/src/components-nextjs/StorySeo/StorySeo.tsx +0 -80
  202. package/src/components-nextjs/StorySeo/index.ts +0 -1
  203. package/src/components-nextjs/document.tsx +0 -38
  204. package/src/components-nextjs/index.ts +0 -3
  205. package/src/data-fetching/api/PrezlyApi.ts +0 -302
  206. package/src/data-fetching/api/getPrezlyApi.ts +0 -24
  207. package/src/data-fetching/api/index.ts +0 -1
  208. package/src/data-fetching/api/queries.ts +0 -51
  209. package/src/data-fetching/index.ts +0 -3
  210. package/src/data-fetching/lib/getAlgoliaSettings.ts +0 -29
  211. package/src/data-fetching/lib/getEnvVariables.ts +0 -46
  212. package/src/data-fetching/lib/index.ts +0 -4
  213. package/src/data-fetching/lib/isSdkError.ts +0 -5
  214. package/src/data-fetching/lib/isUuid.ts +0 -5
  215. package/src/data-fetching/types.ts +0 -14
  216. package/src/index.ts +0 -9
  217. package/src/infinite-loading/index.ts +0 -4
  218. package/src/infinite-loading/types.ts +0 -5
  219. package/src/infinite-loading/useInfiniteGalleriesLoading.ts +0 -53
  220. package/src/infinite-loading/useInfiniteLoading.ts +0 -66
  221. package/src/infinite-loading/useInfiniteStoriesLoading.ts +0 -81
  222. package/src/intl/index.ts +0 -4
  223. package/src/intl/languages.test.ts +0 -232
  224. package/src/intl/languages.ts +0 -233
  225. package/src/intl/locale.test.ts +0 -94
  226. package/src/intl/locale.ts +0 -140
  227. package/src/intl/localeConfig.js +0 -23
  228. package/src/intl/localeList.js +0 -110
  229. package/src/intl/localeObject.test.ts +0 -81
  230. package/src/intl/localeObject.ts +0 -99
  231. package/src/newsroom-context/context.tsx +0 -115
  232. package/src/newsroom-context/hooks/index.ts +0 -11
  233. package/src/newsroom-context/hooks/useAlgoliaSettings.ts +0 -7
  234. package/src/newsroom-context/hooks/useCategories.ts +0 -7
  235. package/src/newsroom-context/hooks/useCompanyInformation.ts +0 -7
  236. package/src/newsroom-context/hooks/useCurrentCategory.ts +0 -7
  237. package/src/newsroom-context/hooks/useCurrentLocale.ts +0 -7
  238. package/src/newsroom-context/hooks/useCurrentStory.ts +0 -7
  239. package/src/newsroom-context/hooks/useGetLinkLocaleSlug.ts +0 -37
  240. package/src/newsroom-context/hooks/useGetTranslationUrl.ts +0 -96
  241. package/src/newsroom-context/hooks/useLanguages.ts +0 -7
  242. package/src/newsroom-context/hooks/useNewsroom.ts +0 -7
  243. package/src/newsroom-context/hooks/useNewsroomContext.ts +0 -15
  244. package/src/newsroom-context/index.ts +0 -2
  245. package/src/sentry/client.ts +0 -7
  246. package/src/sentry/common.ts +0 -27
  247. package/src/sentry/index.ts +0 -2
  248. package/src/sentry/server.ts +0 -7
  249. package/src/types.ts +0 -51
  250. package/src/utils/boilerplate.ts +0 -27
  251. package/src/utils/constants.ts +0 -3
  252. package/src/utils/getAssetsUrl.test.ts +0 -9
  253. package/src/utils/getAssetsUrl.ts +0 -9
  254. package/src/utils/getDataRequestLink.ts +0 -14
  255. package/src/utils/getLocalizedCategoryData.ts +0 -47
  256. package/src/utils/getNewsroomLogoUrl.ts +0 -22
  257. package/src/utils/getPrivacyPortalUrl.ts +0 -25
  258. package/src/utils/getStoryPublicationDate.tsx +0 -15
  259. package/src/utils/getUploadcareGroupUrl.ts +0 -13
  260. package/src/utils/index.ts +0 -10
  261. package/src/utils/isEmbargoStory.ts +0 -10
@@ -1,351 +0,0 @@
1
- import type { ExtendedStory } from '@prezly/sdk';
2
- import {
3
- NewsroomStatus,
4
- StoryLifecycleStatus,
5
- StoryPublicationStatus,
6
- StoryVisibility,
7
- TextDirection,
8
- } from '@prezly/sdk';
9
-
10
- export const STORY: ExtendedStory = {
11
- id: 380023,
12
- uuid: '65018f5b-b313-453f-b23b-9e739c6a8591',
13
- thumbnail_url:
14
- 'https://avatars-cdn.prezly.com/story/6337/380023/c3a3d56ee09ce808dbb1bc2f06d16b68bdaeefbf731d8a080b7e4d5e68fb3e94?t=1640077510&v=1',
15
- title: 'Take a breath',
16
- subtitle:
17
- "Going through your socials, you'll likely come across some guru preaching that this quarantine is the ideal moment to pause your busy life and just chill. While it's up to you to decide what's best, few can argue that you shouldn't take every opportunity to stick your head out and suck in a lungful of that fresh(er) air.",
18
- intro: '',
19
- summary:
20
- "Air quality has been an important topic this millennium. There were those who didn't believe we had an impact on it, but these past weeks have proved otherwise.",
21
- culture: {
22
- code: 'en',
23
- locale: 'en',
24
- name: 'English (Global)',
25
- native_name: 'English (Global)',
26
- direction: TextDirection.LTR,
27
- language_code: 'en',
28
- },
29
- slug: 'take-a-breath',
30
- format_version: 3,
31
- language: 'EN',
32
- lifecycle_status: StoryLifecycleStatus.PUBLISHED,
33
- publication_status: StoryPublicationStatus.PUBLISHED,
34
- visibility: StoryVisibility.PUBLIC,
35
- is_archived: false,
36
- is_finalized: true,
37
- is_published: true,
38
- is_draft: false,
39
- is_embargo: false,
40
- is_private: false,
41
- is_scheduled: false,
42
- is_analytics_available: true,
43
- is_sharable: true,
44
- created_at: '2020-04-28T12:03:46+00:00',
45
- updated_at: '2021-12-21T09:05:10+00:00',
46
- published_at: '2020-04-30T12:56:00+00:00',
47
- scheduled_at: null,
48
- author: {
49
- id: 7680,
50
- username: 'marthe@prezly.com',
51
- email: 'marthe@prezly.com',
52
- display_name: 'Marthe Anthonis',
53
- first_name: 'Marthe',
54
- last_name: 'Anthonis',
55
- avatar_url:
56
- 'https://avatars-cdn.prezly.com/user/7680/6260be53465a846a511c44edd8f594f38235d782f3fa515ab968ad2f947a236c?v=1&c=cc6e751bdb46638cd948d0d812149ce391e45b7cd2b5d80a94de575ba0ce65d0',
57
- use_case_answer: 'unknown',
58
- sign_in_flow: 'password',
59
- created_at: '2019-02-06T09:54:34+00:00',
60
- is_terms_of_service_accepted: false,
61
- last_seen_at: '2021-12-03T09:15:39+00:00',
62
- },
63
- newsroom: {
64
- uuid: '578e78e9-9a5b-44ad-bda2-5214895ee036',
65
- id: 12698,
66
- name: 'The Good News Room',
67
- display_name: 'The Good News Room',
68
- subdomain: 'the-good-news-room',
69
- thumbnail_url:
70
- 'https://avatars-cdn.prezly.com/newsroom/12698/e4939974b7781d4c61e282713116690387e9b7b1f6302478b13b68e18e0d3055?t=1648556918&v=1',
71
- timezone: 'europe/london',
72
- status: NewsroomStatus.ACTIVE,
73
- is_active: true,
74
- is_archived: false,
75
- is_online: true,
76
- is_offline: false,
77
- is_multilingual: true,
78
- is_indexable: true,
79
- url: 'https://the-good-news-room.prezly.com/',
80
- links: {
81
- media_gallery_api: 'https://api.prezly.com/v1/rooms/12698/media',
82
- analytics_and_visibility_settings:
83
- 'https://rock.prezly.com/pressroom/the-good-news-room/ga',
84
- categories_management:
85
- 'https://rock.prezly.com/settings/newsrooms/578e78e9-9a5b-44ad-bda2-5214895ee036/categories',
86
- company_info_settings:
87
- 'https://rock.prezly.com/settings/newsrooms/578e78e9-9a5b-44ad-bda2-5214895ee036/information',
88
- contacts_management:
89
- 'https://rock.prezly.com/settings/newsrooms/578e78e9-9a5b-44ad-bda2-5214895ee036/contacts',
90
- domain_settings: 'https://rock.prezly.com/pressroom/the-good-news-room/domain',
91
- edit: 'https://rock.prezly.com/settings/newsrooms/578e78e9-9a5b-44ad-bda2-5214895ee036/information',
92
- gallery_management: 'https://rock.prezly.com/pressroom/the-good-news-room/gallery',
93
- hub_settings: 'https://rock.prezly.com/pressroom/the-good-news-room/hub',
94
- languages:
95
- 'https://rock.prezly.com/settings/newsrooms/578e78e9-9a5b-44ad-bda2-5214895ee036/languages',
96
- look_and_feel_settings:
97
- 'https://rock.prezly.com/settings/newsrooms/578e78e9-9a5b-44ad-bda2-5214895ee036/themes',
98
- manual_subscription_management: '',
99
- privacy_settings:
100
- 'https://rock.prezly.com/settings/newsrooms/578e78e9-9a5b-44ad-bda2-5214895ee036/privacy',
101
- widget_settings: 'https://rock.prezly.com/pressroom/the-good-news-room/widget',
102
- },
103
- time_format: 'HH:mm',
104
- date_format: 'D/M/YY',
105
- },
106
- oembed: {
107
- type: 'link',
108
- url: 'https://the-good-news-room.prezly.com/take-a-breath',
109
- title: 'Take a breath',
110
- description:
111
- "Going through your socials, you'll likely come across some guru preaching that this quarantine is the ideal moment to pause your busy life and just chill. While it's up to you to decide what's best, few can argue that you shouldn't take every opportunity to stick your head out and suck in a lungful of that fresh(er) air.",
112
- thumbnail_url:
113
- 'https://cdn.uc.assets.prezly.com/e9dc3b29-3d91-46e4-b9a0-695f8517bbf0/-/preview/600x600/',
114
- thumbnail_width: 1024,
115
- thumbnail_height: 482,
116
- version: '1.0',
117
- },
118
- links: {
119
- api: 'https://api.prezly.com/v1/stories/380023',
120
- preview: '',
121
- edit: 'https://rock.prezly.com/stories/380023',
122
- sharing: 'https://rock.prezly.com/stories/380023/sharing',
123
- duplicate: 'https://rock.prezly.com/pressrelease/duplicate/380023',
124
- translate: 'https://rock.prezly.com/pressrelease/translate/380023',
125
- analytics: 'https://rock.prezly.com/stories/380023/report',
126
- publication_api: 'https://api.prezly.com/v1/stories/380023/publication',
127
- create_campaign: '',
128
- reports_api: 'https://api.prezly.com/v1/stories/380023/reports',
129
- short: 'http://prez.ly/zRAb',
130
- newsroom_view: 'https://the-good-news-room.prezly.com/take-a-breath',
131
- newsroom_preview:
132
- 'https://the-good-news-room.prezly.com/s/65018f5b-b313-453f-b23b-9e739c6a8591',
133
- },
134
- categories: [],
135
- translations: [
136
- {
137
- id: 380028,
138
- uuid: 'db07a149-ce6a-4446-a86e-689440fae2ac',
139
- slug: 'adem',
140
- thumbnail_url:
141
- 'https://avatars-cdn.prezly.com/story/6337/380028/6a9248cfbf88bbea5eb9ca1b3907a9bf163e4a41a34598ad38a3d1150c648b79?t=1640077505&v=1',
142
- title: 'Adem!',
143
- culture: {
144
- code: 'nl_BE',
145
- locale: 'nl_BE',
146
- name: 'Dutch (Belgium)',
147
- native_name: 'Nederlands (België)',
148
- direction: TextDirection.LTR,
149
- language_code: 'nl',
150
- },
151
- lifecycle_status: StoryLifecycleStatus.PUBLISHED,
152
- publication_status: StoryPublicationStatus.PUBLISHED,
153
- visibility: StoryVisibility.PUBLIC,
154
- created_at: '2020-05-05T10:07:11+00:00',
155
- updated_at: '2021-12-21T09:05:05+00:00',
156
- published_at: '2020-05-05T10:21:00+00:00',
157
- scheduled_at: null,
158
- author: {
159
- id: 7680,
160
- username: 'marthe@prezly.com',
161
- email: 'marthe@prezly.com',
162
- display_name: 'Marthe Anthonis',
163
- first_name: 'Marthe',
164
- last_name: 'Anthonis',
165
- avatar_url:
166
- 'https://avatars-cdn.prezly.com/user/7680/6260be53465a846a511c44edd8f594f38235d782f3fa515ab968ad2f947a236c?v=1&c=cc6e751bdb46638cd948d0d812149ce391e45b7cd2b5d80a94de575ba0ce65d0',
167
- use_case_answer: 'unknown',
168
- sign_in_flow: 'password',
169
- created_at: '2019-02-06T09:54:34+00:00',
170
- is_terms_of_service_accepted: false,
171
- last_seen_at: '2021-12-03T09:15:39+00:00',
172
- },
173
- newsroom: {
174
- uuid: '578e78e9-9a5b-44ad-bda2-5214895ee036',
175
- id: 12698,
176
- name: 'The Good News Room',
177
- display_name: 'The Good News Room',
178
- subdomain: 'the-good-news-room',
179
- thumbnail_url:
180
- 'https://avatars-cdn.prezly.com/newsroom/12698/e4939974b7781d4c61e282713116690387e9b7b1f6302478b13b68e18e0d3055?t=1648556918&v=1',
181
- timezone: 'europe/london',
182
- status: NewsroomStatus.ACTIVE,
183
- is_active: true,
184
- is_archived: false,
185
- is_online: true,
186
- is_offline: false,
187
- is_multilingual: true,
188
- is_indexable: true,
189
- url: 'https://the-good-news-room.prezly.com/',
190
- links: {
191
- media_gallery_api: 'https://api.prezly.com/v1/rooms/12698/media',
192
- analytics_and_visibility_settings:
193
- 'https://rock.prezly.com/pressroom/the-good-news-room/ga',
194
- categories_management:
195
- 'https://rock.prezly.com/settings/newsrooms/578e78e9-9a5b-44ad-bda2-5214895ee036/categories',
196
- company_info_settings:
197
- 'https://rock.prezly.com/settings/newsrooms/578e78e9-9a5b-44ad-bda2-5214895ee036/information',
198
- contacts_management:
199
- 'https://rock.prezly.com/settings/newsrooms/578e78e9-9a5b-44ad-bda2-5214895ee036/contacts',
200
- domain_settings: 'https://rock.prezly.com/pressroom/the-good-news-room/domain',
201
- edit: 'https://rock.prezly.com/settings/newsrooms/578e78e9-9a5b-44ad-bda2-5214895ee036/information',
202
- gallery_management:
203
- 'https://rock.prezly.com/pressroom/the-good-news-room/gallery',
204
- hub_settings: 'https://rock.prezly.com/pressroom/the-good-news-room/hub',
205
- languages:
206
- 'https://rock.prezly.com/settings/newsrooms/578e78e9-9a5b-44ad-bda2-5214895ee036/languages',
207
- look_and_feel_settings:
208
- 'https://rock.prezly.com/settings/newsrooms/578e78e9-9a5b-44ad-bda2-5214895ee036/themes',
209
- manual_subscription_management: '',
210
- privacy_settings:
211
- 'https://rock.prezly.com/settings/newsrooms/578e78e9-9a5b-44ad-bda2-5214895ee036/privacy',
212
- widget_settings: 'https://rock.prezly.com/pressroom/the-good-news-room/widget',
213
- },
214
- time_format: 'HH:mm',
215
- date_format: 'D/M/YY',
216
- },
217
- oembed: {
218
- type: 'link',
219
- url: 'https://the-good-news-room.prezly.com/adem',
220
- title: 'Adem!',
221
- description:
222
- 'Scrollen door je sociale media, levert deze dagen al snel een of andere post van een zelfgenaamde guru op die predikt dat dit een ideale moment is om je drukke leven even op pauze te zetten. Het is helemaal aan jou om te beslissen wat nu het beste is voor jou. Maar weinig mensen kunnen ontkennen dat nu een ideale moment is om je hoofd dor het raam te steken en grote gulpen fris(sere) lucht te nemen.',
223
- thumbnail_url:
224
- 'https://cdn.uc.assets.prezly.com/e9dc3b29-3d91-46e4-b9a0-695f8517bbf0/-/preview/600x600/',
225
- thumbnail_width: 1024,
226
- thumbnail_height: 482,
227
- version: '1.0',
228
- },
229
- links: {
230
- newsroom_view: 'https://the-good-news-room.prezly.com/adem',
231
- edit: 'https://rock.prezly.com/stories/380028',
232
- report: 'https://rock.prezly.com/stories/380028/report',
233
- },
234
- },
235
- {
236
- id: 492826,
237
- uuid: 'f6b9daa7-86fb-44f2-b3c3-7fe264b401d3',
238
- slug: 'translation-adem',
239
- thumbnail_url:
240
- 'https://avatars-cdn.prezly.com/story/6337/492826/65269a918884e706d75759f309085f3552a7a3848f5df74e3a11bed8a5649ac3?t=1656401349&v=1',
241
- title: '[translation] Adem!',
242
- culture: {
243
- code: 'nl_NL',
244
- locale: 'nl_NL',
245
- name: 'Dutch (Netherlands)',
246
- native_name: 'Nederlands (Nederland)',
247
- direction: TextDirection.LTR,
248
- language_code: 'nl',
249
- },
250
- lifecycle_status: StoryLifecycleStatus.PUBLISHED,
251
- publication_status: StoryPublicationStatus.PUBLISHED,
252
- visibility: StoryVisibility.PUBLIC,
253
- created_at: '2022-06-28T07:29:03+00:00',
254
- updated_at: '2022-06-28T07:29:09+00:00',
255
- published_at: '2022-06-28T07:29:09+00:00',
256
- scheduled_at: null,
257
- author: {
258
- id: 10324,
259
- username: 'oleg@prezly.com',
260
- email: 'oleg@prezly.com',
261
- display_name: 'Oleg Semyonov',
262
- first_name: 'Oleg',
263
- last_name: 'Semyonov',
264
- avatar_url:
265
- 'https://avatars-cdn.prezly.com/user/10324/85fc2201624703503c24a3a97cc7e1776015e9f6ffe2ad96016650add0b9ab5f?v=1&c=add8f27908ec1f74f1a7c0530a74d88027eea08d05cac4300713d1c07fed0e1b',
266
- use_case_answer: 'stories',
267
- sign_in_flow: 'google',
268
- created_at: '2021-02-25T13:30:04+00:00',
269
- is_terms_of_service_accepted: true,
270
- last_seen_at: '2022-06-28T09:06:32+00:00',
271
- },
272
- newsroom: {
273
- uuid: '578e78e9-9a5b-44ad-bda2-5214895ee036',
274
- id: 12698,
275
- name: 'The Good News Room',
276
- display_name: 'The Good News Room',
277
- subdomain: 'the-good-news-room',
278
- thumbnail_url:
279
- 'https://avatars-cdn.prezly.com/newsroom/12698/e4939974b7781d4c61e282713116690387e9b7b1f6302478b13b68e18e0d3055?t=1648556918&v=1',
280
- timezone: 'europe/london',
281
- status: NewsroomStatus.ACTIVE,
282
- is_active: true,
283
- is_archived: false,
284
- is_online: true,
285
- is_offline: false,
286
- is_multilingual: true,
287
- is_indexable: true,
288
- url: 'https://the-good-news-room.prezly.com/',
289
- links: {
290
- media_gallery_api: 'https://api.prezly.com/v1/rooms/12698/media',
291
- analytics_and_visibility_settings:
292
- 'https://rock.prezly.com/pressroom/the-good-news-room/ga',
293
- categories_management:
294
- 'https://rock.prezly.com/settings/newsrooms/578e78e9-9a5b-44ad-bda2-5214895ee036/categories',
295
- company_info_settings:
296
- 'https://rock.prezly.com/settings/newsrooms/578e78e9-9a5b-44ad-bda2-5214895ee036/information',
297
- contacts_management:
298
- 'https://rock.prezly.com/settings/newsrooms/578e78e9-9a5b-44ad-bda2-5214895ee036/contacts',
299
- domain_settings: 'https://rock.prezly.com/pressroom/the-good-news-room/domain',
300
- edit: 'https://rock.prezly.com/settings/newsrooms/578e78e9-9a5b-44ad-bda2-5214895ee036/information',
301
- gallery_management:
302
- 'https://rock.prezly.com/pressroom/the-good-news-room/gallery',
303
- hub_settings: 'https://rock.prezly.com/pressroom/the-good-news-room/hub',
304
- languages:
305
- 'https://rock.prezly.com/settings/newsrooms/578e78e9-9a5b-44ad-bda2-5214895ee036/languages',
306
- look_and_feel_settings:
307
- 'https://rock.prezly.com/settings/newsrooms/578e78e9-9a5b-44ad-bda2-5214895ee036/themes',
308
- manual_subscription_management: '',
309
- privacy_settings:
310
- 'https://rock.prezly.com/settings/newsrooms/578e78e9-9a5b-44ad-bda2-5214895ee036/privacy',
311
- widget_settings: 'https://rock.prezly.com/pressroom/the-good-news-room/widget',
312
- },
313
- time_format: 'HH:mm',
314
- date_format: 'D/M/YY',
315
- },
316
- oembed: {
317
- type: 'link',
318
- url: 'https://the-good-news-room.prezly.com/translation-adem',
319
- title: '[translation] Adem!',
320
- description:
321
- 'Scrollen door je sociale media, levert deze dagen al snel een of andere post van een zelfgenaamde guru op die predikt dat dit een ideale moment is om je drukke leven even op pauze te zetten. Het is helemaal aan jou om te beslissen wat nu het beste is voor jou. Maar weinig mensen kunnen ontkennen dat nu een ideale moment is om je hoofd dor het raam te steken en grote gulpen fris(sere) lucht te nemen.',
322
- thumbnail_url:
323
- 'https://cdn.uc.assets.prezly.com/e9dc3b29-3d91-46e4-b9a0-695f8517bbf0/-/preview/600x600/',
324
- thumbnail_width: 1024,
325
- thumbnail_height: 482,
326
- version: '1.0',
327
- },
328
- links: {
329
- newsroom_view: 'https://the-good-news-room.prezly.com/translation-adem',
330
- edit: 'https://rock.prezly.com/stories/492826',
331
- report: 'https://rock.prezly.com/stories/492826/report',
332
- },
333
- },
334
- ],
335
- coverage_number: 0,
336
- last_coverage_at: null,
337
- content:
338
- '{"type":"document","children":[{"type":"paragraph","children":[{"text":"Air quality has been an important topic this millennium. There were those who didn\'t believe we had an impact on it, but these past weeks have proved otherwise. "}]},{"type":"block-quote","children":[{"text":"\\"Air quality is an important factor in determining our lifespan.\\""}]},{"type":"paragraph","children":[{"text":"In "},{"text":"India","bold":true},{"text":", the most air polluted country in the world, the difference is immense. Below, you can see a picture – the left side was taken November 3, 2019, the right side March 30, 2020."}]},{"type":"paragraph","children":[{"text":"What a difference."}]},{"type":"image-block","href":"","file":{"version":2,"uuid":"4fd7edc3-0e7b-4de5-8d88-6fc384cdabd4","filename":"200401105309-20200401-indian-gate-air-pollution-split-super-tease.jpg","mime_type":"image/jpeg","size":73660,"original_width":1100,"original_height":619,"effects":[]},"layout":"contained","align":"center","new_tab":true,"width":"100%","children":[{"text":"Source: https://www.theguardian.com/environment/2020/apr/11/positively-alpine-disbelief-air-pollution-falls-lockdown-coronavirus"}]},{"type":"paragraph","children":[{"text":"Also in India, people are sharing incredible pictures of their view of the Himalayas. For the first time in 30 years, people can see the mountains with crystal clarity from a distance of 200km."}]},{"type":"embed","children":[{"text":""}],"uuid":"539e96a5-f721-4629-aa7c-d9f9946ede28","url":"https://twitter.com/parasrishi/status/1246376229902536704","oembed":{"url":"https://twitter.com/parasrishi/status/1246376229902536704","html":"<div class=\\"iframely-embed\\" style=\\"max-width: 550px;\\"><div class=\\"iframely-responsive\\" style=\\"padding-bottom: 56.2493%;\\"><a href=\\"https://twitter.com/parasrishi/status/1246376229902536704\\" data-iframely-url=\\"//cdn.iframe.ly/api/iframe?url=https%3A%2F%2Ftwitter.com%2Fparasrishi%2Fstatus%2F1246376229902536704&amp;key=8fe6cdec03482ac31f27a6ae8ea2fb3f\\"></a></div></div><script async src=\\"//cdn.iframe.ly/embed.js\\" charset=\\"utf-8\\"></script>","type":"rich","title":"Paras पारस ਰਿਸ਼ੀ on Twitter","author":"Paras पारस ਰਿਸ਼ੀ","options":{"_theme":{"value":"","values":{"dark":"Use dark theme"}},"_hide_media":{"label":"Hide photos, videos, and cards","value":false}},"version":"1.0","cache_age":86400,"author_url":"https://twitter.com/parasrishi","description":"The mighty Himalayas are now visible from Pathankot, Punjab. Thanks to super visibility and no pollution. What an incredible sight! 😌 pic.twitter.com/dY4AI9ZvXa— Paras पारस ਰਿਸ਼ੀ (@parasrishi) April 4, 2020\\n\\n","provider_name":"Twitter","thumbnail_url":"https://pbs.twimg.com/media/EUwEkVvUMAAbdmp.jpg:large","screenshot_url":"https://avatars-cdn.prezly.com/embed/aHR0cHM6Ly90d2l0dGVyLmNvbS9wYXJhc3Jpc2hpL3N0YXR1cy8xMjQ2Mzc2MjI5OTAyNTM2NzA0/9b51f0059a1ab9aaa9cf7c096572d112766eab778ba0f603a66a92e86ce892f7?v=1583930760","thumbnail_width":960,"thumbnail_height":540}},{"type":"paragraph","children":[{"text":""}]},{"type":"paragraph","children":[{"text":"And the effect of the quarantine on air pollution isn\'t only visible in India. Across the world, countries are seeing the benefits in air quality:"}]},{"type":"gallery","children":[{"text":""}],"images":[{"caption":"Italy","file":{"version":2,"uuid":"d6b4a0cd-3dfb-4bcf-9488-06d5516875b3","filename":"Italy.jpg","mime_type":"image/jpeg","size":88682,"original_width":1050,"original_height":450,"effects":[]}},{"caption":"China","file":{"version":2,"uuid":"43645b68-e8f6-407e-9981-04c9d7fdd069","filename":"China.webp","mime_type":"image/webp","size":97888,"original_width":1443,"original_height":811,"effects":[]}},{"caption":"Spain","file":{"version":2,"uuid":"88057ea6-4afd-41d3-98db-5eecd82033ed","filename":"Spain.jpg","mime_type":"image/jpeg","size":87588,"original_width":1080,"original_height":405,"effects":[]}},{"caption":"France","file":{"version":2,"uuid":"dfa3b432-a375-4afd-983f-444540845f56","filename":"France.jpg","mime_type":"image/jpeg","size":141548,"original_width":1440,"original_height":810,"effects":[]}}],"uuid":"b3b49cb3-2495-4206-9219-afcf56a049b8","layout":"full-width","padding":"M","thumbnail_size":"XS"},{"type":"paragraph","children":[{"text":""}]},{"type":"heading-one","children":[{"text":"Exact numbers"}]},{"type":"paragraph","children":[{"text":"As everyone can see, air quality has improved. However, experts find it difficult to express the improvement in numbers. You may have seen several headlines which stated \'40% less air pollution\', this isn\'t completely accurate. Overall, the amount of nitrogen dioxide has fallen but the amount of fine dust is still (too) high."}]},{"type":"block-quote","children":[{"text":"\\"Maybe, when the crisis is over, we\'ll work more remotely, which is good news for our air quality.\\""}]}],"version":"0.50"}',
339
- thumbnail_image:
340
- '{"version":2,"uuid":"e9dc3b29-3d91-46e4-b9a0-695f8517bbf0","filename":"air.jpg","mime_type":"image/jpeg","size":50225,"original_width":1024,"original_height":482,"effects":[]}',
341
- header_image:
342
- '{"size":442609,"uuid":"e8605194-da87-45f4-a241-ecacc103f6b2","effects":["\\/crop\\/670x280\\/0,25\\/","\\/preview\\/"],"version":2,"filename":"header.png","mime_type":"image\\/png","original_width":670,"original_height":447}',
343
- preview_image:
344
- '{"size":50225,"uuid":"e9dc3b29-3d91-46e4-b9a0-695f8517bbf0","effects":[],"version":2,"filename":"air.jpg","mime_type":"image\\/jpeg","original_width":1024,"original_height":482}',
345
- tag_names: [],
346
- social_text: 'Take a breath',
347
- social_image: null,
348
- referenced_entities: {
349
- stories: {},
350
- },
351
- };
@@ -1,24 +0,0 @@
1
- import type { NextApiRequest, NextApiResponse } from 'next';
2
-
3
- import { getPrezlyApi } from '../../data-fetching';
4
-
5
- export async function fetchGalleries(req: NextApiRequest, res: NextApiResponse) {
6
- if (req.method !== 'POST') {
7
- res.status(405);
8
- return;
9
- }
10
-
11
- const { page, pageSize } = req.body;
12
-
13
- try {
14
- const api = getPrezlyApi(req);
15
-
16
- const { galleries } = await api.getGalleries({ page, pageSize });
17
-
18
- res.status(200).json({ galleries });
19
- } catch (error) {
20
- res.status(500).send({
21
- message: (error as Error).message,
22
- });
23
- }
24
- }
@@ -1,26 +0,0 @@
1
- import type { NextApiRequest, NextApiResponse } from 'next';
2
-
3
- import { getPrezlyApi } from '../../data-fetching';
4
-
5
- export async function fetchStories(req: NextApiRequest, res: NextApiResponse) {
6
- if (req.method !== 'POST') {
7
- res.status(405);
8
- return;
9
- }
10
-
11
- const { page, pageSize, category, include, localeCode } = req.body;
12
-
13
- try {
14
- const api = getPrezlyApi(req);
15
-
16
- const { stories } = await (category
17
- ? api.getStoriesFromCategory(category, { page, pageSize, include, localeCode })
18
- : api.getStories({ page, pageSize, include, localeCode }));
19
-
20
- res.status(200).json({ stories });
21
- } catch (error) {
22
- res.status(500).send({
23
- message: (error as Error).message,
24
- });
25
- }
26
- }
@@ -1,2 +0,0 @@
1
- export { fetchGalleries } from './fetchGalleries';
2
- export { fetchStories } from './fetchStories';
@@ -1,29 +0,0 @@
1
- import type { Story } from '@prezly/sdk';
2
- import type { GetServerSidePropsContext } from 'next';
3
-
4
- import { getPrezlyApi } from '../data-fetching';
5
-
6
- interface Options {
7
- loadHomepageContacts?: boolean;
8
- story?: Story;
9
- }
10
-
11
- /**
12
- * Use this function in your `getServerSideProps` page methods to retrieve the data necessary for the NewsroomContextProvider and `processRequest` function.
13
- * See README for usage examples.
14
- */
15
- export async function getNewsroomServerSideProps(
16
- context: GetServerSidePropsContext,
17
- options: Options = {},
18
- ) {
19
- const { req: request, locale } = context;
20
-
21
- const api = getPrezlyApi(request);
22
- const serverSideProps = await api.getNewsroomServerSideProps(request, locale, options.story);
23
-
24
- if (options.loadHomepageContacts) {
25
- serverSideProps.newsroomContextProps.contacts = await api.getNewsroomContacts();
26
- }
27
-
28
- return { api, serverSideProps };
29
- }
@@ -1,29 +0,0 @@
1
- import type { Story } from '@prezly/sdk';
2
- import type { GetStaticPropsContext } from 'next';
3
-
4
- import { getPrezlyApi } from '../data-fetching';
5
-
6
- interface Options {
7
- loadHomepageContacts?: boolean;
8
- story?: Story;
9
- }
10
-
11
- /**
12
- * Use this function in your `getNewsroomStaticProps` page methods to retrieve the data necessary for the NewsroomContextProvider and `processRequest` function.
13
- * See README for usage examples.
14
- */
15
- export async function getNewsroomStaticProps(
16
- context: GetStaticPropsContext,
17
- options: Options = {},
18
- ) {
19
- const { locale } = context;
20
-
21
- const api = getPrezlyApi();
22
- const staticProps = await api.getNewsroomServerSideProps(undefined, locale, options.story);
23
-
24
- if (options.loadHomepageContacts) {
25
- staticProps.newsroomContextProps.contacts = await api.getNewsroomContacts();
26
- }
27
-
28
- return { api, staticProps };
29
- }
@@ -1,6 +0,0 @@
1
- export * from './api-handlers';
2
- export * from './getNewsroomServerSideProps';
3
- export * from './getNewsroomStaticProps';
4
- export * from './page-props';
5
- export * from './processRequest';
6
- export * from './processStaticRequest';
@@ -1,157 +0,0 @@
1
- import type { ExtraStoryFields, Story } from '@prezly/sdk';
2
- import type {
3
- GetServerSidePropsContext,
4
- GetServerSidePropsResult,
5
- GetStaticPathsResult,
6
- GetStaticPropsContext,
7
- GetStaticPropsResult,
8
- } from 'next';
9
-
10
- import { getPrezlyApi } from '../../data-fetching';
11
- import type { PaginationProps } from '../../infinite-loading/types';
12
- import { LocaleObject } from '../../intl';
13
- import { DEFAULT_PAGE_SIZE, getLocalizedCategoryData } from '../../utils';
14
- import { getNewsroomServerSideProps } from '../getNewsroomServerSideProps';
15
- import { getNewsroomStaticProps } from '../getNewsroomStaticProps';
16
- import { processRequest } from '../processRequest';
17
- import { processStaticRequest } from '../processStaticRequest';
18
-
19
- import type { PropsFunction } from './lib/types';
20
-
21
- export interface CategoryPageProps<StoryType extends Story = Story> {
22
- stories: StoryType[];
23
- pagination: PaginationProps;
24
- }
25
-
26
- interface Options {
27
- extraStoryFields?: (keyof ExtraStoryFields)[];
28
- pageSize?: number;
29
- }
30
-
31
- export function getCategoryPageServerSideProps<
32
- CustomProps extends Record<string, any>,
33
- StoryType extends Story = Story,
34
- >(customProps: CustomProps | PropsFunction<CustomProps>, options?: Options) {
35
- const { pageSize = DEFAULT_PAGE_SIZE, extraStoryFields } = options || {};
36
-
37
- return async function getServerSideProps(
38
- context: GetServerSidePropsContext,
39
- ): Promise<GetServerSidePropsResult<CategoryPageProps<StoryType> & CustomProps>> {
40
- const { api, serverSideProps } = await getNewsroomServerSideProps(context);
41
-
42
- const { slug } = context.params as { slug: string };
43
- const category = await api.getCategoryBySlug(slug);
44
-
45
- if (!category) {
46
- return {
47
- notFound: true,
48
- };
49
- }
50
-
51
- const { query } = context;
52
- const page = query.page && typeof query.page === 'string' ? Number(query.page) : undefined;
53
-
54
- const { localeCode } = serverSideProps.newsroomContextProps;
55
-
56
- const { stories, storiesTotal } = await api.getStoriesFromCategory(category, {
57
- page,
58
- pageSize,
59
- include: extraStoryFields,
60
- localeCode,
61
- });
62
-
63
- serverSideProps.newsroomContextProps.currentCategory = category;
64
-
65
- return processRequest(
66
- context,
67
- {
68
- ...serverSideProps,
69
- // TODO: This is temporary until return types from API are figured out
70
- stories: stories as StoryType[],
71
- pagination: {
72
- itemsTotal: storiesTotal,
73
- currentPage: page ?? 1,
74
- pageSize,
75
- },
76
- ...(typeof customProps === 'function'
77
- ? await (customProps as PropsFunction<CustomProps>)(context, serverSideProps)
78
- : customProps),
79
- },
80
- `/category/${slug}`,
81
- );
82
- };
83
- }
84
-
85
- export function getCategoryPageStaticProps<
86
- CustomProps extends Record<string, any>,
87
- StoryType extends Story = Story,
88
- >(customProps: CustomProps | PropsFunction<CustomProps, GetStaticPropsContext>, options?: Options) {
89
- const { pageSize = DEFAULT_PAGE_SIZE, extraStoryFields } = options || {};
90
-
91
- return async function getStaticProps(
92
- context: GetStaticPropsContext,
93
- ): Promise<GetStaticPropsResult<CategoryPageProps<StoryType> & CustomProps>> {
94
- const { api, staticProps } = await getNewsroomStaticProps(context);
95
-
96
- const { slug } = context.params as { slug: string };
97
- const category = await api.getCategoryBySlug(slug);
98
-
99
- if (!category) {
100
- return {
101
- notFound: true,
102
- };
103
- }
104
-
105
- const { localeCode } = staticProps.newsroomContextProps;
106
-
107
- const { stories, storiesTotal } = await api.getStoriesFromCategory(category, {
108
- pageSize,
109
- include: extraStoryFields,
110
- localeCode,
111
- });
112
-
113
- staticProps.newsroomContextProps.currentCategory = category;
114
-
115
- return processStaticRequest(context, {
116
- ...staticProps,
117
- // TODO: This is temporary until return types from API are figured out
118
- stories: stories as StoryType[],
119
- pagination: {
120
- itemsTotal: storiesTotal,
121
- currentPage: 1,
122
- pageSize,
123
- },
124
- ...(typeof customProps === 'function'
125
- ? await (customProps as PropsFunction<CustomProps, GetStaticPropsContext>)(
126
- context,
127
- staticProps,
128
- )
129
- : customProps),
130
- });
131
- };
132
- }
133
-
134
- export async function getCategoryPageStaticPaths(): Promise<GetStaticPathsResult> {
135
- const api = getPrezlyApi();
136
- const [categories, defaultLanguage] = await Promise.all([
137
- api.getCategories(),
138
- api.getNewsroomDefaultLanguage(),
139
- ]);
140
- const locale = LocaleObject.fromAnyCode(defaultLanguage.code);
141
-
142
- const paths = categories
143
- .map((category) => {
144
- const { slug } = getLocalizedCategoryData(category, locale);
145
- if (!slug) {
146
- return undefined;
147
- }
148
-
149
- return { params: { slug } };
150
- })
151
- .filter<{ params: { slug: string } }>(Boolean as any);
152
-
153
- return {
154
- paths,
155
- fallback: 'blocking',
156
- };
157
- }