@prezly/theme-kit-nextjs 1.18.2 → 2.0.0-1

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 (262) hide show
  1. package/build/@types/global.d.js +1 -0
  2. package/build/adapter-nextjs/api-handlers/fetchGalleries.js +27 -23
  3. package/build/adapter-nextjs/api-handlers/fetchGalleries.js.map +1 -1
  4. package/build/adapter-nextjs/api-handlers/fetchStories.js +37 -25
  5. package/build/adapter-nextjs/api-handlers/fetchStories.js.map +1 -1
  6. package/build/adapter-nextjs/api-handlers/index.js +2 -8
  7. package/build/adapter-nextjs/api-handlers/index.js.map +1 -1
  8. package/build/adapter-nextjs/getNewsroomServerSideProps.js +16 -15
  9. package/build/adapter-nextjs/getNewsroomServerSideProps.js.map +1 -1
  10. package/build/adapter-nextjs/getNewsroomStaticProps.js +15 -15
  11. package/build/adapter-nextjs/getNewsroomStaticProps.js.map +1 -1
  12. package/build/adapter-nextjs/index.js +6 -23
  13. package/build/adapter-nextjs/index.js.map +1 -1
  14. package/build/adapter-nextjs/page-props/category.d.ts +2 -2
  15. package/build/adapter-nextjs/page-props/category.js +118 -100
  16. package/build/adapter-nextjs/page-props/category.js.map +1 -1
  17. package/build/adapter-nextjs/page-props/gallery.js +87 -68
  18. package/build/adapter-nextjs/page-props/gallery.js.map +1 -1
  19. package/build/adapter-nextjs/page-props/galleryAlbum.js +64 -53
  20. package/build/adapter-nextjs/page-props/galleryAlbum.js.map +1 -1
  21. package/build/adapter-nextjs/page-props/home.d.ts +2 -2
  22. package/build/adapter-nextjs/page-props/home.js +83 -69
  23. package/build/adapter-nextjs/page-props/home.js.map +1 -1
  24. package/build/adapter-nextjs/page-props/index.js +8 -42
  25. package/build/adapter-nextjs/page-props/index.js.map +1 -1
  26. package/build/adapter-nextjs/page-props/lib/types.js +1 -3
  27. package/build/adapter-nextjs/page-props/search.js +25 -31
  28. package/build/adapter-nextjs/page-props/search.js.map +1 -1
  29. package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js +29 -50
  30. package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js.map +1 -1
  31. package/build/adapter-nextjs/page-props/sitemap/createPaths.js +13 -19
  32. package/build/adapter-nextjs/page-props/sitemap/createPaths.js.map +1 -1
  33. package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js +33 -35
  34. package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js.map +1 -1
  35. package/build/adapter-nextjs/page-props/sitemap/index.js +4 -25
  36. package/build/adapter-nextjs/page-props/sitemap/index.js.map +1 -1
  37. package/build/adapter-nextjs/page-props/sitemap/types.js +1 -3
  38. package/build/adapter-nextjs/page-props/story.js +77 -64
  39. package/build/adapter-nextjs/page-props/story.js.map +1 -1
  40. package/build/adapter-nextjs/page-props/storyPreview.js +27 -26
  41. package/build/adapter-nextjs/page-props/storyPreview.js.map +1 -1
  42. package/build/adapter-nextjs/processRequest.js +34 -25
  43. package/build/adapter-nextjs/processRequest.js.map +1 -1
  44. package/build/adapter-nextjs/processStaticRequest.js +19 -16
  45. package/build/adapter-nextjs/processStaticRequest.js.map +1 -1
  46. package/build/components-nextjs/PageSeo/PageSeo.js +84 -78
  47. package/build/components-nextjs/PageSeo/PageSeo.js.map +1 -1
  48. package/build/components-nextjs/PageSeo/index.js +2 -21
  49. package/build/components-nextjs/PageSeo/index.js.map +1 -1
  50. package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js +5 -10
  51. package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js.map +1 -1
  52. package/build/components-nextjs/PageSeo/lib/types.js +1 -3
  53. package/build/components-nextjs/StorySeo/StorySeo.js +69 -47
  54. package/build/components-nextjs/StorySeo/StorySeo.js.map +1 -1
  55. package/build/components-nextjs/StorySeo/index.js +1 -6
  56. package/build/components-nextjs/StorySeo/index.js.map +1 -1
  57. package/build/components-nextjs/document.js +31 -48
  58. package/build/components-nextjs/document.js.map +1 -1
  59. package/build/components-nextjs/index.js +3 -10
  60. package/build/components-nextjs/index.js.map +1 -1
  61. package/build/data-fetching/api/PrezlyApi.d.ts +4 -5
  62. package/build/data-fetching/api/PrezlyApi.js +207 -192
  63. package/build/data-fetching/api/PrezlyApi.js.map +1 -1
  64. package/build/data-fetching/api/getPrezlyApi.js +21 -21
  65. package/build/data-fetching/api/getPrezlyApi.js.map +1 -1
  66. package/build/data-fetching/api/index.js +1 -18
  67. package/build/data-fetching/api/index.js.map +1 -1
  68. package/build/data-fetching/api/queries.js +76 -47
  69. package/build/data-fetching/api/queries.js.map +1 -1
  70. package/build/data-fetching/index.js +3 -20
  71. package/build/data-fetching/index.js.map +1 -1
  72. package/build/data-fetching/lib/getAlgoliaSettings.js +22 -22
  73. package/build/data-fetching/lib/getAlgoliaSettings.js.map +1 -1
  74. package/build/data-fetching/lib/getEnvVariables.js +35 -38
  75. package/build/data-fetching/lib/getEnvVariables.js.map +1 -1
  76. package/build/data-fetching/lib/index.js +4 -12
  77. package/build/data-fetching/lib/index.js.map +1 -1
  78. package/build/data-fetching/lib/isSdkError.js +3 -8
  79. package/build/data-fetching/lib/isSdkError.js.map +1 -1
  80. package/build/data-fetching/lib/isUuid.js +3 -8
  81. package/build/data-fetching/lib/isUuid.js.map +1 -1
  82. package/build/data-fetching/types.js +1 -3
  83. package/build/index.js +9 -26
  84. package/build/index.js.map +1 -1
  85. package/build/infinite-loading/index.js +4 -25
  86. package/build/infinite-loading/index.js.map +1 -1
  87. package/build/infinite-loading/types.js +1 -3
  88. package/build/infinite-loading/useInfiniteGalleriesLoading.js +42 -37
  89. package/build/infinite-loading/useInfiniteGalleriesLoading.js.map +1 -1
  90. package/build/infinite-loading/useInfiniteLoading.js +50 -43
  91. package/build/infinite-loading/useInfiniteLoading.js.map +1 -1
  92. package/build/infinite-loading/useInfiniteStoriesLoading.d.ts +2 -2
  93. package/build/infinite-loading/useInfiniteStoriesLoading.js +56 -50
  94. package/build/infinite-loading/useInfiniteStoriesLoading.js.map +1 -1
  95. package/build/intl/index.d.ts +1 -1
  96. package/build/intl/index.js +4 -26
  97. package/build/intl/index.js.map +1 -1
  98. package/build/intl/languages.d.ts +1 -1
  99. package/build/intl/languages.js +146 -122
  100. package/build/intl/languages.js.map +1 -1
  101. package/build/intl/locale.js +52 -107
  102. package/build/intl/locale.js.map +1 -1
  103. package/build/intl/localeConfig.d.ts +1 -2
  104. package/build/intl/localeConfig.js +7 -14
  105. package/build/intl/localeConfig.js.map +1 -1
  106. package/build/intl/localeList.d.ts +4 -2
  107. package/build/intl/localeList.js +1 -109
  108. package/build/intl/localeList.js.map +1 -1
  109. package/build/intl/localeObject.js +80 -82
  110. package/build/intl/localeObject.js.map +1 -1
  111. package/build/newsroom-context/context.js +35 -25
  112. package/build/newsroom-context/context.js.map +1 -1
  113. package/build/newsroom-context/hooks/index.js +11 -28
  114. package/build/newsroom-context/hooks/index.js.map +1 -1
  115. package/build/newsroom-context/hooks/useAlgoliaSettings.js +5 -10
  116. package/build/newsroom-context/hooks/useAlgoliaSettings.js.map +1 -1
  117. package/build/newsroom-context/hooks/useCategories.js +5 -10
  118. package/build/newsroom-context/hooks/useCategories.js.map +1 -1
  119. package/build/newsroom-context/hooks/useCompanyInformation.js +5 -10
  120. package/build/newsroom-context/hooks/useCompanyInformation.js.map +1 -1
  121. package/build/newsroom-context/hooks/useCurrentCategory.js +5 -10
  122. package/build/newsroom-context/hooks/useCurrentCategory.js.map +1 -1
  123. package/build/newsroom-context/hooks/useCurrentLocale.js +5 -10
  124. package/build/newsroom-context/hooks/useCurrentLocale.js.map +1 -1
  125. package/build/newsroom-context/hooks/useCurrentStory.js +5 -10
  126. package/build/newsroom-context/hooks/useCurrentStory.js.map +1 -1
  127. package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js +17 -21
  128. package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js.map +1 -1
  129. package/build/newsroom-context/hooks/useGetTranslationUrl.js +52 -55
  130. package/build/newsroom-context/hooks/useGetTranslationUrl.js.map +1 -1
  131. package/build/newsroom-context/hooks/useLanguages.js +5 -10
  132. package/build/newsroom-context/hooks/useLanguages.js.map +1 -1
  133. package/build/newsroom-context/hooks/useNewsroom.js +5 -10
  134. package/build/newsroom-context/hooks/useNewsroom.js.map +1 -1
  135. package/build/newsroom-context/hooks/useNewsroomContext.js +11 -16
  136. package/build/newsroom-context/hooks/useNewsroomContext.js.map +1 -1
  137. package/build/newsroom-context/index.js +2 -22
  138. package/build/newsroom-context/index.js.map +1 -1
  139. package/build/sentry/client.js +4 -9
  140. package/build/sentry/client.js.map +1 -1
  141. package/build/sentry/common.js +26 -29
  142. package/build/sentry/common.js.map +1 -1
  143. package/build/sentry/index.js +2 -8
  144. package/build/sentry/index.js.map +1 -1
  145. package/build/sentry/server.js +4 -9
  146. package/build/sentry/server.js.map +1 -1
  147. package/build/types.d.ts +2 -2
  148. package/build/types.js +1 -3
  149. package/build/utils/boilerplate.js +7 -22
  150. package/build/utils/boilerplate.js.map +1 -1
  151. package/build/utils/constants.js +3 -7
  152. package/build/utils/constants.js.map +1 -1
  153. package/build/utils/getAssetsUrl.js +4 -9
  154. package/build/utils/getAssetsUrl.js.map +1 -1
  155. package/build/utils/getDataRequestLink.js +6 -12
  156. package/build/utils/getDataRequestLink.js.map +1 -1
  157. package/build/utils/getLocalizedCategoryData.js +33 -33
  158. package/build/utils/getLocalizedCategoryData.js.map +1 -1
  159. package/build/utils/getNewsroomLogoUrl.js +15 -21
  160. package/build/utils/getNewsroomLogoUrl.js.map +1 -1
  161. package/build/utils/getPrivacyPortalUrl.js +11 -13
  162. package/build/utils/getPrivacyPortalUrl.js.map +1 -1
  163. package/build/utils/getStoryPublicationDate.js +9 -14
  164. package/build/utils/getStoryPublicationDate.js.map +1 -1
  165. package/build/utils/getUploadcareGroupUrl.js +5 -10
  166. package/build/utils/getUploadcareGroupUrl.js.map +1 -1
  167. package/build/utils/index.js +10 -27
  168. package/build/utils/index.js.map +1 -1
  169. package/build/utils/isEmbargoStory.js +3 -8
  170. package/build/utils/isEmbargoStory.js.map +1 -1
  171. package/package.json +26 -18
  172. package/build/tsconfig.tsbuildinfo +0 -1
  173. package/src/@types/global.d.ts +0 -7
  174. package/src/__mocks__/languages.ts +0 -417
  175. package/src/__mocks__/story.ts +0 -351
  176. package/src/adapter-nextjs/api-handlers/fetchGalleries.ts +0 -24
  177. package/src/adapter-nextjs/api-handlers/fetchStories.ts +0 -26
  178. package/src/adapter-nextjs/api-handlers/index.ts +0 -2
  179. package/src/adapter-nextjs/getNewsroomServerSideProps.ts +0 -29
  180. package/src/adapter-nextjs/getNewsroomStaticProps.ts +0 -29
  181. package/src/adapter-nextjs/index.ts +0 -6
  182. package/src/adapter-nextjs/page-props/category.ts +0 -157
  183. package/src/adapter-nextjs/page-props/gallery.ts +0 -114
  184. package/src/adapter-nextjs/page-props/galleryAlbum.ts +0 -89
  185. package/src/adapter-nextjs/page-props/home.ts +0 -113
  186. package/src/adapter-nextjs/page-props/index.ts +0 -26
  187. package/src/adapter-nextjs/page-props/lib/types.ts +0 -8
  188. package/src/adapter-nextjs/page-props/search.ts +0 -53
  189. package/src/adapter-nextjs/page-props/sitemap/SitemapBuilder.ts +0 -56
  190. package/src/adapter-nextjs/page-props/sitemap/createPaths.ts +0 -21
  191. package/src/adapter-nextjs/page-props/sitemap/getServerSideProps.ts +0 -43
  192. package/src/adapter-nextjs/page-props/sitemap/index.ts +0 -5
  193. package/src/adapter-nextjs/page-props/sitemap/types.ts +0 -5
  194. package/src/adapter-nextjs/page-props/story.ts +0 -94
  195. package/src/adapter-nextjs/page-props/storyPreview.ts +0 -33
  196. package/src/adapter-nextjs/processRequest.ts +0 -49
  197. package/src/adapter-nextjs/processStaticRequest.ts +0 -32
  198. package/src/components-nextjs/PageSeo/PageSeo.tsx +0 -131
  199. package/src/components-nextjs/PageSeo/index.ts +0 -2
  200. package/src/components-nextjs/PageSeo/lib/getAbsoluteUrl.ts +0 -7
  201. package/src/components-nextjs/PageSeo/lib/types.ts +0 -4
  202. package/src/components-nextjs/StorySeo/StorySeo.tsx +0 -80
  203. package/src/components-nextjs/StorySeo/index.ts +0 -1
  204. package/src/components-nextjs/document.tsx +0 -38
  205. package/src/components-nextjs/index.ts +0 -3
  206. package/src/data-fetching/api/PrezlyApi.ts +0 -302
  207. package/src/data-fetching/api/getPrezlyApi.ts +0 -24
  208. package/src/data-fetching/api/index.ts +0 -1
  209. package/src/data-fetching/api/queries.ts +0 -51
  210. package/src/data-fetching/index.ts +0 -3
  211. package/src/data-fetching/lib/getAlgoliaSettings.ts +0 -29
  212. package/src/data-fetching/lib/getEnvVariables.ts +0 -46
  213. package/src/data-fetching/lib/index.ts +0 -4
  214. package/src/data-fetching/lib/isSdkError.ts +0 -5
  215. package/src/data-fetching/lib/isUuid.ts +0 -5
  216. package/src/data-fetching/types.ts +0 -14
  217. package/src/index.ts +0 -9
  218. package/src/infinite-loading/index.ts +0 -4
  219. package/src/infinite-loading/types.ts +0 -5
  220. package/src/infinite-loading/useInfiniteGalleriesLoading.ts +0 -53
  221. package/src/infinite-loading/useInfiniteLoading.ts +0 -66
  222. package/src/infinite-loading/useInfiniteStoriesLoading.ts +0 -81
  223. package/src/intl/index.ts +0 -4
  224. package/src/intl/languages.test.ts +0 -232
  225. package/src/intl/languages.ts +0 -233
  226. package/src/intl/locale.test.ts +0 -94
  227. package/src/intl/locale.ts +0 -140
  228. package/src/intl/localeConfig.js +0 -23
  229. package/src/intl/localeList.js +0 -110
  230. package/src/intl/localeObject.test.ts +0 -81
  231. package/src/intl/localeObject.ts +0 -99
  232. package/src/newsroom-context/context.tsx +0 -115
  233. package/src/newsroom-context/hooks/index.ts +0 -11
  234. package/src/newsroom-context/hooks/useAlgoliaSettings.ts +0 -7
  235. package/src/newsroom-context/hooks/useCategories.ts +0 -7
  236. package/src/newsroom-context/hooks/useCompanyInformation.ts +0 -7
  237. package/src/newsroom-context/hooks/useCurrentCategory.ts +0 -7
  238. package/src/newsroom-context/hooks/useCurrentLocale.ts +0 -7
  239. package/src/newsroom-context/hooks/useCurrentStory.ts +0 -7
  240. package/src/newsroom-context/hooks/useGetLinkLocaleSlug.ts +0 -37
  241. package/src/newsroom-context/hooks/useGetTranslationUrl.ts +0 -96
  242. package/src/newsroom-context/hooks/useLanguages.ts +0 -7
  243. package/src/newsroom-context/hooks/useNewsroom.ts +0 -7
  244. package/src/newsroom-context/hooks/useNewsroomContext.ts +0 -15
  245. package/src/newsroom-context/index.ts +0 -2
  246. package/src/sentry/client.ts +0 -7
  247. package/src/sentry/common.ts +0 -27
  248. package/src/sentry/index.ts +0 -2
  249. package/src/sentry/server.ts +0 -7
  250. package/src/types.ts +0 -51
  251. package/src/utils/boilerplate.ts +0 -27
  252. package/src/utils/constants.ts +0 -3
  253. package/src/utils/getAssetsUrl.test.ts +0 -9
  254. package/src/utils/getAssetsUrl.ts +0 -9
  255. package/src/utils/getDataRequestLink.ts +0 -14
  256. package/src/utils/getLocalizedCategoryData.ts +0 -47
  257. package/src/utils/getNewsroomLogoUrl.ts +0 -22
  258. package/src/utils/getPrivacyPortalUrl.ts +0 -25
  259. package/src/utils/getStoryPublicationDate.tsx +0 -15
  260. package/src/utils/getUploadcareGroupUrl.ts +0 -13
  261. package/src/utils/index.ts +0 -10
  262. package/src/utils/isEmbargoStory.ts +0 -10
@@ -0,0 +1 @@
1
+ export {};
@@ -1,23 +1,27 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchGalleries = void 0;
4
- const data_fetching_1 = require("../../data-fetching");
5
- async function fetchGalleries(req, res) {
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
+ import { getPrezlyApi } from "../../data-fetching/index.js";
2
+ export async function fetchGalleries(req, res) {
3
+ if (req.method !== 'POST') {
4
+ res.status(405);
5
+ return;
6
+ }
7
+ const {
8
+ page,
9
+ pageSize
10
+ } = req.body;
11
+ try {
12
+ const api = getPrezlyApi(req);
13
+ const {
14
+ galleries
15
+ } = await api.getGalleries({
16
+ page,
17
+ pageSize
18
+ });
19
+ res.status(200).json({
20
+ galleries
21
+ });
22
+ } catch (error) {
23
+ res.status(500).send({
24
+ message: error.message
25
+ });
26
+ }
27
+ }
@@ -1 +1 @@
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
+ {"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,25 +1,37 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchStories = void 0;
4
- const data_fetching_1 = require("../../data-fetching");
5
- async function fetchStories(req, res) {
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
+ import { getPrezlyApi } from "../../data-fetching/index.js";
2
+ export async function fetchStories(req, res) {
3
+ if (req.method !== 'POST') {
4
+ res.status(405);
5
+ return;
6
+ }
7
+ const {
8
+ page,
9
+ pageSize,
10
+ category,
11
+ include,
12
+ localeCode
13
+ } = req.body;
14
+ try {
15
+ const api = getPrezlyApi(req);
16
+ const {
17
+ stories
18
+ } = await (category ? api.getStoriesFromCategory(category, {
19
+ page,
20
+ pageSize,
21
+ include,
22
+ localeCode
23
+ }) : api.getStories({
24
+ page,
25
+ pageSize,
26
+ include,
27
+ localeCode
28
+ }));
29
+ res.status(200).json({
30
+ stories
31
+ });
32
+ } catch (error) {
33
+ res.status(500).send({
34
+ message: error.message
35
+ });
36
+ }
37
+ }
@@ -1 +1 @@
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;QA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AC;YACjB,OAAO,EAAG,KAAe,CAAC,OAAO;SACpC,CAAC,CAAC;KACN;AACL,CAAC"}
@@ -1,8 +1,2 @@
1
- "use strict";
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
+ export { fetchGalleries } from "./fetchGalleries.js";
2
+ export { fetchStories } from "./fetchStories.js";
@@ -1 +1 @@
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
+ {"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,19 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNewsroomServerSideProps = void 0;
4
- const data_fetching_1 = require("../data-fetching");
1
+ import { getPrezlyApi } from "../data-fetching/index.js";
5
2
  /**
6
3
  * Use this function in your `getServerSideProps` page methods to retrieve the data necessary for the NewsroomContextProvider and `processRequest` function.
7
4
  * See README for usage examples.
8
5
  */
9
- async function getNewsroomServerSideProps(context, options = {}) {
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
6
+ export async function getNewsroomServerSideProps(context, options = {}) {
7
+ const {
8
+ req: request,
9
+ locale
10
+ } = context;
11
+ const api = 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 {
17
+ api,
18
+ serverSideProps
19
+ };
20
+ }
@@ -1 +1 @@
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
+ {"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,19 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNewsroomStaticProps = void 0;
4
- const data_fetching_1 = require("../data-fetching");
1
+ import { getPrezlyApi } from "../data-fetching/index.js";
5
2
  /**
6
3
  * Use this function in your `getNewsroomStaticProps` page methods to retrieve the data necessary for the NewsroomContextProvider and `processRequest` function.
7
4
  * See README for usage examples.
8
5
  */
9
- async function getNewsroomStaticProps(context, options = {}) {
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
6
+ export async function getNewsroomStaticProps(context, options = {}) {
7
+ const {
8
+ locale
9
+ } = context;
10
+ const api = getPrezlyApi();
11
+ const staticProps = await api.getNewsroomServerSideProps(undefined, locale, options.story);
12
+ if (options.loadHomepageContacts) {
13
+ staticProps.newsroomContextProps.contacts = await api.getNewsroomContacts();
14
+ }
15
+ return {
16
+ api,
17
+ staticProps
18
+ };
19
+ }
@@ -1 +1 @@
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
+ {"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,23 +1,6 @@
1
- "use strict";
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]; } };
7
- }
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
+ export * from "./api-handlers/index.js";
2
+ export * from "./getNewsroomServerSideProps.js";
3
+ export * from "./getNewsroomStaticProps.js";
4
+ export * from "./page-props/index.js";
5
+ export * from "./processRequest.js";
6
+ export * from "./processStaticRequest.js";
@@ -1 +1 @@
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"}
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,4 +1,4 @@
1
- import type { ExtraStoryFields, Story } from '@prezly/sdk';
1
+ import type { Story } from '@prezly/sdk';
2
2
  import type { GetServerSidePropsContext, GetServerSidePropsResult, GetStaticPathsResult, GetStaticPropsContext, GetStaticPropsResult } from 'next';
3
3
  import type { PaginationProps } from '../../infinite-loading/types';
4
4
  import type { PropsFunction } from './lib/types';
@@ -7,7 +7,7 @@ export interface CategoryPageProps<StoryType extends Story = Story> {
7
7
  pagination: PaginationProps;
8
8
  }
9
9
  interface Options {
10
- extraStoryFields?: (keyof ExtraStoryFields)[];
10
+ extraStoryFields?: (keyof Story.ExtraFields)[];
11
11
  pageSize?: number;
12
12
  }
13
13
  export declare function getCategoryPageServerSideProps<CustomProps extends Record<string, any>, StoryType extends Story = Story>(customProps: CustomProps | PropsFunction<CustomProps>, options?: Options): (context: GetServerSidePropsContext) => Promise<GetServerSidePropsResult<CategoryPageProps<StoryType> & CustomProps>>;
@@ -1,104 +1,122 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCategoryPageStaticPaths = exports.getCategoryPageStaticProps = exports.getCategoryPageServerSideProps = void 0;
4
- const data_fetching_1 = require("../../data-fetching");
5
- const intl_1 = require("../../intl");
6
- const utils_1 = require("../../utils");
7
- const getNewsroomServerSideProps_1 = require("../getNewsroomServerSideProps");
8
- const getNewsroomStaticProps_1 = require("../getNewsroomStaticProps");
9
- const processRequest_1 = require("../processRequest");
10
- const processStaticRequest_1 = require("../processStaticRequest");
11
- function getCategoryPageServerSideProps(customProps, options) {
12
- const { pageSize = utils_1.DEFAULT_PAGE_SIZE, extraStoryFields } = options || {};
13
- return async function getServerSideProps(context) {
14
- const { api, serverSideProps } = await (0, getNewsroomServerSideProps_1.getNewsroomServerSideProps)(context);
15
- const { slug } = context.params;
16
- const category = await api.getCategoryBySlug(slug);
17
- if (!category) {
18
- return {
19
- notFound: true,
20
- };
21
- }
22
- const { query } = context;
23
- const page = query.page && typeof query.page === 'string' ? Number(query.page) : undefined;
24
- const { localeCode } = serverSideProps.newsroomContextProps;
25
- const { stories, storiesTotal } = await api.getStoriesFromCategory(category, {
26
- page,
27
- pageSize,
28
- include: extraStoryFields,
29
- localeCode,
30
- });
31
- serverSideProps.newsroomContextProps.currentCategory = category;
32
- return (0, processRequest_1.processRequest)(context, {
33
- ...serverSideProps,
34
- // TODO: This is temporary until return types from API are figured out
35
- stories: stories,
36
- pagination: {
37
- itemsTotal: storiesTotal,
38
- currentPage: page ?? 1,
39
- pageSize,
40
- },
41
- ...(typeof customProps === 'function'
42
- ? await customProps(context, serverSideProps)
43
- : customProps),
44
- }, `/category/${slug}`);
45
- };
1
+ import { getPrezlyApi } from "../../data-fetching/index.js";
2
+ import { LocaleObject } from "../../intl/index.js";
3
+ import { DEFAULT_PAGE_SIZE, getLocalizedCategoryData } from "../../utils/index.js";
4
+ import { getNewsroomServerSideProps } from "../getNewsroomServerSideProps.js";
5
+ import { getNewsroomStaticProps } from "../getNewsroomStaticProps.js";
6
+ import { processRequest } from "../processRequest.js";
7
+ import { processStaticRequest } from "../processStaticRequest.js";
8
+ export function getCategoryPageServerSideProps(customProps, options) {
9
+ const {
10
+ pageSize = DEFAULT_PAGE_SIZE,
11
+ extraStoryFields
12
+ } = options || {};
13
+ return async function getServerSideProps(context) {
14
+ const {
15
+ api,
16
+ serverSideProps
17
+ } = await getNewsroomServerSideProps(context);
18
+ const {
19
+ slug
20
+ } = context.params;
21
+ const category = await api.getCategoryBySlug(slug);
22
+ if (!category) {
23
+ return {
24
+ notFound: true
25
+ };
26
+ }
27
+ const {
28
+ query
29
+ } = context;
30
+ const page = query.page && typeof query.page === 'string' ? Number(query.page) : undefined;
31
+ const {
32
+ localeCode
33
+ } = serverSideProps.newsroomContextProps;
34
+ const {
35
+ stories,
36
+ storiesTotal
37
+ } = await api.getStoriesFromCategory(category, {
38
+ page,
39
+ pageSize,
40
+ include: extraStoryFields,
41
+ localeCode
42
+ });
43
+ serverSideProps.newsroomContextProps.currentCategory = category;
44
+ return processRequest(context, {
45
+ ...serverSideProps,
46
+ // TODO: This is temporary until return types from API are figured out
47
+ stories: stories,
48
+ pagination: {
49
+ itemsTotal: storiesTotal,
50
+ currentPage: page ?? 1,
51
+ pageSize
52
+ },
53
+ ...(typeof customProps === 'function' ? await customProps(context, serverSideProps) : customProps)
54
+ }, `/category/${slug}`);
55
+ };
46
56
  }
47
- exports.getCategoryPageServerSideProps = getCategoryPageServerSideProps;
48
- function getCategoryPageStaticProps(customProps, options) {
49
- const { pageSize = utils_1.DEFAULT_PAGE_SIZE, extraStoryFields } = options || {};
50
- return async function getStaticProps(context) {
51
- const { api, staticProps } = await (0, getNewsroomStaticProps_1.getNewsroomStaticProps)(context);
52
- const { slug } = context.params;
53
- const category = await api.getCategoryBySlug(slug);
54
- if (!category) {
55
- return {
56
- notFound: true,
57
- };
58
- }
59
- const { localeCode } = staticProps.newsroomContextProps;
60
- const { stories, storiesTotal } = await api.getStoriesFromCategory(category, {
61
- pageSize,
62
- include: extraStoryFields,
63
- localeCode,
64
- });
65
- staticProps.newsroomContextProps.currentCategory = category;
66
- return (0, processStaticRequest_1.processStaticRequest)(context, {
67
- ...staticProps,
68
- // TODO: This is temporary until return types from API are figured out
69
- stories: stories,
70
- pagination: {
71
- itemsTotal: storiesTotal,
72
- currentPage: 1,
73
- pageSize,
74
- },
75
- ...(typeof customProps === 'function'
76
- ? await customProps(context, staticProps)
77
- : customProps),
78
- });
79
- };
57
+ export function getCategoryPageStaticProps(customProps, options) {
58
+ const {
59
+ pageSize = DEFAULT_PAGE_SIZE,
60
+ extraStoryFields
61
+ } = options || {};
62
+ return async function getStaticProps(context) {
63
+ const {
64
+ api,
65
+ staticProps
66
+ } = await getNewsroomStaticProps(context);
67
+ const {
68
+ slug
69
+ } = context.params;
70
+ const category = await api.getCategoryBySlug(slug);
71
+ if (!category) {
72
+ return {
73
+ notFound: true
74
+ };
75
+ }
76
+ const {
77
+ localeCode
78
+ } = staticProps.newsroomContextProps;
79
+ const {
80
+ stories,
81
+ storiesTotal
82
+ } = await api.getStoriesFromCategory(category, {
83
+ pageSize,
84
+ include: extraStoryFields,
85
+ localeCode
86
+ });
87
+ staticProps.newsroomContextProps.currentCategory = category;
88
+ return processStaticRequest(context, {
89
+ ...staticProps,
90
+ // TODO: This is temporary until return types from API are figured out
91
+ stories: stories,
92
+ pagination: {
93
+ itemsTotal: storiesTotal,
94
+ currentPage: 1,
95
+ pageSize
96
+ },
97
+ ...(typeof customProps === 'function' ? await customProps(context, staticProps) : customProps)
98
+ });
99
+ };
80
100
  }
81
- exports.getCategoryPageStaticProps = getCategoryPageStaticProps;
82
- async function getCategoryPageStaticPaths() {
83
- const api = (0, data_fetching_1.getPrezlyApi)();
84
- const [categories, defaultLanguage] = await Promise.all([
85
- api.getCategories(),
86
- api.getNewsroomDefaultLanguage(),
87
- ]);
88
- const locale = intl_1.LocaleObject.fromAnyCode(defaultLanguage.code);
89
- const paths = categories
90
- .map((category) => {
91
- const { slug } = (0, utils_1.getLocalizedCategoryData)(category, locale);
92
- if (!slug) {
93
- return undefined;
94
- }
95
- return { params: { slug } };
96
- })
97
- .filter(Boolean);
101
+ export async function getCategoryPageStaticPaths() {
102
+ const api = getPrezlyApi();
103
+ const [categories, defaultLanguage] = await Promise.all([api.getCategories(), api.getNewsroomDefaultLanguage()]);
104
+ const locale = LocaleObject.fromAnyCode(defaultLanguage.code);
105
+ const paths = categories.map(category => {
106
+ const {
107
+ slug
108
+ } = getLocalizedCategoryData(category, locale);
109
+ if (!slug) {
110
+ return undefined;
111
+ }
98
112
  return {
99
- paths,
100
- fallback: 'blocking',
113
+ params: {
114
+ slug
115
+ }
101
116
  };
102
- }
103
- exports.getCategoryPageStaticPaths = getCategoryPageStaticPaths;
104
- //# sourceMappingURL=category.js.map
117
+ }).filter(Boolean);
118
+ return {
119
+ paths,
120
+ fallback: 'blocking'
121
+ };
122
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"category.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/category.ts"],"names":[],"mappings":";;;AASA,uDAAmD;AAEnD,qCAA0C;AAC1C,uCAA0E;AAC1E,8EAA2E;AAC3E,sEAAmE;AACnE,sDAAmD;AACnD,kEAA+D;AAc/D,SAAgB,8BAA8B,CAG5C,WAAqD,EAAE,OAAiB;IACtE,MAAM,EAAE,QAAQ,GAAG,yBAAiB,EAAE,gBAAgB,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAEzE,OAAO,KAAK,UAAU,kBAAkB,CACpC,OAAkC;QAElC,MAAM,EAAE,GAAG,EAAE,eAAe,EAAE,GAAG,MAAM,IAAA,uDAA0B,EAAC,OAAO,CAAC,CAAC;QAE3E,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAA0B,CAAC;QACpD,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAEnD,IAAI,CAAC,QAAQ,EAAE;YACX,OAAO;gBACH,QAAQ,EAAE,IAAI;aACjB,CAAC;SACL;QAED,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QAC1B,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE3F,MAAM,EAAE,UAAU,EAAE,GAAG,eAAe,CAAC,oBAAoB,CAAC;QAE5D,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,GAAG,CAAC,sBAAsB,CAAC,QAAQ,EAAE;YACzE,IAAI;YACJ,QAAQ;YACR,OAAO,EAAE,gBAAgB;YACzB,UAAU;SACb,CAAC,CAAC;QAEH,eAAe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G,QAAQ,CAAC;QAE5D,OAAO,IAAA,2CAAoB,EAAC,OAAO,EAAE;YACjC,GAAG,WAAW;YACd,sEAAsE;YACtE,OAAO,EAAE,OAAsB;YAC/B,UAAU,EAAE;gBACR,UAAU,EAAE,YAAY;gBACxB,WAAW,EAAE,CAAC;gBACd,QAAQ;aACX;YACD,GAAG,CAAC,OAAO,WAAW,KAAK,UAAU;gBACjC,CAAC,CAAC,MAAO,WAAiE,CACpE,OAAO,EACP,WAAW,CACd;gBACH,CAAC,CAAC,WAAW,CAAC;SACrB,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC;AA/CD,gEA+CC;AAEM,KAAK,UAAU,0BAA0B;IAC5C,MAAM,GAAG,GAAG,IAAA,4BAAY,GAAE,CAAC;IAC3B,MAAM,CAAC,UAAU,EAAE,eAAe,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACpD,GAAG,CAAC,aAAa,EAAE;QACnB,GAAG,CAAC,0BAA0B,EAAE;KACnC,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,mBAAY,CAAC,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAE9D,MAAM,KAAK,GAAG,UAAU;SACnB,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;QACd,MAAM,EAAE,IAAI,EAAE,GAAG,IAAA,gCAAwB,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,EAAE;YACP,OAAO,SAAS,CAAC;SACpB;QAED,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC;IAChC,CAAC,CAAC;SACD,MAAM,CAA+B,OAAc,CAAC,CAAC;IAE1D,OAAO;QACH,KAAK;QACL,QAAQ,EAAE,UAAU;KACvB,CAAC;AACN,CAAC;AAvBD,gEAuBC"}
1
+ {"version":3,"file":"category.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/category.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,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