@prezly/theme-kit-nextjs 1.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 (164) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +28 -0
  3. package/build/adapter-nextjs/getBasePageProps.d.ts +9 -0
  4. package/build/adapter-nextjs/getBasePageProps.js +11 -0
  5. package/build/adapter-nextjs/getBasePageProps.js.map +1 -0
  6. package/build/adapter-nextjs/index.d.ts +2 -0
  7. package/build/adapter-nextjs/index.js +3 -0
  8. package/build/adapter-nextjs/index.js.map +1 -0
  9. package/build/adapter-nextjs/processRequest.d.ts +3 -0
  10. package/build/adapter-nextjs/processRequest.js +20 -0
  11. package/build/adapter-nextjs/processRequest.js.map +1 -0
  12. package/build/data-fetching/api/PrezlyApi.d.ts +43 -0
  13. package/build/data-fetching/api/PrezlyApi.js +139 -0
  14. package/build/data-fetching/api/PrezlyApi.js.map +1 -0
  15. package/build/data-fetching/api/getPrezlyApi.d.ts +4 -0
  16. package/build/data-fetching/api/getPrezlyApi.js +17 -0
  17. package/build/data-fetching/api/getPrezlyApi.js.map +1 -0
  18. package/build/data-fetching/api/index.d.ts +2 -0
  19. package/build/data-fetching/api/index.js +3 -0
  20. package/build/data-fetching/api/index.js.map +1 -0
  21. package/build/data-fetching/api/languages.d.ts +18 -0
  22. package/build/data-fetching/api/languages.js +117 -0
  23. package/build/data-fetching/api/languages.js.map +1 -0
  24. package/build/data-fetching/api/queries.d.ts +45 -0
  25. package/build/data-fetching/api/queries.js +35 -0
  26. package/build/data-fetching/api/queries.js.map +1 -0
  27. package/build/data-fetching/constants.d.ts +2 -0
  28. package/build/data-fetching/constants.js +3 -0
  29. package/build/data-fetching/constants.js.map +1 -0
  30. package/build/data-fetching/getAssetsUrl.d.ts +1 -0
  31. package/build/data-fetching/getAssetsUrl.js +5 -0
  32. package/build/data-fetching/getAssetsUrl.js.map +1 -0
  33. package/build/data-fetching/getLocalizedCategoryData.d.ts +10 -0
  34. package/build/data-fetching/getLocalizedCategoryData.js +31 -0
  35. package/build/data-fetching/getLocalizedCategoryData.js.map +1 -0
  36. package/build/data-fetching/getNewsroomLogoUrl.d.ts +3 -0
  37. package/build/data-fetching/getNewsroomLogoUrl.js +14 -0
  38. package/build/data-fetching/getNewsroomLogoUrl.js.map +1 -0
  39. package/build/data-fetching/getPrivacyPortalUrl.d.ts +8 -0
  40. package/build/data-fetching/getPrivacyPortalUrl.js +9 -0
  41. package/build/data-fetching/getPrivacyPortalUrl.js.map +1 -0
  42. package/build/data-fetching/getStoryPublicationDate.d.ts +3 -0
  43. package/build/data-fetching/getStoryPublicationDate.jsx +10 -0
  44. package/build/data-fetching/getStoryPublicationDate.jsx.map +1 -0
  45. package/build/data-fetching/getUploadcareGroupUrl.d.ts +1 -0
  46. package/build/data-fetching/getUploadcareGroupUrl.js +5 -0
  47. package/build/data-fetching/getUploadcareGroupUrl.js.map +1 -0
  48. package/build/data-fetching/index.d.ts +9 -0
  49. package/build/data-fetching/index.js +10 -0
  50. package/build/data-fetching/index.js.map +1 -0
  51. package/build/data-fetching/lib/getAlgoliaSettings.d.ts +4 -0
  52. package/build/data-fetching/lib/getAlgoliaSettings.js +18 -0
  53. package/build/data-fetching/lib/getAlgoliaSettings.js.map +1 -0
  54. package/build/data-fetching/lib/getEnvVariables.d.ts +4 -0
  55. package/build/data-fetching/lib/getEnvVariables.js +37 -0
  56. package/build/data-fetching/lib/getEnvVariables.js.map +1 -0
  57. package/build/data-fetching/types.d.ts +11 -0
  58. package/build/data-fetching/types.js +2 -0
  59. package/build/data-fetching/types.js.map +1 -0
  60. package/build/index.d.ts +5 -0
  61. package/build/index.js +6 -0
  62. package/build/index.js.map +1 -0
  63. package/build/intl/index.d.ts +4 -0
  64. package/build/intl/index.js +5 -0
  65. package/build/intl/index.js.map +1 -0
  66. package/build/intl/lang.d.ts +12 -0
  67. package/build/intl/lang.js +25 -0
  68. package/build/intl/lang.js.map +1 -0
  69. package/build/intl/locale.d.ts +10 -0
  70. package/build/intl/locale.js +93 -0
  71. package/build/intl/locale.js.map +1 -0
  72. package/build/intl/localeConfig.d.ts +2 -0
  73. package/build/intl/localeConfig.js +113 -0
  74. package/build/intl/localeConfig.js.map +1 -0
  75. package/build/intl/localeObject.d.ts +22 -0
  76. package/build/intl/localeObject.js +59 -0
  77. package/build/intl/localeObject.js.map +1 -0
  78. package/build/newsroom-context/context.d.ts +26 -0
  79. package/build/newsroom-context/context.jsx +22 -0
  80. package/build/newsroom-context/context.jsx.map +1 -0
  81. package/build/newsroom-context/hooks/index.d.ts +11 -0
  82. package/build/newsroom-context/hooks/index.js +12 -0
  83. package/build/newsroom-context/hooks/index.js.map +1 -0
  84. package/build/newsroom-context/hooks/useAlgoliaSettings.d.ts +1 -0
  85. package/build/newsroom-context/hooks/useAlgoliaSettings.js +6 -0
  86. package/build/newsroom-context/hooks/useAlgoliaSettings.js.map +1 -0
  87. package/build/newsroom-context/hooks/useCategories.d.ts +1 -0
  88. package/build/newsroom-context/hooks/useCategories.js +6 -0
  89. package/build/newsroom-context/hooks/useCategories.js.map +1 -0
  90. package/build/newsroom-context/hooks/useCompanyInformation.d.ts +1 -0
  91. package/build/newsroom-context/hooks/useCompanyInformation.js +6 -0
  92. package/build/newsroom-context/hooks/useCompanyInformation.js.map +1 -0
  93. package/build/newsroom-context/hooks/useCurrentLocale.d.ts +1 -0
  94. package/build/newsroom-context/hooks/useCurrentLocale.js +6 -0
  95. package/build/newsroom-context/hooks/useCurrentLocale.js.map +1 -0
  96. package/build/newsroom-context/hooks/useGetLinkLocaleSlug.d.ts +2 -0
  97. package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js +21 -0
  98. package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js.map +1 -0
  99. package/build/newsroom-context/hooks/useGetTranslationUrl.d.ts +2 -0
  100. package/build/newsroom-context/hooks/useGetTranslationUrl.js +36 -0
  101. package/build/newsroom-context/hooks/useGetTranslationUrl.js.map +1 -0
  102. package/build/newsroom-context/hooks/useLanguages.d.ts +1 -0
  103. package/build/newsroom-context/hooks/useLanguages.js +6 -0
  104. package/build/newsroom-context/hooks/useLanguages.js.map +1 -0
  105. package/build/newsroom-context/hooks/useNewsroom.d.ts +1 -0
  106. package/build/newsroom-context/hooks/useNewsroom.js +6 -0
  107. package/build/newsroom-context/hooks/useNewsroom.js.map +1 -0
  108. package/build/newsroom-context/hooks/useNewsroomContext.d.ts +2 -0
  109. package/build/newsroom-context/hooks/useNewsroomContext.js +12 -0
  110. package/build/newsroom-context/hooks/useNewsroomContext.js.map +1 -0
  111. package/build/newsroom-context/hooks/useSelectedCategory.d.ts +1 -0
  112. package/build/newsroom-context/hooks/useSelectedCategory.js +6 -0
  113. package/build/newsroom-context/hooks/useSelectedCategory.js.map +1 -0
  114. package/build/newsroom-context/hooks/useSelectedStory.d.ts +1 -0
  115. package/build/newsroom-context/hooks/useSelectedStory.js +6 -0
  116. package/build/newsroom-context/hooks/useSelectedStory.js.map +1 -0
  117. package/build/newsroom-context/index.d.ts +2 -0
  118. package/build/newsroom-context/index.js +3 -0
  119. package/build/newsroom-context/index.js.map +1 -0
  120. package/build/types.d.ts +38 -0
  121. package/build/types.js +2 -0
  122. package/build/types.js.map +1 -0
  123. package/package.json +60 -0
  124. package/src/@types/global.d.ts +7 -0
  125. package/src/adapter-nextjs/getBasePageProps.ts +23 -0
  126. package/src/adapter-nextjs/index.ts +2 -0
  127. package/src/adapter-nextjs/processRequest.ts +31 -0
  128. package/src/data-fetching/api/PrezlyApi.ts +240 -0
  129. package/src/data-fetching/api/getPrezlyApi.ts +24 -0
  130. package/src/data-fetching/api/index.ts +2 -0
  131. package/src/data-fetching/api/languages.ts +172 -0
  132. package/src/data-fetching/api/queries.ts +44 -0
  133. package/src/data-fetching/constants.ts +2 -0
  134. package/src/data-fetching/getAssetsUrl.ts +5 -0
  135. package/src/data-fetching/getLocalizedCategoryData.ts +47 -0
  136. package/src/data-fetching/getNewsroomLogoUrl.ts +21 -0
  137. package/src/data-fetching/getPrivacyPortalUrl.ts +22 -0
  138. package/src/data-fetching/getStoryPublicationDate.tsx +15 -0
  139. package/src/data-fetching/getUploadcareGroupUrl.ts +5 -0
  140. package/src/data-fetching/index.ts +9 -0
  141. package/src/data-fetching/lib/getAlgoliaSettings.ts +29 -0
  142. package/src/data-fetching/lib/getEnvVariables.ts +44 -0
  143. package/src/data-fetching/types.ts +12 -0
  144. package/src/index.ts +5 -0
  145. package/src/intl/index.ts +4 -0
  146. package/src/intl/lang.ts +36 -0
  147. package/src/intl/locale.ts +118 -0
  148. package/src/intl/localeConfig.js +116 -0
  149. package/src/intl/localeObject.ts +73 -0
  150. package/src/newsroom-context/context.tsx +73 -0
  151. package/src/newsroom-context/hooks/index.ts +11 -0
  152. package/src/newsroom-context/hooks/useAlgoliaSettings.ts +7 -0
  153. package/src/newsroom-context/hooks/useCategories.ts +7 -0
  154. package/src/newsroom-context/hooks/useCompanyInformation.ts +7 -0
  155. package/src/newsroom-context/hooks/useCurrentLocale.ts +7 -0
  156. package/src/newsroom-context/hooks/useGetLinkLocaleSlug.ts +33 -0
  157. package/src/newsroom-context/hooks/useGetTranslationUrl.ts +61 -0
  158. package/src/newsroom-context/hooks/useLanguages.ts +7 -0
  159. package/src/newsroom-context/hooks/useNewsroom.ts +7 -0
  160. package/src/newsroom-context/hooks/useNewsroomContext.ts +14 -0
  161. package/src/newsroom-context/hooks/useSelectedCategory.ts +7 -0
  162. package/src/newsroom-context/hooks/useSelectedStory.ts +7 -0
  163. package/src/newsroom-context/index.ts +2 -0
  164. package/src/types.ts +56 -0
package/src/types.ts ADDED
@@ -0,0 +1,56 @@
1
+ // TODO: Re-arrange the types to make them isolated to respective libs where possible
2
+ import type { AlgoliaSettings } from './data-fetching';
3
+ import type {
4
+ Category,
5
+ CultureRef,
6
+ ExtraStoryFields,
7
+ Newsroom,
8
+ NewsroomCompanyInformation,
9
+ NewsroomContact,
10
+ NewsroomLanguageSettings,
11
+ NewsroomThemePreset,
12
+ Story,
13
+ } from '@prezly/sdk';
14
+
15
+ export interface BasePageProps {
16
+ newsroom: Newsroom;
17
+ companyInformation: NewsroomCompanyInformation;
18
+ categories: Category[];
19
+ languages: NewsroomLanguageSettings[];
20
+ localeCode: string;
21
+ /**
22
+ * `false` means it's the default locale
23
+ */
24
+ shortestLocaleCode: string | false;
25
+ localeResolved: boolean;
26
+ themePreset: NewsroomThemePreset;
27
+ algoliaSettings: AlgoliaSettings;
28
+ translations?: Translations;
29
+ contacts?: NewsroomContact[];
30
+ isTrackingEnabled?: boolean;
31
+ }
32
+
33
+ export interface PaginationProps {
34
+ itemsTotal: number;
35
+ currentPage: number;
36
+ pageSize: number;
37
+ }
38
+
39
+ export type StoryWithImage = Story & Pick<ExtraStoryFields, 'thumbnail_image'>;
40
+
41
+ export interface AlgoliaCategoryRef {
42
+ id: number;
43
+ name: string;
44
+ slug: string;
45
+ }
46
+
47
+ export type AlgoliaStory = Pick<Story, 'uuid' | 'slug' | 'title' | 'subtitle'> &
48
+ Pick<ExtraStoryFields, 'thumbnail_image'> & {
49
+ content_text: string;
50
+ updated_at: number;
51
+ published_at: number;
52
+ culture: Pick<CultureRef, 'code' | 'name' | 'native_name' | 'language_code'>;
53
+ categories: AlgoliaCategoryRef[];
54
+ };
55
+
56
+ export type Translations = Record<string, string>;