@prezly/theme-kit-nextjs 1.1.5-0 → 1.3.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 (35) hide show
  1. package/README.md +2 -2
  2. package/build/adapter-nextjs/processRequest.js +3 -11
  3. package/build/adapter-nextjs/processRequest.js.map +1 -1
  4. package/build/data-fetching/getNewsroomLogoUrl.js +1 -1
  5. package/build/data-fetching/getNewsroomLogoUrl.js.map +1 -1
  6. package/build/data-fetching/getPrivacyPortalUrl.d.ts +1 -1
  7. package/build/data-fetching/getPrivacyPortalUrl.js.map +1 -1
  8. package/build/newsroom-context/context.d.ts +2 -2
  9. package/build/newsroom-context/context.js +3 -3
  10. package/build/newsroom-context/context.js.map +1 -1
  11. package/build/newsroom-context/hooks/index.d.ts +2 -2
  12. package/build/newsroom-context/hooks/index.js +2 -2
  13. package/build/newsroom-context/hooks/index.js.map +1 -1
  14. package/build/newsroom-context/hooks/useCurrentCategory.d.ts +1 -0
  15. package/build/newsroom-context/hooks/useCurrentCategory.js +10 -0
  16. package/build/newsroom-context/hooks/useCurrentCategory.js.map +1 -0
  17. package/build/newsroom-context/hooks/useCurrentStory.d.ts +1 -0
  18. package/build/newsroom-context/hooks/{useSelectedStory.js → useCurrentStory.js} +5 -5
  19. package/build/newsroom-context/hooks/useCurrentStory.js.map +1 -0
  20. package/build/newsroom-context/hooks/useGetTranslationUrl.js +12 -12
  21. package/build/newsroom-context/hooks/useGetTranslationUrl.js.map +1 -1
  22. package/package.json +1 -1
  23. package/src/adapter-nextjs/processRequest.ts +3 -16
  24. package/src/data-fetching/getNewsroomLogoUrl.ts +1 -1
  25. package/src/data-fetching/getPrivacyPortalUrl.ts +4 -1
  26. package/src/newsroom-context/context.tsx +6 -6
  27. package/src/newsroom-context/hooks/index.ts +2 -2
  28. package/src/newsroom-context/hooks/{useSelectedCategory.ts → useCurrentCategory.ts} +2 -2
  29. package/src/newsroom-context/hooks/{useSelectedStory.ts → useCurrentStory.ts} +2 -2
  30. package/src/newsroom-context/hooks/useGetTranslationUrl.ts +13 -13
  31. package/build/newsroom-context/hooks/useSelectedCategory.d.ts +0 -1
  32. package/build/newsroom-context/hooks/useSelectedCategory.js +0 -10
  33. package/build/newsroom-context/hooks/useSelectedCategory.js.map +0 -1
  34. package/build/newsroom-context/hooks/useSelectedStory.d.ts +0 -1
  35. package/build/newsroom-context/hooks/useSelectedStory.js.map +0 -1
package/README.md CHANGED
@@ -98,13 +98,13 @@ type AnyPageProps = Record<string, any>;
98
98
  function App({ Component, pageProps }: AppProps<AnyPageProps>) {
99
99
  const { newsroomContextProps, ...customPageProps } = pageProps as PageProps & AnyPageProps;
100
100
 
101
- // eslint-disable react/jsx-props-no-spreading
101
+ /* eslint-disable react/jsx-props-no-spreading */
102
102
  return (
103
103
  <NewsroomContextProvider {...newsroomContextProps}>
104
104
  <Component {...customPageProps} />
105
105
  </NewsroomContextProvider>
106
106
  );
107
- // eslint-enable react/jsx-props-no-spreading
107
+ /* eslint-enable react/jsx-props-no-spreading */
108
108
  }
109
109
 
110
110
  export default App;
@@ -14,22 +14,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.processRequest = void 0;
15
15
  var data_fetching_1 = require("../data-fetching");
16
16
  var intl_1 = require("../intl");
17
- // TODO: Try to make the typings even more robust
18
- function extractServerSideProps(props) {
19
- var localeResolved = props.localeResolved, pageProps = __rest(props, ["localeResolved"]);
20
- return {
21
- pageProps: pageProps,
22
- serverSideProps: { localeResolved: localeResolved },
23
- };
24
- }
25
17
  function processRequest(context, props, canonicalUrl) {
26
18
  var nextLocale = context.locale, query = context.query;
27
- var _a = extractServerSideProps(props), pageProps = _a.pageProps, serverSideProps = _a.serverSideProps;
28
- if (!serverSideProps.localeResolved) {
19
+ var localeResolved = props.localeResolved, pageProps = __rest(props, ["localeResolved"]);
20
+ if (!localeResolved) {
29
21
  return { notFound: true };
30
22
  }
31
23
  if (canonicalUrl) {
32
- var _b = pageProps.newsroomContextProps, languages = _b.languages, localeCode = _b.localeCode;
24
+ var _a = pageProps.newsroomContextProps, languages = _a.languages, localeCode = _a.localeCode;
33
25
  var currentLocale = intl_1.LocaleObject.fromAnyCode(localeCode);
34
26
  var shortestLocaleCode = (0, data_fetching_1.getShortestLocaleCode)(languages, currentLocale);
35
27
  var redirect = (0, intl_1.getRedirectToCanonicalLocale)(shortestLocaleCode, nextLocale, canonicalUrl, query);
@@ -1 +1 @@
1
- {"version":3,"file":"processRequest.js","sourceRoot":"","sources":["../../src/adapter-nextjs/processRequest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,kDAAyD;AACzD,gCAAqE;AAGrE,iDAAiD;AACjD,SAAS,sBAAsB,CAAQ,KAAkC;IAI7D,IAAA,cAAc,GAAmB,KAAK,eAAxB,EAAK,SAAS,UAAK,KAAK,EAAxC,kBAAgC,CAAF,CAAW;IAE/C,OAAO;QACH,SAAS,EAAE,SAA6B;QACxC,eAAe,EAAE,EAAE,cAAc,gBAAA,EAAE;KACtC,CAAC;AACN,CAAC;AAED,SAAgB,cAAc,CAC1B,OAAkC,EAClC,KAA8C,EAC9C,YAAqB;IAEb,IAAQ,UAAU,GAAY,OAAO,OAAnB,EAAE,KAAK,GAAK,OAAO,MAAZ,CAAa;IAExC,IAAA,KAAiC,sBAAsB,CAAC,KAAK,CAAC,EAA5D,SAAS,eAAA,EAAE,eAAe,qBAAkC,CAAC;IAErE,IAAI,CAAC,eAAe,CAAC,cAAc,EAAE;QACjC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;KAC7B;IAED,IAAI,YAAY,EAAE;QACR,IAAA,KAA4B,SAAS,CAAC,oBAAoB,EAAxD,SAAS,eAAA,EAAE,UAAU,gBAAmC,CAAC;QACjE,IAAM,aAAa,GAAG,mBAAY,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QAC3D,IAAM,kBAAkB,GAAG,IAAA,qCAAqB,EAAC,SAAS,EAAE,aAAa,CAAC,CAAC;QAE3E,IAAM,QAAQ,GAAG,IAAA,mCAA4B,EACzC,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,KAAK,CACR,CAAC;QACF,IAAI,QAAQ,EAAE;YACV,OAAO,EAAE,QAAQ,UAAA,EAAE,CAAC;SACvB;KACJ;IAED,OAAO;QACH,KAAK,EAAE,SAAS;KACnB,CAAC;AACN,CAAC;AAhCD,wCAgCC"}
1
+ {"version":3,"file":"processRequest.js","sourceRoot":"","sources":["../../src/adapter-nextjs/processRequest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,kDAAyD;AACzD,gCAAqE;AAGrE,SAAgB,cAAc,CAC1B,OAAkC,EAClC,KAA8C,EAC9C,YAAqB;IAEb,IAAQ,UAAU,GAAY,OAAO,OAAnB,EAAE,KAAK,GAAK,OAAO,MAAZ,CAAa;IAEtC,IAAA,cAAc,GAAmB,KAAK,eAAxB,EAAK,SAAS,UAAK,KAAK,EAAxC,kBAAgC,CAAF,CAAW;IAE/C,IAAI,CAAC,cAAc,EAAE;QACjB,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;KAC7B;IAED,IAAI,YAAY,EAAE;QACR,IAAA,KAA4B,SAAS,CAAC,oBAAoB,EAAxD,SAAS,eAAA,EAAE,UAAU,gBAAmC,CAAC;QACjE,IAAM,aAAa,GAAG,mBAAY,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QAC3D,IAAM,kBAAkB,GAAG,IAAA,qCAAqB,EAAC,SAAS,EAAE,aAAa,CAAC,CAAC;QAE3E,IAAM,QAAQ,GAAG,IAAA,mCAA4B,EACzC,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,KAAK,CACR,CAAC;QACF,IAAI,QAAQ,EAAE;YACV,OAAO,EAAE,QAAQ,UAAA,EAAE,CAAC;SACvB;KACJ;IAED,OAAO;QACH,KAAK,EAAE,SAA8B;KACxC,CAAC;AACN,CAAC;AAhCD,wCAgCC"}
@@ -4,7 +4,7 @@ exports.getNewsroomFaviconUrl = exports.getNewsroomLogoUrl = void 0;
4
4
  var getAssetsUrl_1 = require("./getAssetsUrl");
5
5
  function getNewsroomLogoUrl(newsroom) {
6
6
  if (newsroom.newsroom_logo) {
7
- (0, getAssetsUrl_1.getAssetsUrl)(newsroom.newsroom_logo.uuid);
7
+ return (0, getAssetsUrl_1.getAssetsUrl)(newsroom.newsroom_logo.uuid);
8
8
  }
9
9
  return '';
10
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getNewsroomLogoUrl.js","sourceRoot":"","sources":["../../src/data-fetching/getNewsroomLogoUrl.ts"],"names":[],"mappings":";;;AAEA,+CAA8C;AAE9C,SAAgB,kBAAkB,CAAC,QAAkB;IACjD,IAAI,QAAQ,CAAC,aAAa,EAAE;QACxB,IAAA,2BAAY,EAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;KAC7C;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AAND,gDAMC;AAED,SAAgB,qBAAqB,CAAC,QAAkB,EAAE,WAAiB;IAAjB,4BAAA,EAAA,iBAAiB;IACvE,IAAI,QAAQ,CAAC,IAAI,EAAE;QACf,OAAO,UAAG,IAAA,2BAAY,EAClB,QAAQ,CAAC,IAAI,CAAC,IAAI,CACrB,uBAAa,WAAW,cAAI,WAAW,qBAAkB,CAAC;KAC9D;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AARD,sDAQC"}
1
+ {"version":3,"file":"getNewsroomLogoUrl.js","sourceRoot":"","sources":["../../src/data-fetching/getNewsroomLogoUrl.ts"],"names":[],"mappings":";;;AAEA,+CAA8C;AAE9C,SAAgB,kBAAkB,CAAC,QAAkB;IACjD,IAAI,QAAQ,CAAC,aAAa,EAAE;QACxB,OAAO,IAAA,2BAAY,EAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;KACpD;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AAND,gDAMC;AAED,SAAgB,qBAAqB,CAAC,QAAkB,EAAE,WAAiB;IAAjB,4BAAA,EAAA,iBAAiB;IACvE,IAAI,QAAQ,CAAC,IAAI,EAAE;QACf,OAAO,UAAG,IAAA,2BAAY,EAClB,QAAQ,CAAC,IAAI,CAAC,IAAI,CACrB,uBAAa,WAAW,cAAI,WAAW,qBAAkB,CAAC;KAC9D;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AARD,sDAQC"}
@@ -2,7 +2,7 @@ import type { Newsroom } from '@prezly/sdk';
2
2
  import { LocaleObject } from '../intl';
3
3
  declare type PrivacyPortalUrlOptions = {
4
4
  email?: string;
5
- action?: 'subscribe' | 'unsubscribe';
5
+ action?: 'data-request' | 'subscribe' | 'unsubscribe';
6
6
  };
7
7
  export declare function getPrivacyPortalUrl(newsroom: Newsroom, locale: LocaleObject, options?: PrivacyPortalUrlOptions): string;
8
8
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"getPrivacyPortalUrl.js","sourceRoot":"","sources":["../../src/data-fetching/getPrivacyPortalUrl.ts"],"names":[],"mappings":";;;AAMA,SAAgB,mBAAmB,CAC/B,QAAkB,EAClB,MAAoB,EACpB,OAAiC;IAE3B,IAAA,KAAkC,OAAO,IAAI,EAAE,EAA7C,KAAK,WAAA,EAAE,cAAoB,EAApB,MAAM,mBAAG,WAAW,KAAkB,CAAC;IAEtD,IAAM,GAAG,GAAG,IAAI,GAAG,CACf,WAAI,MAAM,CAAC,SAAS,EAAE,uBAAa,QAAQ,CAAC,IAAI,cAAI,MAAM,CAAE,EAC5D,4BAA4B,CAC/B,CAAC;IACF,IAAI,KAAK,EAAE;QACP,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KAC3C;IACD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AAC1B,CAAC;AAfD,kDAeC"}
1
+ {"version":3,"file":"getPrivacyPortalUrl.js","sourceRoot":"","sources":["../../src/data-fetching/getPrivacyPortalUrl.ts"],"names":[],"mappings":";;;AASA,SAAgB,mBAAmB,CAC/B,QAAkB,EAClB,MAAoB,EACpB,OAAiC;IAE3B,IAAA,KAAkC,OAAO,IAAI,EAAE,EAA7C,KAAK,WAAA,EAAE,cAAoB,EAApB,MAAM,mBAAG,WAAW,KAAkB,CAAC;IAEtD,IAAM,GAAG,GAAG,IAAI,GAAG,CACf,WAAI,MAAM,CAAC,SAAS,EAAE,uBAAa,QAAQ,CAAC,IAAI,cAAI,MAAM,CAAE,EAC5D,4BAA4B,CAC/B,CAAC;IACF,IAAI,KAAK,EAAE;QACP,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;KAC3C;IACD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AAC1B,CAAC;AAfD,kDAeC"}
@@ -7,8 +7,8 @@ export interface NewsroomContextType {
7
7
  companyInformation: NewsroomCompanyInformation;
8
8
  categories: Category[];
9
9
  contacts?: NewsroomContact[];
10
- selectedCategory?: Category;
11
- selectedStory?: ExtendedStory;
10
+ currentCategory?: Category;
11
+ currentStory?: ExtendedStory;
12
12
  languages: NewsroomLanguageSettings[];
13
13
  locale: LocaleObject;
14
14
  themePreset: NewsroomThemePreset;
@@ -17,14 +17,14 @@ var react_1 = require("react");
17
17
  var intl_1 = require("../intl");
18
18
  exports.NewsroomContext = (0, react_1.createContext)(undefined);
19
19
  var NewsroomContextProvider = function (_a) {
20
- var categories = _a.categories, contacts = _a.contacts, newsroom = _a.newsroom, selectedCategory = _a.selectedCategory, selectedStory = _a.selectedStory, companyInformation = _a.companyInformation, languages = _a.languages, localeCode = _a.localeCode, themePreset = _a.themePreset, algoliaSettings = _a.algoliaSettings, children = _a.children;
20
+ var categories = _a.categories, contacts = _a.contacts, newsroom = _a.newsroom, currentCategory = _a.currentCategory, currentStory = _a.currentStory, companyInformation = _a.companyInformation, languages = _a.languages, localeCode = _a.localeCode, themePreset = _a.themePreset, algoliaSettings = _a.algoliaSettings, children = _a.children;
21
21
  var locale = (0, react_1.useMemo)(function () { return intl_1.LocaleObject.fromAnyCode(localeCode || intl_1.DEFAULT_LOCALE); }, [localeCode]);
22
22
  return ((0, jsx_runtime_1.jsx)(exports.NewsroomContext.Provider, __assign({ value: {
23
23
  categories: categories,
24
24
  contacts: contacts,
25
25
  newsroom: newsroom,
26
- selectedCategory: selectedCategory,
27
- selectedStory: selectedStory,
26
+ currentCategory: currentCategory,
27
+ currentStory: currentStory,
28
28
  companyInformation: companyInformation,
29
29
  languages: languages,
30
30
  locale: locale,
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/newsroom-context/context.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AASA,+BAAkE;AAGlE,gCAAuD;AAmB1C,QAAA,eAAe,GAAG,IAAA,qBAAa,EAAkC,SAAS,CAAC,CAAC;AAElF,IAAM,uBAAuB,GAA4C,UAAC,EAYhF;QAXG,UAAU,gBAAA,EACV,QAAQ,cAAA,EACR,QAAQ,cAAA,EACR,gBAAgB,sBAAA,EAChB,aAAa,mBAAA,EACb,kBAAkB,wBAAA,EAClB,SAAS,eAAA,EACT,UAAU,gBAAA,EACV,WAAW,iBAAA,EACX,eAAe,qBAAA,EACf,QAAQ,cAAA;IAER,IAAM,MAAM,GAAG,IAAA,eAAO,EAClB,cAAM,OAAA,mBAAY,CAAC,WAAW,CAAC,UAAU,IAAI,qBAAc,CAAC,EAAtD,CAAsD,EAC5D,CAAC,UAAU,CAAC,CACf,CAAC;IAEF,OAAO,CACH,uBAAC,uBAAe,CAAC,QAAQ,aACrB,KAAK,EAAE;YACH,UAAU,YAAA;YACV,QAAQ,UAAA;YACR,QAAQ,UAAA;YACR,gBAAgB,kBAAA;YAChB,aAAa,eAAA;YACb,kBAAkB,oBAAA;YAClB,SAAS,WAAA;YACT,MAAM,QAAA;YACN,WAAW,aAAA;YACX,eAAe,iBAAA;SAClB,gBAEA,QAAQ,YACc,CAC9B,CAAC;AACN,CAAC,CAAC;AApCW,QAAA,uBAAuB,2BAoClC"}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/newsroom-context/context.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AASA,+BAAkE;AAGlE,gCAAuD;AAmB1C,QAAA,eAAe,GAAG,IAAA,qBAAa,EAAkC,SAAS,CAAC,CAAC;AAElF,IAAM,uBAAuB,GAA4C,UAAC,EAYhF;QAXG,UAAU,gBAAA,EACV,QAAQ,cAAA,EACR,QAAQ,cAAA,EACR,eAAe,qBAAA,EACf,YAAY,kBAAA,EACZ,kBAAkB,wBAAA,EAClB,SAAS,eAAA,EACT,UAAU,gBAAA,EACV,WAAW,iBAAA,EACX,eAAe,qBAAA,EACf,QAAQ,cAAA;IAER,IAAM,MAAM,GAAG,IAAA,eAAO,EAClB,cAAM,OAAA,mBAAY,CAAC,WAAW,CAAC,UAAU,IAAI,qBAAc,CAAC,EAAtD,CAAsD,EAC5D,CAAC,UAAU,CAAC,CACf,CAAC;IAEF,OAAO,CACH,uBAAC,uBAAe,CAAC,QAAQ,aACrB,KAAK,EAAE;YACH,UAAU,YAAA;YACV,QAAQ,UAAA;YACR,QAAQ,UAAA;YACR,eAAe,iBAAA;YACf,YAAY,cAAA;YACZ,kBAAkB,oBAAA;YAClB,SAAS,WAAA;YACT,MAAM,QAAA;YACN,WAAW,aAAA;YACX,eAAe,iBAAA;SAClB,gBAEA,QAAQ,YACc,CAC9B,CAAC;AACN,CAAC,CAAC;AApCW,QAAA,uBAAuB,2BAoClC"}
@@ -1,11 +1,11 @@
1
1
  export * from './useAlgoliaSettings';
2
2
  export * from './useCategories';
3
3
  export * from './useCompanyInformation';
4
+ export * from './useCurrentCategory';
4
5
  export * from './useCurrentLocale';
6
+ export * from './useCurrentStory';
5
7
  export * from './useGetLinkLocaleSlug';
6
8
  export * from './useGetTranslationUrl';
7
9
  export * from './useLanguages';
8
10
  export * from './useNewsroom';
9
11
  export * from './useNewsroomContext';
10
- export * from './useSelectedCategory';
11
- export * from './useSelectedStory';
@@ -13,12 +13,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./useAlgoliaSettings"), exports);
14
14
  __exportStar(require("./useCategories"), exports);
15
15
  __exportStar(require("./useCompanyInformation"), exports);
16
+ __exportStar(require("./useCurrentCategory"), exports);
16
17
  __exportStar(require("./useCurrentLocale"), exports);
18
+ __exportStar(require("./useCurrentStory"), exports);
17
19
  __exportStar(require("./useGetLinkLocaleSlug"), exports);
18
20
  __exportStar(require("./useGetTranslationUrl"), exports);
19
21
  __exportStar(require("./useLanguages"), exports);
20
22
  __exportStar(require("./useNewsroom"), exports);
21
23
  __exportStar(require("./useNewsroomContext"), exports);
22
- __exportStar(require("./useSelectedCategory"), exports);
23
- __exportStar(require("./useSelectedStory"), exports);
24
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAqC;AACrC,kDAAgC;AAChC,0DAAwC;AACxC,qDAAmC;AACnC,yDAAuC;AACvC,yDAAuC;AACvC,iDAA+B;AAC/B,gDAA8B;AAC9B,uDAAqC;AACrC,wDAAsC;AACtC,qDAAmC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAqC;AACrC,kDAAgC;AAChC,0DAAwC;AACxC,uDAAqC;AACrC,qDAAmC;AACnC,oDAAkC;AAClC,yDAAuC;AACvC,yDAAuC;AACvC,iDAA+B;AAC/B,gDAA8B;AAC9B,uDAAqC"}
@@ -0,0 +1 @@
1
+ export declare const useCurrentCategory: () => import("@prezly/sdk").Category | undefined;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCurrentCategory = void 0;
4
+ var useNewsroomContext_1 = require("./useNewsroomContext");
5
+ var useCurrentCategory = function () {
6
+ var context = (0, useNewsroomContext_1.useNewsroomContext)();
7
+ return context.currentCategory;
8
+ };
9
+ exports.useCurrentCategory = useCurrentCategory;
10
+ //# sourceMappingURL=useCurrentCategory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCurrentCategory.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useCurrentCategory.ts"],"names":[],"mappings":";;;AAAA,2DAA0D;AAEnD,IAAM,kBAAkB,GAAG;IAC9B,IAAM,OAAO,GAAG,IAAA,uCAAkB,GAAE,CAAC;IAErC,OAAO,OAAO,CAAC,eAAe,CAAC;AACnC,CAAC,CAAC;AAJW,QAAA,kBAAkB,sBAI7B"}
@@ -0,0 +1 @@
1
+ export declare const useCurrentStory: () => import("@prezly/sdk").ExtendedStory | undefined;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useSelectedStory = void 0;
3
+ exports.useCurrentStory = void 0;
4
4
  var useNewsroomContext_1 = require("./useNewsroomContext");
5
- var useSelectedStory = function () {
5
+ var useCurrentStory = function () {
6
6
  var context = (0, useNewsroomContext_1.useNewsroomContext)();
7
- return context.selectedStory;
7
+ return context.currentStory;
8
8
  };
9
- exports.useSelectedStory = useSelectedStory;
10
- //# sourceMappingURL=useSelectedStory.js.map
9
+ exports.useCurrentStory = useCurrentStory;
10
+ //# sourceMappingURL=useCurrentStory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCurrentStory.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useCurrentStory.ts"],"names":[],"mappings":";;;AAAA,2DAA0D;AAEnD,IAAM,eAAe,GAAG;IAC3B,IAAM,OAAO,GAAG,IAAA,uCAAkB,GAAE,CAAC;IAErC,OAAO,OAAO,CAAC,YAAY,CAAC;AAChC,CAAC,CAAC;AAJW,QAAA,eAAe,mBAI1B"}
@@ -4,13 +4,13 @@ exports.useGetTranslationUrl = void 0;
4
4
  var router_1 = require("next/router");
5
5
  var react_1 = require("react");
6
6
  var data_fetching_1 = require("../../data-fetching");
7
- var useSelectedCategory_1 = require("./useSelectedCategory");
8
- var useSelectedStory_1 = require("./useSelectedStory");
7
+ var useCurrentCategory_1 = require("./useCurrentCategory");
8
+ var useCurrentStory_1 = require("./useCurrentStory");
9
9
  // Determine correct URL for translated stories/categories with a fallback to homepage
10
- function getTranslationUrl(locale, path, selectedCategory, selectedStory, noFallback) {
11
- if (selectedCategory) {
12
- if ((0, data_fetching_1.getCategoryHasTranslation)(selectedCategory, locale)) {
13
- return (0, data_fetching_1.getCategoryUrl)(selectedCategory, locale);
10
+ function getTranslationUrl(locale, path, currentCategory, currentStory, noFallback) {
11
+ if (currentCategory) {
12
+ if ((0, data_fetching_1.getCategoryHasTranslation)(currentCategory, locale)) {
13
+ return (0, data_fetching_1.getCategoryUrl)(currentCategory, locale);
14
14
  }
15
15
  if (noFallback) {
16
16
  return '';
@@ -18,8 +18,8 @@ function getTranslationUrl(locale, path, selectedCategory, selectedStory, noFall
18
18
  return '/';
19
19
  }
20
20
  var localeCode = locale.toUnderscoreCode();
21
- if (selectedStory && selectedStory.culture.locale !== localeCode) {
22
- var translatedStory = selectedStory.translations.find(function (_a) {
21
+ if (currentStory && currentStory.culture.locale !== localeCode) {
22
+ var translatedStory = currentStory.translations.find(function (_a) {
23
23
  var culture = _a.culture;
24
24
  return culture.locale === localeCode;
25
25
  });
@@ -35,11 +35,11 @@ function getTranslationUrl(locale, path, selectedCategory, selectedStory, noFall
35
35
  }
36
36
  function useGetTranslationUrl() {
37
37
  var asPath = (0, router_1.useRouter)().asPath;
38
- var selectedCategory = (0, useSelectedCategory_1.useSelectedCategory)();
39
- var selectedStory = (0, useSelectedStory_1.useSelectedStory)();
38
+ var currentCategory = (0, useCurrentCategory_1.useCurrentCategory)();
39
+ var currentStory = (0, useCurrentStory_1.useCurrentStory)();
40
40
  return (0, react_1.useCallback)(function (locale, noFallback) {
41
- return getTranslationUrl(locale, asPath, selectedCategory, selectedStory, noFallback);
42
- }, [asPath, selectedCategory, selectedStory]);
41
+ return getTranslationUrl(locale, asPath, currentCategory, currentStory, noFallback);
42
+ }, [asPath, currentCategory, currentStory]);
43
43
  }
44
44
  exports.useGetTranslationUrl = useGetTranslationUrl;
45
45
  //# sourceMappingURL=useGetTranslationUrl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useGetTranslationUrl.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useGetTranslationUrl.ts"],"names":[],"mappings":";;;AACA,sCAAwC;AACxC,+BAAoC;AAEpC,qDAAgF;AAGhF,6DAA4D;AAC5D,uDAAsD;AAEtD,sFAAsF;AACtF,SAAS,iBAAiB,CACtB,MAAoB,EACpB,IAAY,EACZ,gBAA2B,EAC3B,aAA6B,EAC7B,UAAoB;IAEpB,IAAI,gBAAgB,EAAE;QAClB,IAAI,IAAA,yCAAyB,EAAC,gBAAgB,EAAE,MAAM,CAAC,EAAE;YACrD,OAAO,IAAA,8BAAc,EAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;SACnD;QAED,IAAI,UAAU,EAAE;YACZ,OAAO,EAAE,CAAC;SACb;QAED,OAAO,GAAG,CAAC;KACd;IAED,IAAM,UAAU,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAE7C,IAAI,aAAa,IAAI,aAAa,CAAC,OAAO,CAAC,MAAM,KAAK,UAAU,EAAE;QAC9D,IAAM,eAAe,GAAG,aAAa,CAAC,YAAY,CAAC,IAAI,CACnD,UAAC,EAAW;gBAAT,OAAO,aAAA;YAAO,OAAA,OAAO,CAAC,MAAM,KAAK,UAAU;QAA7B,CAA6B,CACjD,CAAC;QACF,IAAI,eAAe,EAAE;YACjB,OAAO,WAAI,eAAe,CAAC,IAAI,CAAE,CAAC;SACrC;QAED,IAAI,UAAU,EAAE;YACZ,OAAO,EAAE,CAAC;SACb;QAED,OAAO,GAAG,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,SAAgB,oBAAoB;IACxB,IAAA,MAAM,GAAK,IAAA,kBAAS,GAAE,OAAhB,CAAiB;IAC/B,IAAM,gBAAgB,GAAG,IAAA,yCAAmB,GAAE,CAAC;IAC/C,IAAM,aAAa,GAAG,IAAA,mCAAgB,GAAE,CAAC;IAEzC,OAAO,IAAA,mBAAW,EACd,UAAC,MAAoB,EAAE,UAAoB;QACvC,OAAA,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAE,UAAU,CAAC;IAA9E,CAA8E,EAClF,CAAC,MAAM,EAAE,gBAAgB,EAAE,aAAa,CAAC,CAC5C,CAAC;AACN,CAAC;AAVD,oDAUC"}
1
+ {"version":3,"file":"useGetTranslationUrl.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useGetTranslationUrl.ts"],"names":[],"mappings":";;;AACA,sCAAwC;AACxC,+BAAoC;AAEpC,qDAAgF;AAGhF,2DAA0D;AAC1D,qDAAoD;AAEpD,sFAAsF;AACtF,SAAS,iBAAiB,CACtB,MAAoB,EACpB,IAAY,EACZ,eAA0B,EAC1B,YAA4B,EAC5B,UAAoB;IAEpB,IAAI,eAAe,EAAE;QACjB,IAAI,IAAA,yCAAyB,EAAC,eAAe,EAAE,MAAM,CAAC,EAAE;YACpD,OAAO,IAAA,8BAAc,EAAC,eAAe,EAAE,MAAM,CAAC,CAAC;SAClD;QAED,IAAI,UAAU,EAAE;YACZ,OAAO,EAAE,CAAC;SACb;QAED,OAAO,GAAG,CAAC;KACd;IAED,IAAM,UAAU,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAE7C,IAAI,YAAY,IAAI,YAAY,CAAC,OAAO,CAAC,MAAM,KAAK,UAAU,EAAE;QAC5D,IAAM,eAAe,GAAG,YAAY,CAAC,YAAY,CAAC,IAAI,CAClD,UAAC,EAAW;gBAAT,OAAO,aAAA;YAAO,OAAA,OAAO,CAAC,MAAM,KAAK,UAAU;QAA7B,CAA6B,CACjD,CAAC;QACF,IAAI,eAAe,EAAE;YACjB,OAAO,WAAI,eAAe,CAAC,IAAI,CAAE,CAAC;SACrC;QAED,IAAI,UAAU,EAAE;YACZ,OAAO,EAAE,CAAC;SACb;QAED,OAAO,GAAG,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,SAAgB,oBAAoB;IACxB,IAAA,MAAM,GAAK,IAAA,kBAAS,GAAE,OAAhB,CAAiB;IAC/B,IAAM,eAAe,GAAG,IAAA,uCAAkB,GAAE,CAAC;IAC7C,IAAM,YAAY,GAAG,IAAA,iCAAe,GAAE,CAAC;IAEvC,OAAO,IAAA,mBAAW,EACd,UAAC,MAAoB,EAAE,UAAoB;QACvC,OAAA,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,YAAY,EAAE,UAAU,CAAC;IAA5E,CAA4E,EAChF,CAAC,MAAM,EAAE,eAAe,EAAE,YAAY,CAAC,CAC1C,CAAC;AACN,CAAC;AAVD,oDAUC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prezly/theme-kit-nextjs",
3
- "version": "1.1.5-0",
3
+ "version": "1.3.0",
4
4
  "description": "Data layer and utility library for developing Prezly themes with NextJS",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -4,19 +4,6 @@ import { getShortestLocaleCode } from '../data-fetching';
4
4
  import { getRedirectToCanonicalLocale, LocaleObject } from '../intl';
5
5
  import { PageProps, ServerSidePageProps } from '../types';
6
6
 
7
- // TODO: Try to make the typings even more robust
8
- function extractServerSideProps<Props>(props: Props & ServerSidePageProps): {
9
- pageProps: Props;
10
- serverSideProps: ServerSidePageProps;
11
- } {
12
- const { localeResolved, ...pageProps } = props;
13
-
14
- return {
15
- pageProps: pageProps as unknown as Props,
16
- serverSideProps: { localeResolved },
17
- };
18
- }
19
-
20
7
  export function processRequest<Props>(
21
8
  context: GetServerSidePropsContext,
22
9
  props: Props & PageProps & ServerSidePageProps,
@@ -24,9 +11,9 @@ export function processRequest<Props>(
24
11
  ): GetServerSidePropsResult<Props> {
25
12
  const { locale: nextLocale, query } = context;
26
13
 
27
- const { pageProps, serverSideProps } = extractServerSideProps(props);
14
+ const { localeResolved, ...pageProps } = props;
28
15
 
29
- if (!serverSideProps.localeResolved) {
16
+ if (!localeResolved) {
30
17
  return { notFound: true };
31
18
  }
32
19
 
@@ -47,6 +34,6 @@ export function processRequest<Props>(
47
34
  }
48
35
 
49
36
  return {
50
- props: pageProps,
37
+ props: pageProps as Props & PageProps,
51
38
  };
52
39
  }
@@ -4,7 +4,7 @@ import { getAssetsUrl } from './getAssetsUrl';
4
4
 
5
5
  export function getNewsroomLogoUrl(newsroom: Newsroom): string {
6
6
  if (newsroom.newsroom_logo) {
7
- getAssetsUrl(newsroom.newsroom_logo.uuid);
7
+ return getAssetsUrl(newsroom.newsroom_logo.uuid);
8
8
  }
9
9
 
10
10
  return '';
@@ -2,7 +2,10 @@ import type { Newsroom } from '@prezly/sdk';
2
2
 
3
3
  import { LocaleObject } from '../intl';
4
4
 
5
- type PrivacyPortalUrlOptions = { email?: string; action?: 'subscribe' | 'unsubscribe' };
5
+ type PrivacyPortalUrlOptions = {
6
+ email?: string;
7
+ action?: 'data-request' | 'subscribe' | 'unsubscribe';
8
+ };
6
9
 
7
10
  export function getPrivacyPortalUrl(
8
11
  newsroom: Newsroom,
@@ -17,8 +17,8 @@ export interface NewsroomContextType {
17
17
  companyInformation: NewsroomCompanyInformation;
18
18
  categories: Category[];
19
19
  contacts?: NewsroomContact[];
20
- selectedCategory?: Category;
21
- selectedStory?: ExtendedStory;
20
+ currentCategory?: Category;
21
+ currentStory?: ExtendedStory;
22
22
  languages: NewsroomLanguageSettings[];
23
23
  locale: LocaleObject;
24
24
  themePreset: NewsroomThemePreset;
@@ -35,8 +35,8 @@ export const NewsroomContextProvider: FunctionComponent<NewsroomContextProps> =
35
35
  categories,
36
36
  contacts,
37
37
  newsroom,
38
- selectedCategory,
39
- selectedStory,
38
+ currentCategory,
39
+ currentStory,
40
40
  companyInformation,
41
41
  languages,
42
42
  localeCode,
@@ -55,8 +55,8 @@ export const NewsroomContextProvider: FunctionComponent<NewsroomContextProps> =
55
55
  categories,
56
56
  contacts,
57
57
  newsroom,
58
- selectedCategory,
59
- selectedStory,
58
+ currentCategory,
59
+ currentStory,
60
60
  companyInformation,
61
61
  languages,
62
62
  locale,
@@ -1,11 +1,11 @@
1
1
  export * from './useAlgoliaSettings';
2
2
  export * from './useCategories';
3
3
  export * from './useCompanyInformation';
4
+ export * from './useCurrentCategory';
4
5
  export * from './useCurrentLocale';
6
+ export * from './useCurrentStory';
5
7
  export * from './useGetLinkLocaleSlug';
6
8
  export * from './useGetTranslationUrl';
7
9
  export * from './useLanguages';
8
10
  export * from './useNewsroom';
9
11
  export * from './useNewsroomContext';
10
- export * from './useSelectedCategory';
11
- export * from './useSelectedStory';
@@ -1,7 +1,7 @@
1
1
  import { useNewsroomContext } from './useNewsroomContext';
2
2
 
3
- export const useSelectedCategory = () => {
3
+ export const useCurrentCategory = () => {
4
4
  const context = useNewsroomContext();
5
5
 
6
- return context.selectedCategory;
6
+ return context.currentCategory;
7
7
  };
@@ -1,7 +1,7 @@
1
1
  import { useNewsroomContext } from './useNewsroomContext';
2
2
 
3
- export const useSelectedStory = () => {
3
+ export const useCurrentStory = () => {
4
4
  const context = useNewsroomContext();
5
5
 
6
- return context.selectedStory;
6
+ return context.currentStory;
7
7
  };
@@ -5,20 +5,20 @@ import { useCallback } from 'react';
5
5
  import { getCategoryHasTranslation, getCategoryUrl } from '../../data-fetching';
6
6
  import { LocaleObject } from '../../intl';
7
7
 
8
- import { useSelectedCategory } from './useSelectedCategory';
9
- import { useSelectedStory } from './useSelectedStory';
8
+ import { useCurrentCategory } from './useCurrentCategory';
9
+ import { useCurrentStory } from './useCurrentStory';
10
10
 
11
11
  // Determine correct URL for translated stories/categories with a fallback to homepage
12
12
  function getTranslationUrl(
13
13
  locale: LocaleObject,
14
14
  path: string,
15
- selectedCategory?: Category,
16
- selectedStory?: ExtendedStory,
15
+ currentCategory?: Category,
16
+ currentStory?: ExtendedStory,
17
17
  noFallback?: boolean,
18
18
  ) {
19
- if (selectedCategory) {
20
- if (getCategoryHasTranslation(selectedCategory, locale)) {
21
- return getCategoryUrl(selectedCategory, locale);
19
+ if (currentCategory) {
20
+ if (getCategoryHasTranslation(currentCategory, locale)) {
21
+ return getCategoryUrl(currentCategory, locale);
22
22
  }
23
23
 
24
24
  if (noFallback) {
@@ -30,8 +30,8 @@ function getTranslationUrl(
30
30
 
31
31
  const localeCode = locale.toUnderscoreCode();
32
32
 
33
- if (selectedStory && selectedStory.culture.locale !== localeCode) {
34
- const translatedStory = selectedStory.translations.find(
33
+ if (currentStory && currentStory.culture.locale !== localeCode) {
34
+ const translatedStory = currentStory.translations.find(
35
35
  ({ culture }) => culture.locale === localeCode,
36
36
  );
37
37
  if (translatedStory) {
@@ -50,12 +50,12 @@ function getTranslationUrl(
50
50
 
51
51
  export function useGetTranslationUrl() {
52
52
  const { asPath } = useRouter();
53
- const selectedCategory = useSelectedCategory();
54
- const selectedStory = useSelectedStory();
53
+ const currentCategory = useCurrentCategory();
54
+ const currentStory = useCurrentStory();
55
55
 
56
56
  return useCallback(
57
57
  (locale: LocaleObject, noFallback?: boolean) =>
58
- getTranslationUrl(locale, asPath, selectedCategory, selectedStory, noFallback),
59
- [asPath, selectedCategory, selectedStory],
58
+ getTranslationUrl(locale, asPath, currentCategory, currentStory, noFallback),
59
+ [asPath, currentCategory, currentStory],
60
60
  );
61
61
  }
@@ -1 +0,0 @@
1
- export declare const useSelectedCategory: () => import("@prezly/sdk").Category | undefined;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useSelectedCategory = void 0;
4
- var useNewsroomContext_1 = require("./useNewsroomContext");
5
- var useSelectedCategory = function () {
6
- var context = (0, useNewsroomContext_1.useNewsroomContext)();
7
- return context.selectedCategory;
8
- };
9
- exports.useSelectedCategory = useSelectedCategory;
10
- //# sourceMappingURL=useSelectedCategory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSelectedCategory.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useSelectedCategory.ts"],"names":[],"mappings":";;;AAAA,2DAA0D;AAEnD,IAAM,mBAAmB,GAAG;IAC/B,IAAM,OAAO,GAAG,IAAA,uCAAkB,GAAE,CAAC;IAErC,OAAO,OAAO,CAAC,gBAAgB,CAAC;AACpC,CAAC,CAAC;AAJW,QAAA,mBAAmB,uBAI9B"}
@@ -1 +0,0 @@
1
- export declare const useSelectedStory: () => import("@prezly/sdk").ExtendedStory | undefined;
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSelectedStory.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useSelectedStory.ts"],"names":[],"mappings":";;;AAAA,2DAA0D;AAEnD,IAAM,gBAAgB,GAAG;IAC5B,IAAM,OAAO,GAAG,IAAA,uCAAkB,GAAE,CAAC;IAErC,OAAO,OAAO,CAAC,aAAa,CAAC;AACjC,CAAC,CAAC;AAJW,QAAA,gBAAgB,oBAI3B"}