@prezly/theme-kit-nextjs 3.3.2-alpha.0 → 4.0.0-alpha.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.
- package/README.md +5 -4
- package/build/adapter-nextjs/api-handlers/fetchGalleries.js +1 -1
- package/build/adapter-nextjs/api-handlers/fetchGalleries.js.map +1 -1
- package/build/adapter-nextjs/api-handlers/fetchStories.js +1 -1
- package/build/adapter-nextjs/api-handlers/fetchStories.js.map +1 -1
- package/build/adapter-nextjs/getNewsroomServerSideProps.d.ts +1 -1
- package/build/adapter-nextjs/getNewsroomServerSideProps.js +1 -1
- package/build/adapter-nextjs/getNewsroomServerSideProps.js.map +1 -1
- package/build/adapter-nextjs/getNewsroomStaticProps.d.ts +1 -1
- package/build/adapter-nextjs/getNewsroomStaticProps.js +1 -1
- package/build/adapter-nextjs/getNewsroomStaticProps.js.map +1 -1
- package/build/adapter-nextjs/page-props/category.js +6 -7
- package/build/adapter-nextjs/page-props/category.js.map +1 -1
- package/build/adapter-nextjs/page-props/gallery.js +3 -3
- package/build/adapter-nextjs/page-props/gallery.js.map +1 -1
- package/build/adapter-nextjs/page-props/galleryAlbum.js +1 -1
- package/build/adapter-nextjs/page-props/galleryAlbum.js.map +1 -1
- package/build/adapter-nextjs/page-props/home.js +3 -3
- package/build/adapter-nextjs/page-props/home.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js +1 -1
- package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js.map +1 -1
- package/build/adapter-nextjs/page-props/story.js +3 -3
- package/build/adapter-nextjs/page-props/story.js.map +1 -1
- package/build/adapter-nextjs/page-props/storyPreview.js +1 -1
- package/build/adapter-nextjs/page-props/storyPreview.js.map +1 -1
- package/build/adapter-nextjs/processRequest.js +3 -2
- package/build/adapter-nextjs/processRequest.js.map +1 -1
- package/build/components-nextjs/PageSeo/PageSeo.js +13 -20
- package/build/components-nextjs/PageSeo/PageSeo.js.map +1 -1
- package/build/components-nextjs/PageSeo/index.d.ts +0 -1
- package/build/components-nextjs/PageSeo/index.js +0 -15
- package/build/components-nextjs/PageSeo/index.js.map +1 -1
- package/build/components-nextjs/PageSeo/lib/index.d.ts +1 -0
- package/build/components-nextjs/PageSeo/lib/index.js +6 -0
- package/build/components-nextjs/PageSeo/lib/index.js.map +1 -0
- package/build/components-nextjs/document.js +4 -4
- package/build/components-nextjs/document.js.map +1 -1
- package/build/data-fetching/NextPrezlyApi.d.ts +8 -0
- package/build/data-fetching/NextPrezlyApi.js +40 -0
- package/build/data-fetching/NextPrezlyApi.js.map +1 -0
- package/build/data-fetching/getNextPrezlyApi.d.ts +4 -0
- package/build/data-fetching/getNextPrezlyApi.js +21 -0
- package/build/data-fetching/getNextPrezlyApi.js.map +1 -0
- package/build/data-fetching/index.d.ts +1 -3
- package/build/data-fetching/index.js +3 -17
- package/build/data-fetching/index.js.map +1 -1
- package/build/index.d.ts +0 -2
- package/build/index.js +0 -2
- package/build/index.js.map +1 -1
- package/build/infinite-loading/useInfiniteLoading.js +1 -1
- package/build/infinite-loading/useInfiniteLoading.js.map +1 -1
- package/build/infinite-loading/useInfiniteStoriesLoading.js.map +1 -1
- package/build/intl/index.d.ts +0 -2
- package/build/intl/index.js +0 -7
- package/build/intl/index.js.map +1 -1
- package/build/intl/languages.d.ts +1 -44
- package/build/intl/languages.js +8 -151
- package/build/intl/languages.js.map +1 -1
- package/build/intl/locale.d.ts +0 -8
- package/build/intl/locale.js +3 -93
- package/build/intl/locale.js.map +1 -1
- package/build/newsroom-context/context.d.ts +2 -2
- package/build/newsroom-context/context.js +2 -2
- package/build/newsroom-context/context.js.map +1 -1
- package/build/newsroom-context/hooks/useAlgoliaSettings.d.ts +1 -1
- package/build/newsroom-context/hooks/useCurrentLocale.d.ts +1 -1
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.d.ts +1 -1
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js +3 -3
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js.map +1 -1
- package/build/newsroom-context/hooks/useGetTranslationUrl.d.ts +1 -1
- package/build/newsroom-context/hooks/useGetTranslationUrl.js +3 -3
- package/build/newsroom-context/hooks/useGetTranslationUrl.js.map +1 -1
- package/build/types.d.ts +0 -29
- package/package.json +15 -13
- package/src/adapter-nextjs/api-handlers/fetchGalleries.ts +2 -2
- package/src/adapter-nextjs/api-handlers/fetchStories.ts +2 -2
- package/src/adapter-nextjs/getNewsroomServerSideProps.ts +2 -2
- package/src/adapter-nextjs/getNewsroomStaticProps.ts +2 -2
- package/src/adapter-nextjs/page-props/category.ts +3 -4
- package/src/adapter-nextjs/page-props/gallery.ts +1 -1
- package/src/adapter-nextjs/page-props/galleryAlbum.ts +2 -2
- package/src/adapter-nextjs/page-props/home.ts +1 -1
- package/src/adapter-nextjs/page-props/sitemap/getServerSideProps.ts +2 -2
- package/src/adapter-nextjs/page-props/story.ts +4 -4
- package/src/adapter-nextjs/page-props/storyPreview.ts +2 -2
- package/src/adapter-nextjs/processRequest.ts +2 -1
- package/src/components-nextjs/PageSeo/PageSeo.tsx +7 -5
- package/src/components-nextjs/PageSeo/index.ts +0 -1
- package/src/components-nextjs/PageSeo/lib/index.ts +1 -0
- package/src/components-nextjs/document.tsx +1 -1
- package/src/data-fetching/NextPrezlyApi.ts +57 -0
- package/src/data-fetching/{api/getPrezlyApi.ts → getNextPrezlyApi.ts} +5 -6
- package/src/data-fetching/index.ts +1 -3
- package/src/index.ts +0 -2
- package/src/infinite-loading/useInfiniteStoriesLoading.ts +1 -1
- package/src/intl/index.ts +0 -3
- package/src/intl/languages.test.ts +1 -196
- package/src/intl/languages.ts +8 -201
- package/src/intl/locale.test.ts +1 -55
- package/src/intl/locale.ts +1 -106
- package/src/newsroom-context/context.tsx +2 -3
- package/src/newsroom-context/hooks/useGetLinkLocaleSlug.ts +1 -2
- package/src/newsroom-context/hooks/useGetTranslationUrl.ts +2 -3
- package/src/types.ts +0 -35
- package/build/components-nextjs/PageSeo/lib/types.d.ts +0 -4
- package/build/components-nextjs/PageSeo/lib/types.js +0 -3
- package/build/components-nextjs/PageSeo/lib/types.js.map +0 -1
- package/build/data-fetching/api/PrezlyApi.d.ts +0 -57
- package/build/data-fetching/api/PrezlyApi.js +0 -200
- package/build/data-fetching/api/PrezlyApi.js.map +0 -1
- package/build/data-fetching/api/getPrezlyApi.d.ts +0 -4
- package/build/data-fetching/api/getPrezlyApi.js +0 -21
- package/build/data-fetching/api/getPrezlyApi.js.map +0 -1
- package/build/data-fetching/api/index.d.ts +0 -1
- package/build/data-fetching/api/index.js +0 -18
- package/build/data-fetching/api/index.js.map +0 -1
- package/build/data-fetching/api/lib.d.ts +0 -11
- package/build/data-fetching/api/lib.js +0 -20
- package/build/data-fetching/api/lib.js.map +0 -1
- package/build/data-fetching/api/queries.d.ts +0 -46
- package/build/data-fetching/api/queries.js +0 -56
- package/build/data-fetching/api/queries.js.map +0 -1
- package/build/data-fetching/lib/getAlgoliaSettings.d.ts +0 -4
- package/build/data-fetching/lib/getAlgoliaSettings.js +0 -22
- package/build/data-fetching/lib/getAlgoliaSettings.js.map +0 -1
- package/build/data-fetching/lib/getEnvVariables.d.ts +0 -4
- package/build/data-fetching/lib/getEnvVariables.js +0 -44
- package/build/data-fetching/lib/getEnvVariables.js.map +0 -1
- package/build/data-fetching/lib/index.d.ts +0 -4
- package/build/data-fetching/lib/index.js +0 -12
- package/build/data-fetching/lib/index.js.map +0 -1
- package/build/data-fetching/lib/isSdkError.d.ts +0 -2
- package/build/data-fetching/lib/isSdkError.js +0 -8
- package/build/data-fetching/lib/isSdkError.js.map +0 -1
- package/build/data-fetching/lib/isUuid.d.ts +0 -1
- package/build/data-fetching/lib/isUuid.js +0 -9
- package/build/data-fetching/lib/isUuid.js.map +0 -1
- package/build/data-fetching/types.d.ts +0 -13
- package/build/data-fetching/types.js +0 -3
- package/build/data-fetching/types.js.map +0 -1
- package/build/intl/localeConfig.d.ts +0 -2
- package/build/intl/localeConfig.js +0 -20
- package/build/intl/localeConfig.js.map +0 -1
- package/build/intl/localeList.d.ts +0 -2
- package/build/intl/localeList.js +0 -112
- package/build/intl/localeList.js.map +0 -1
- package/build/intl/localeObject.d.ts +0 -45
- package/build/intl/localeObject.js +0 -91
- package/build/intl/localeObject.js.map +0 -1
- package/build/utils/boilerplate.d.ts +0 -4
- package/build/utils/boilerplate.js +0 -27
- package/build/utils/boilerplate.js.map +0 -1
- package/build/utils/constants.d.ts +0 -3
- package/build/utils/constants.js +0 -7
- package/build/utils/constants.js.map +0 -1
- package/build/utils/getAssetsUrl.d.ts +0 -5
- package/build/utils/getAssetsUrl.js +0 -13
- package/build/utils/getAssetsUrl.js.map +0 -1
- package/build/utils/getDataRequestLink.d.ts +0 -3
- package/build/utils/getDataRequestLink.js +0 -12
- package/build/utils/getDataRequestLink.js.map +0 -1
- package/build/utils/getLocalizedCategoryData.d.ts +0 -10
- package/build/utils/getLocalizedCategoryData.js +0 -37
- package/build/utils/getLocalizedCategoryData.js.map +0 -1
- package/build/utils/getNewsroomLogoUrl.d.ts +0 -3
- package/build/utils/getNewsroomLogoUrl.js +0 -22
- package/build/utils/getNewsroomLogoUrl.js.map +0 -1
- package/build/utils/getPrivacyPortalUrl.d.ts +0 -8
- package/build/utils/getPrivacyPortalUrl.js +0 -13
- package/build/utils/getPrivacyPortalUrl.js.map +0 -1
- package/build/utils/getStoryPublicationDate.d.ts +0 -3
- package/build/utils/getStoryPublicationDate.js +0 -14
- package/build/utils/getStoryPublicationDate.js.map +0 -1
- package/build/utils/getUploadcareGroupUrl.d.ts +0 -8
- package/build/utils/getUploadcareGroupUrl.js +0 -17
- package/build/utils/getUploadcareGroupUrl.js.map +0 -1
- package/build/utils/index.d.ts +0 -10
- package/build/utils/index.js +0 -27
- package/build/utils/index.js.map +0 -1
- package/build/utils/isEmbargoStory.d.ts +0 -6
- package/build/utils/isEmbargoStory.js +0 -8
- package/build/utils/isEmbargoStory.js.map +0 -1
- package/src/@types/global.d.ts +0 -7
- package/src/__mocks__/story.ts +0 -359
- package/src/components-nextjs/PageSeo/lib/types.ts +0 -4
- package/src/data-fetching/api/PrezlyApi.ts +0 -312
- package/src/data-fetching/api/index.ts +0 -1
- package/src/data-fetching/api/lib.ts +0 -24
- package/src/data-fetching/api/queries.ts +0 -59
- package/src/data-fetching/lib/getAlgoliaSettings.ts +0 -29
- package/src/data-fetching/lib/getEnvVariables.ts +0 -46
- package/src/data-fetching/lib/index.ts +0 -4
- package/src/data-fetching/lib/isSdkError.ts +0 -5
- package/src/data-fetching/lib/isUuid.ts +0 -5
- package/src/data-fetching/types.ts +0 -14
- package/src/intl/getFallbackLocale.ts +0 -29
- package/src/intl/localeConfig.js +0 -23
- package/src/intl/localeList.js +0 -110
- package/src/intl/localeObject.test.ts +0 -81
- package/src/intl/localeObject.ts +0 -107
- package/src/seo/getAlternateLanguageLinks.test.ts +0 -166
- package/src/seo/getAlternateLanguageLinks.ts +0 -115
- package/src/seo/index.ts +0 -1
- package/src/seo/utils/bindLanguagesWithLocales.ts +0 -31
- package/src/seo/utils/createAlternateLanguageLink.ts +0 -17
- package/src/utils/boilerplate.ts +0 -30
- package/src/utils/constants.ts +0 -3
- package/src/utils/getAssetsUrl.test.ts +0 -9
- package/src/utils/getAssetsUrl.ts +0 -9
- package/src/utils/getDataRequestLink.ts +0 -14
- package/src/utils/getLocalizedCategoryData.ts +0 -47
- package/src/utils/getNewsroomLogoUrl.ts +0 -22
- package/src/utils/getPrivacyPortalUrl.ts +0 -25
- package/src/utils/getStoryPublicationDate.tsx +0 -15
- package/src/utils/getUploadcareGroupUrl.ts +0 -13
- package/src/utils/index.ts +0 -10
- package/src/utils/isEmbargoStory.ts +0 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useCurrentLocale(): import("
|
|
1
|
+
export declare function useCurrentLocale(): import("@prezly/theme-kit-core").LocaleObject;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { LocaleObject } from '
|
|
1
|
+
import { LocaleObject } from '@prezly/theme-kit-core';
|
|
2
2
|
export declare function useGetLinkLocaleSlug(): (locale?: LocaleObject) => string | false;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useGetLinkLocaleSlug = void 0;
|
|
4
|
+
const theme_kit_core_1 = require("@prezly/theme-kit-core");
|
|
4
5
|
const react_1 = require("react");
|
|
5
|
-
const intl_1 = require("../../intl");
|
|
6
6
|
const useCurrentLocale_1 = require("./useCurrentLocale");
|
|
7
7
|
const useLanguages_1 = require("./useLanguages");
|
|
8
8
|
/**
|
|
@@ -12,12 +12,12 @@ const useLanguages_1 = require("./useLanguages");
|
|
|
12
12
|
* `false` means that a default locale should be used (no locale in URL required).
|
|
13
13
|
*/
|
|
14
14
|
function getLinkLocaleSlug(languages, locale) {
|
|
15
|
-
const shortestLocaleCode = (0,
|
|
15
|
+
const shortestLocaleCode = (0, theme_kit_core_1.getShortestLocaleCode)(languages, locale);
|
|
16
16
|
// When navigating to default language, we don't append the locale to the URL.
|
|
17
17
|
if (!shortestLocaleCode) {
|
|
18
18
|
return shortestLocaleCode;
|
|
19
19
|
}
|
|
20
|
-
return
|
|
20
|
+
return theme_kit_core_1.LocaleObject.fromAnyCode(shortestLocaleCode).toUrlSlug();
|
|
21
21
|
}
|
|
22
22
|
function useGetLinkLocaleSlug() {
|
|
23
23
|
const currentLocale = (0, useCurrentLocale_1.useCurrentLocale)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetLinkLocaleSlug.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useGetLinkLocaleSlug.ts"],"names":[],"mappings":";;;AACA,iCAAoC;AAEpC,
|
|
1
|
+
{"version":3,"file":"useGetLinkLocaleSlug.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useGetLinkLocaleSlug.ts"],"names":[],"mappings":";;;AACA,2DAA6E;AAC7E,iCAAoC;AAEpC,yDAAsD;AACtD,iDAA8C;AAE9C;;;;;GAKG;AACH,SAAS,iBAAiB,CACtB,SAAqC,EACrC,MAAoB;IAEpB,MAAM,kBAAkB,GAAG,IAAA,sCAAqB,EAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACpE,8EAA8E;IAC9E,IAAI,CAAC,kBAAkB,EAAE;QACrB,OAAO,kBAAkB,CAAC;KAC7B;IAED,OAAO,6BAAY,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,SAAS,EAAE,CAAC;AACpE,CAAC;AAED,SAAgB,oBAAoB;IAChC,MAAM,aAAa,GAAG,IAAA,mCAAgB,GAAE,CAAC;IACzC,MAAM,SAAS,GAAG,IAAA,2BAAY,GAAE,CAAC;IAEjC,8DAA8D;IAC9D,OAAO,IAAA,mBAAW,EACd,CAAC,MAAqB,EAAE,EAAE,CAAC,iBAAiB,CAAC,SAAS,EAAE,MAAM,IAAI,aAAa,CAAC,EAChF,CAAC,SAAS,EAAE,aAAa,CAAC,CAC7B,CAAC;AACN,CAAC;AATD,oDASC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LocaleObject } from '
|
|
1
|
+
import type { LocaleObject } from '@prezly/theme-kit-core';
|
|
2
2
|
/**
|
|
3
3
|
* This hook returns a function that is meant to be used in language pickers and alternate locales list for the pages.
|
|
4
4
|
* `noFallback` parameter is useful for alternate language links in the `head` section of the document (so that there are no unwanted links to the homepage).
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useGetTranslationUrl = void 0;
|
|
4
4
|
const sdk_1 = require("@prezly/sdk");
|
|
5
|
+
const theme_kit_core_1 = require("@prezly/theme-kit-core");
|
|
5
6
|
const router_1 = require("next/router");
|
|
6
7
|
const react_1 = require("react");
|
|
7
|
-
const utils_1 = require("../../utils");
|
|
8
8
|
const useCurrentCategory_1 = require("./useCurrentCategory");
|
|
9
9
|
const useCurrentStory_1 = require("./useCurrentStory");
|
|
10
10
|
// Pulled from SDK types to not leak the `@prezly/sdk` dependency into the client bundle
|
|
@@ -37,8 +37,8 @@ function getAllowedTranslationVisibilityValues(story) {
|
|
|
37
37
|
*/
|
|
38
38
|
function getTranslationUrl(locale, path, currentCategory, currentStory, noFallback) {
|
|
39
39
|
if (currentCategory) {
|
|
40
|
-
if ((0,
|
|
41
|
-
return (0,
|
|
40
|
+
if ((0, theme_kit_core_1.getCategoryHasTranslation)(currentCategory, locale)) {
|
|
41
|
+
return (0, theme_kit_core_1.getCategoryUrl)(currentCategory, locale);
|
|
42
42
|
}
|
|
43
43
|
if (noFallback) {
|
|
44
44
|
return '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetTranslationUrl.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useGetTranslationUrl.ts"],"names":[],"mappings":";;;AACA,qCAAoC;
|
|
1
|
+
{"version":3,"file":"useGetTranslationUrl.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useGetTranslationUrl.ts"],"names":[],"mappings":";;;AACA,qCAAoC;AAEpC,2DAAmF;AACnF,wCAAwC;AACxC,iCAAoC;AAEpC,6DAA0D;AAC1D,uDAAoD;AAEpD,wFAAwF;AACxF,wEAAwE;AACxE,IAAK,UAKJ;AALD,WAAK,UAAU;IACX,+BAAiB,CAAA;IACjB,iCAAmB,CAAA;IACnB,iCAAmB,CAAA;IACnB,2CAA6B,CAAA;AACjC,CAAC,EALI,UAAU,KAAV,UAAU,QAKd;AAED,SAAS,qCAAqC,CAAC,KAAoB;IAC/D,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IAE7B,QAAQ,UAAU,EAAE;QAChB,KAAK,UAAU,CAAC,OAAO;YACnB,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;QACnD,KAAK,UAAU,CAAC,OAAO;YACnB,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;QACnD,KAAK,UAAU,CAAC,YAAY;YACxB,OAAO,CAAC,UAAU,CAAC,YAAY,EAAE,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;QAC5E;YACI,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;KAClC;AACL,CAAC;AAED;;;;;GAKG;AACH,SAAS,iBAAiB,CACtB,MAAoB,EACpB,IAAY,EACZ,eAA0B,EAC1B,YAA4B,EAC5B,UAAoB;IAEpB,IAAI,eAAe,EAAE;QACjB,IAAI,IAAA,0CAAyB,EAAC,eAAe,EAAE,MAAM,CAAC,EAAE;YACpD,OAAO,IAAA,+BAAc,EAAC,eAAe,EAAE,MAAM,CAAC,CAAC;SAClD;QAED,IAAI,UAAU,EAAE;YACZ,OAAO,EAAE,CAAC;SACb;QAED,OAAO,GAAG,CAAC;KACd;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAE7C,IAAI,YAAY,IAAI,YAAY,CAAC,OAAO,CAAC,MAAM,KAAK,UAAU,EAAE;QAC5D,MAAM,uBAAuB,GAAG,qCAAqC,CAAC,YAAY,CAAC,CAAC;QAEpF,MAAM,eAAe,GAAG,YAAY,CAAC,YAAY,CAAC,IAAI,CAClD,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,EAAE,EAAE,CAC1C,OAAO,CAAC,MAAM,KAAK,UAAU;YAC7B,WAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC;YACnC,uBAAuB,CAAC,QAAQ,CAAC,UAAU,CAAC,CACnD,CAAC;QACF,IAAI,eAAe,EAAE;YACjB,OAAO,IAAI,eAAe,CAAC,IAAI,EAAE,CAAC;SACrC;QAED,IAAI,UAAU,EAAE;YACZ,OAAO,EAAE,CAAC;SACb;QAED,OAAO,GAAG,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAgB,oBAAoB;IAChC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,kBAAS,GAAE,CAAC;IAC/B,MAAM,eAAe,GAAG,IAAA,uCAAkB,GAAE,CAAC;IAC7C,MAAM,YAAY,GAAG,IAAA,iCAAe,GAAE,CAAC;IAEvC,OAAO,IAAA,mBAAW,EACd,CAAC,MAAoB,EAAE,UAAoB,EAAE,EAAE,CAC3C,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,YAAY,EAAE,UAAU,CAAC,EAChF,CAAC,MAAM,EAAE,eAAe,EAAE,YAAY,CAAC,CAC1C,CAAC;AACN,CAAC;AAVD,oDAUC"}
|
package/build/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { CultureRef, Story } from '@prezly/sdk';
|
|
2
1
|
import type { NewsroomContextProps } from './newsroom-context';
|
|
3
2
|
export interface ServerSidePageProps {
|
|
4
3
|
/**
|
|
@@ -13,31 +12,3 @@ export interface ServerSidePageProps {
|
|
|
13
12
|
export interface PageProps {
|
|
14
13
|
newsroomContextProps: NewsroomContextProps;
|
|
15
14
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Categories in Algolia index are stored in a simplified format, with `slug` and `name` properties already saved in the correct locale for the story search result.
|
|
18
|
-
*/
|
|
19
|
-
export interface AlgoliaCategoryRef {
|
|
20
|
-
id: number;
|
|
21
|
-
name: string;
|
|
22
|
-
slug: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Stories in Algolia index are stored in a simplified format, with only minimal subset of fields.
|
|
26
|
-
*/
|
|
27
|
-
export type AlgoliaStory = Pick<Story, 'uuid' | 'slug' | 'title' | 'subtitle'> & Pick<Story.ExtraFields, 'thumbnail_image'> & {
|
|
28
|
-
content_text: string;
|
|
29
|
-
updated_at: number;
|
|
30
|
-
published_at: number;
|
|
31
|
-
culture: Pick<CultureRef, 'code' | 'name' | 'native_name' | 'language_code'>;
|
|
32
|
-
categories: AlgoliaCategoryRef[];
|
|
33
|
-
};
|
|
34
|
-
export interface SdkError extends Error {
|
|
35
|
-
status: number;
|
|
36
|
-
statusText: string;
|
|
37
|
-
payload: {
|
|
38
|
-
errors: {
|
|
39
|
-
reason: string;
|
|
40
|
-
};
|
|
41
|
-
message: string;
|
|
42
|
-
};
|
|
43
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prezly/theme-kit-nextjs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.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",
|
|
@@ -18,43 +18,45 @@
|
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/prezly/theme-kit-
|
|
21
|
+
"url": "git+https://github.com/prezly/theme-kit-js.git",
|
|
22
|
+
"directory": "packages/nextjs"
|
|
22
23
|
},
|
|
23
|
-
"keywords": [
|
|
24
|
-
|
|
24
|
+
"keywords": [
|
|
25
|
+
"prezly",
|
|
26
|
+
"nextjs"
|
|
27
|
+
],
|
|
28
|
+
"author": "Prezly Team",
|
|
25
29
|
"license": "MIT",
|
|
26
30
|
"bugs": {
|
|
27
|
-
"url": "https://github.com/prezly/theme-kit-
|
|
31
|
+
"url": "https://github.com/prezly/theme-kit-js/issues"
|
|
28
32
|
},
|
|
29
|
-
"homepage": "https://github.com/prezly/theme-kit-nextjs#readme",
|
|
33
|
+
"homepage": "https://github.com/prezly/theme-kit-js/tree/main/packages/nextjs#readme",
|
|
30
34
|
"scripts": {
|
|
31
|
-
"
|
|
35
|
+
"prebuild": "rimraf build/* *.tsbuildinfo",
|
|
32
36
|
"build": "tsc --project .",
|
|
33
|
-
"
|
|
37
|
+
"dev": "tsc --watch --preserveWatchOutput --project .",
|
|
34
38
|
"typecheck": "tsc --noEmit --incremental --project .",
|
|
35
39
|
"lint": "eslint src",
|
|
36
40
|
"test": "jest"
|
|
37
41
|
},
|
|
38
42
|
"peerDependencies": {
|
|
43
|
+
"@prezly/theme-kit-core": "*",
|
|
39
44
|
"next": "^12.x || ^13.x",
|
|
40
45
|
"react": "^17.x || ^18.x",
|
|
41
46
|
"react-dom": "^17.x || ^18.x"
|
|
42
47
|
},
|
|
43
48
|
"dependencies": {
|
|
44
49
|
"@prezly/sdk": "^11.11.0",
|
|
45
|
-
"@prezly/uploadcare": "^2.3.4",
|
|
46
50
|
"@react-hookz/web": "^16.0.0",
|
|
47
|
-
"next-seo": "^5.4.0"
|
|
48
|
-
"parse-data-url": "^4.0.1"
|
|
51
|
+
"next-seo": "^5.4.0"
|
|
49
52
|
},
|
|
50
53
|
"devDependencies": {
|
|
51
54
|
"@sentry/nextjs": "7.45.0",
|
|
52
|
-
"@types/parse-data-url": "3.0.0",
|
|
53
55
|
"rimraf": "3.0.2"
|
|
54
56
|
},
|
|
55
57
|
"publishConfig": {
|
|
56
58
|
"access": "public"
|
|
57
59
|
},
|
|
58
60
|
"sideEffects": false,
|
|
59
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "bada4e4ca15d085f19101ac4aa5ecdc7a02c2ab6"
|
|
60
62
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { getNextPrezlyApi } from '../../data-fetching';
|
|
4
4
|
|
|
5
5
|
export async function fetchGalleries(req: NextApiRequest, res: NextApiResponse) {
|
|
6
6
|
if (req.method !== 'POST') {
|
|
@@ -11,7 +11,7 @@ export async function fetchGalleries(req: NextApiRequest, res: NextApiResponse)
|
|
|
11
11
|
const { page, pageSize } = req.body;
|
|
12
12
|
|
|
13
13
|
try {
|
|
14
|
-
const api =
|
|
14
|
+
const api = getNextPrezlyApi(req);
|
|
15
15
|
|
|
16
16
|
const { galleries } = await api.getGalleries({ page, pageSize });
|
|
17
17
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { getNextPrezlyApi } from '../../data-fetching';
|
|
4
4
|
|
|
5
5
|
export async function fetchStories(req: NextApiRequest, res: NextApiResponse) {
|
|
6
6
|
if (req.method !== 'POST') {
|
|
@@ -12,7 +12,7 @@ export async function fetchStories(req: NextApiRequest, res: NextApiResponse) {
|
|
|
12
12
|
req.body;
|
|
13
13
|
|
|
14
14
|
try {
|
|
15
|
-
const api =
|
|
15
|
+
const api = getNextPrezlyApi(req);
|
|
16
16
|
|
|
17
17
|
const { stories } = await (category
|
|
18
18
|
? api.getStoriesFromCategory(category, { page, pageSize, include, localeCode })
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Story } from '@prezly/sdk';
|
|
2
2
|
import type { GetServerSidePropsContext } from 'next';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { getNextPrezlyApi } from '../data-fetching';
|
|
5
5
|
|
|
6
6
|
interface Options {
|
|
7
7
|
loadHomepageContacts?: boolean;
|
|
@@ -18,7 +18,7 @@ export async function getNewsroomServerSideProps(
|
|
|
18
18
|
) {
|
|
19
19
|
const { req: request, locale } = context;
|
|
20
20
|
|
|
21
|
-
const api =
|
|
21
|
+
const api = getNextPrezlyApi(request);
|
|
22
22
|
const serverSideProps = await api.getNewsroomServerSideProps(request, locale, options.story);
|
|
23
23
|
|
|
24
24
|
if (options.loadHomepageContacts) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Story } from '@prezly/sdk';
|
|
2
2
|
import type { GetStaticPropsContext } from 'next';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { getNextPrezlyApi } from '../data-fetching';
|
|
5
5
|
|
|
6
6
|
interface Options {
|
|
7
7
|
loadHomepageContacts?: boolean;
|
|
@@ -18,7 +18,7 @@ export async function getNewsroomStaticProps(
|
|
|
18
18
|
) {
|
|
19
19
|
const { locale } = context;
|
|
20
20
|
|
|
21
|
-
const api =
|
|
21
|
+
const api = getNextPrezlyApi();
|
|
22
22
|
const staticProps = await api.getNewsroomServerSideProps(undefined, locale, options.story);
|
|
23
23
|
|
|
24
24
|
if (options.loadHomepageContacts) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Story } from '@prezly/sdk';
|
|
2
|
+
import { DEFAULT_PAGE_SIZE, getLocalizedCategoryData, LocaleObject } from '@prezly/theme-kit-core';
|
|
2
3
|
import type {
|
|
3
4
|
GetServerSidePropsContext,
|
|
4
5
|
GetServerSidePropsResult,
|
|
@@ -7,10 +8,8 @@ import type {
|
|
|
7
8
|
GetStaticPropsResult,
|
|
8
9
|
} from 'next';
|
|
9
10
|
|
|
10
|
-
import {
|
|
11
|
+
import { getNextPrezlyApi } from '../../data-fetching';
|
|
11
12
|
import type { PaginationProps } from '../../infinite-loading/types';
|
|
12
|
-
import { LocaleObject } from '../../intl';
|
|
13
|
-
import { DEFAULT_PAGE_SIZE, getLocalizedCategoryData } from '../../utils';
|
|
14
13
|
import { getNewsroomServerSideProps } from '../getNewsroomServerSideProps';
|
|
15
14
|
import { getNewsroomStaticProps } from '../getNewsroomStaticProps';
|
|
16
15
|
import { processRequest } from '../processRequest';
|
|
@@ -132,7 +131,7 @@ export function getCategoryPageStaticProps<
|
|
|
132
131
|
}
|
|
133
132
|
|
|
134
133
|
export async function getCategoryPageStaticPaths(): Promise<GetStaticPathsResult> {
|
|
135
|
-
const api =
|
|
134
|
+
const api = getNextPrezlyApi();
|
|
136
135
|
const [categories, defaultLanguage] = await Promise.all([
|
|
137
136
|
api.getCategories(),
|
|
138
137
|
api.getNewsroomDefaultLanguage(),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { NewsroomGallery } from '@prezly/sdk';
|
|
2
|
+
import { DEFAULT_GALLERY_PAGE_SIZE } from '@prezly/theme-kit-core';
|
|
2
3
|
import type {
|
|
3
4
|
GetServerSidePropsContext,
|
|
4
5
|
GetServerSidePropsResult,
|
|
@@ -7,7 +8,6 @@ import type {
|
|
|
7
8
|
} from 'next';
|
|
8
9
|
|
|
9
10
|
import type { PaginationProps } from '../../infinite-loading/types';
|
|
10
|
-
import { DEFAULT_GALLERY_PAGE_SIZE } from '../../utils';
|
|
11
11
|
import { getNewsroomServerSideProps } from '../getNewsroomServerSideProps';
|
|
12
12
|
import { getNewsroomStaticProps } from '../getNewsroomStaticProps';
|
|
13
13
|
import { processRequest } from '../processRequest';
|
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
GetStaticPropsResult,
|
|
8
8
|
} from 'next';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { getNextPrezlyApi } from '../../data-fetching';
|
|
11
11
|
import { getNewsroomServerSideProps } from '../getNewsroomServerSideProps';
|
|
12
12
|
import { getNewsroomStaticProps } from '../getNewsroomStaticProps';
|
|
13
13
|
import { processRequest } from '../processRequest';
|
|
@@ -77,7 +77,7 @@ export function getGalleryAlbumPageStaticProps<CustomProps extends Record<string
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
export async function getGalleryAlbumPageStaticPaths(): Promise<GetStaticPathsResult> {
|
|
80
|
-
const api =
|
|
80
|
+
const api = getNextPrezlyApi();
|
|
81
81
|
const { galleries } = await api.getGalleries({});
|
|
82
82
|
|
|
83
83
|
const paths = galleries.map(({ uuid }) => ({ params: { uuid } }));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Story } from '@prezly/sdk';
|
|
2
|
+
import { DEFAULT_PAGE_SIZE } from '@prezly/theme-kit-core';
|
|
2
3
|
import type {
|
|
3
4
|
GetServerSidePropsContext,
|
|
4
5
|
GetServerSidePropsResult,
|
|
@@ -7,7 +8,6 @@ import type {
|
|
|
7
8
|
} from 'next';
|
|
8
9
|
|
|
9
10
|
import type { PaginationProps } from '../../infinite-loading/types';
|
|
10
|
-
import { DEFAULT_PAGE_SIZE } from '../../utils';
|
|
11
11
|
import { getNewsroomServerSideProps } from '../getNewsroomServerSideProps';
|
|
12
12
|
import { getNewsroomStaticProps } from '../getNewsroomStaticProps';
|
|
13
13
|
import { processRequest } from '../processRequest';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NextPageContext } from 'next';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { getNextPrezlyApi } from '../../../data-fetching';
|
|
4
4
|
|
|
5
5
|
import { createPaths } from './createPaths';
|
|
6
6
|
import { SitemapBuilder } from './SitemapBuilder';
|
|
@@ -20,7 +20,7 @@ export function getSitemapServerSideProps(
|
|
|
20
20
|
|
|
21
21
|
const baseUrl = req.headers.host || '/';
|
|
22
22
|
|
|
23
|
-
const api =
|
|
23
|
+
const api = getNextPrezlyApi(req);
|
|
24
24
|
const stories = await api.getAllStories({
|
|
25
25
|
pinning: options.pinning ?? false,
|
|
26
26
|
});
|
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
GetStaticPropsResult,
|
|
6
6
|
} from 'next';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { getNextPrezlyApi } from '../../data-fetching';
|
|
9
9
|
import { DUMMY_DEFAULT_LOCALE } from '../../intl';
|
|
10
10
|
import { getNewsroomServerSideProps } from '../getNewsroomServerSideProps';
|
|
11
11
|
import { getNewsroomStaticProps } from '../getNewsroomStaticProps';
|
|
@@ -20,7 +20,7 @@ export function getStoryPageServerSideProps<CustomProps extends Record<string, a
|
|
|
20
20
|
return async function getServerSideProps(
|
|
21
21
|
context: GetServerSidePropsContext,
|
|
22
22
|
): Promise<GetServerSidePropsResult<CustomProps>> {
|
|
23
|
-
const api =
|
|
23
|
+
const api = getNextPrezlyApi(context.req);
|
|
24
24
|
|
|
25
25
|
const { slug } = context.params as { slug?: string };
|
|
26
26
|
const story = slug ? await api.getStoryBySlug(slug) : null;
|
|
@@ -57,7 +57,7 @@ export function getStoryPageStaticProps<CustomProps extends Record<string, any>>
|
|
|
57
57
|
return async function getStaticProps(
|
|
58
58
|
context: GetStaticPropsContext,
|
|
59
59
|
): Promise<GetStaticPropsResult<CustomProps>> {
|
|
60
|
-
const api =
|
|
60
|
+
const api = getNextPrezlyApi();
|
|
61
61
|
|
|
62
62
|
const { slug } = context.params as { slug?: string };
|
|
63
63
|
const story = slug ? await api.getStoryBySlug(slug) : null;
|
|
@@ -82,7 +82,7 @@ export function getStoryPageStaticProps<CustomProps extends Record<string, any>>
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
export async function getStoryPageStaticPaths(options: { pinning?: boolean } = {}) {
|
|
85
|
-
const api =
|
|
85
|
+
const api = getNextPrezlyApi();
|
|
86
86
|
const stories = await api.getAllStories({
|
|
87
87
|
pinning: options.pinning ?? false,
|
|
88
88
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { GetServerSidePropsContext, GetServerSidePropsResult } from 'next';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { getNextPrezlyApi } from '../../data-fetching';
|
|
4
4
|
import { getNewsroomServerSideProps } from '../getNewsroomServerSideProps';
|
|
5
5
|
import { processRequest } from '../processRequest';
|
|
6
6
|
|
|
@@ -12,7 +12,7 @@ export function getStoryPreviewPageServerSideProps<CustomProps extends Record<st
|
|
|
12
12
|
return async function getServerSideProps(
|
|
13
13
|
context: GetServerSidePropsContext,
|
|
14
14
|
): Promise<GetServerSidePropsResult<CustomProps>> {
|
|
15
|
-
const api =
|
|
15
|
+
const api = getNextPrezlyApi(context.req);
|
|
16
16
|
const { uuid } = context.params as { uuid: string };
|
|
17
17
|
const story = await api.getStory(uuid);
|
|
18
18
|
if (!story) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { getShortestLocaleCode, LocaleObject } from '@prezly/theme-kit-core';
|
|
1
2
|
import type { GetServerSidePropsContext, GetServerSidePropsResult } from 'next';
|
|
2
3
|
|
|
3
|
-
import { getRedirectToCanonicalLocale
|
|
4
|
+
import { getRedirectToCanonicalLocale } from '../intl';
|
|
4
5
|
import type { PageProps, ServerSidePageProps } from '../types';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getAlternateLanguageLinks,
|
|
3
|
+
getNewsroomLogoUrl,
|
|
4
|
+
getUsedLanguages,
|
|
5
|
+
} from '@prezly/theme-kit-core';
|
|
6
|
+
import type { AlternateLanguageLink } from '@prezly/theme-kit-core';
|
|
1
7
|
import { NextSeo } from 'next-seo';
|
|
2
8
|
import type { NextSeoProps } from 'next-seo';
|
|
3
9
|
import { useRouter } from 'next/router';
|
|
4
10
|
import { useMemo } from 'react';
|
|
5
11
|
|
|
6
|
-
import { getUsedLanguages } from '../../intl';
|
|
7
12
|
import {
|
|
8
13
|
useCompanyInformation,
|
|
9
14
|
useCurrentLocale,
|
|
@@ -13,11 +18,8 @@ import {
|
|
|
13
18
|
useLanguages,
|
|
14
19
|
useNewsroom,
|
|
15
20
|
} from '../../newsroom-context';
|
|
16
|
-
import { getAlternateLanguageLinks } from '../../seo';
|
|
17
|
-
import { getNewsroomLogoUrl } from '../../utils';
|
|
18
21
|
|
|
19
|
-
import { getAbsoluteUrl } from './lib
|
|
20
|
-
import type { AlternateLanguageLink } from './lib/types';
|
|
22
|
+
import { getAbsoluteUrl } from './lib';
|
|
21
23
|
|
|
22
24
|
type Props = NextSeoProps & {
|
|
23
25
|
imageUrl?: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getAbsoluteUrl } from './getAbsoluteUrl';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { DEFAULT_LOCALE, getLocaleDirection, LocaleObject } from '@prezly/theme-kit-core';
|
|
1
2
|
import Document, { Head, Html, Main, NextScript } from 'next/document';
|
|
2
3
|
|
|
3
|
-
import { DEFAULT_LOCALE, getLocaleDirection, LocaleObject } from '../intl';
|
|
4
4
|
import type { PageProps } from '../types';
|
|
5
5
|
|
|
6
6
|
export class PrezlyThemeDocument extends Document {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Story } from '@prezly/sdk';
|
|
2
|
+
import {
|
|
3
|
+
getAlgoliaSettings,
|
|
4
|
+
getCompanyInformation,
|
|
5
|
+
getDefaultLanguage,
|
|
6
|
+
getLanguageFromStory,
|
|
7
|
+
getNotifications,
|
|
8
|
+
LocaleObject,
|
|
9
|
+
PrezlyApi,
|
|
10
|
+
} from '@prezly/theme-kit-core';
|
|
11
|
+
import type { IncomingMessage } from 'http';
|
|
12
|
+
|
|
13
|
+
import { getLanguageFromNextLocaleIsoCode } from '../intl';
|
|
14
|
+
import type { PageProps, ServerSidePageProps } from '../types';
|
|
15
|
+
|
|
16
|
+
export class NextPrezlyApi extends PrezlyApi {
|
|
17
|
+
async getNewsroomServerSideProps(
|
|
18
|
+
request?: IncomingMessage,
|
|
19
|
+
nextLocaleIsoCode?: string,
|
|
20
|
+
story?: Story,
|
|
21
|
+
): Promise<PageProps & ServerSidePageProps> {
|
|
22
|
+
const [newsroom, languages, categories, themePreset] = await Promise.all([
|
|
23
|
+
this.getNewsroom(),
|
|
24
|
+
this.getNewsroomLanguages(),
|
|
25
|
+
this.getCategories(),
|
|
26
|
+
this.getThemePreset(),
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
const currentLanguage = story
|
|
30
|
+
? getLanguageFromStory(languages, story)
|
|
31
|
+
: getLanguageFromNextLocaleIsoCode(languages, nextLocaleIsoCode);
|
|
32
|
+
const defaultLanguage = getDefaultLanguage(languages);
|
|
33
|
+
|
|
34
|
+
const { code: localeCode } = currentLanguage || defaultLanguage;
|
|
35
|
+
const locale = LocaleObject.fromAnyCode(localeCode);
|
|
36
|
+
|
|
37
|
+
// TODO: if no information given for current language, show boilerplate from default language
|
|
38
|
+
const companyInformation = getCompanyInformation(languages, locale);
|
|
39
|
+
|
|
40
|
+
const notifications = getNotifications(languages, locale);
|
|
41
|
+
const algoliaSettings = getAlgoliaSettings(request);
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
newsroomContextProps: {
|
|
45
|
+
newsroom,
|
|
46
|
+
companyInformation,
|
|
47
|
+
categories,
|
|
48
|
+
languages,
|
|
49
|
+
localeCode,
|
|
50
|
+
notifications,
|
|
51
|
+
themePreset,
|
|
52
|
+
algoliaSettings,
|
|
53
|
+
},
|
|
54
|
+
localeResolved: Boolean(currentLanguage),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import { getEnvVariables } from '@prezly/theme-kit-core';
|
|
1
2
|
import type { IncomingMessage } from 'http';
|
|
2
3
|
|
|
3
|
-
import {
|
|
4
|
+
import { NextPrezlyApi } from './NextPrezlyApi';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export function getPrezlyApi(req?: IncomingMessage): PrezlyApi {
|
|
6
|
+
export function getNextPrezlyApi(req?: IncomingMessage): NextPrezlyApi {
|
|
8
7
|
if (typeof window !== 'undefined') {
|
|
9
|
-
throw new Error('"
|
|
8
|
+
throw new Error('"getNextPrezlyApi" should only be used on back-end side.');
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
// `getEnvVariables` handles both cases for envs parsing - .env and request headers
|
|
@@ -20,5 +19,5 @@ export function getPrezlyApi(req?: IncomingMessage): PrezlyApi {
|
|
|
20
19
|
throw new Error('"PREZLY_NEWSROOM_UUID" is not set in env variables.');
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
return new
|
|
22
|
+
return new NextPrezlyApi(PREZLY_ACCESS_TOKEN, PREZLY_NEWSROOM_UUID, PREZLY_THEME_UUID);
|
|
24
23
|
}
|
package/src/index.ts
CHANGED
|
@@ -2,8 +2,6 @@ export * from './adapter-nextjs';
|
|
|
2
2
|
export * from './components-nextjs';
|
|
3
3
|
export * from './data-fetching';
|
|
4
4
|
export * from './infinite-loading';
|
|
5
|
-
export * from './intl';
|
|
6
5
|
export * from './newsroom-context';
|
|
7
6
|
export * from './sentry';
|
|
8
7
|
export * from './types';
|
|
9
|
-
export * from './utils';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Category, Story } from '@prezly/sdk';
|
|
2
|
+
import type { LocaleObject } from '@prezly/theme-kit-core';
|
|
2
3
|
import { useEffect } from 'react';
|
|
3
4
|
|
|
4
|
-
import type { LocaleObject } from '../intl';
|
|
5
5
|
import { useCurrentLocale } from '../newsroom-context';
|
|
6
6
|
|
|
7
7
|
import type { PaginationProps } from './types';
|