@prezly/theme-kit-nextjs 1.6.3 → 1.6.4-2
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 +30 -0
- package/build/adapter-nextjs/getNewsroomServerSideProps.js +9 -63
- package/build/adapter-nextjs/getNewsroomServerSideProps.js.map +1 -1
- package/build/adapter-nextjs/index.js +2 -14
- package/build/adapter-nextjs/index.js.map +1 -1
- package/build/adapter-nextjs/processRequest.js +10 -25
- package/build/adapter-nextjs/processRequest.js.map +1 -1
- package/build/components-nextjs/PageSeo/PageSeo.d.ts +12 -0
- package/build/components-nextjs/PageSeo/PageSeo.js +74 -0
- package/build/components-nextjs/PageSeo/PageSeo.js.map +1 -0
- package/build/components-nextjs/PageSeo/index.d.ts +2 -0
- package/build/components-nextjs/PageSeo/index.js +3 -0
- package/build/components-nextjs/PageSeo/index.js.map +1 -0
- package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.d.ts +1 -0
- package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js +7 -0
- package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js.map +1 -0
- package/build/components-nextjs/PageSeo/lib/types.d.ts +4 -0
- package/build/components-nextjs/PageSeo/lib/types.js +2 -0
- package/build/components-nextjs/PageSeo/lib/types.js.map +1 -0
- package/build/components-nextjs/Sitemap/SitemapBuilder.d.ts +11 -0
- package/build/components-nextjs/Sitemap/SitemapBuilder.js +47 -0
- package/build/components-nextjs/Sitemap/SitemapBuilder.js.map +1 -0
- package/build/components-nextjs/Sitemap/createPaths.d.ts +2 -0
- package/build/components-nextjs/Sitemap/createPaths.js +15 -0
- package/build/components-nextjs/Sitemap/createPaths.js.map +1 -0
- package/build/components-nextjs/Sitemap/getInitialProps.d.ts +2 -0
- package/build/components-nextjs/Sitemap/getInitialProps.js +26 -0
- package/build/components-nextjs/Sitemap/getInitialProps.js.map +1 -0
- package/build/components-nextjs/Sitemap/index.d.ts +4 -0
- package/build/components-nextjs/Sitemap/index.js +5 -0
- package/build/components-nextjs/Sitemap/index.js.map +1 -0
- package/build/components-nextjs/Sitemap/types.d.ts +5 -0
- package/build/components-nextjs/Sitemap/types.js +2 -0
- package/build/components-nextjs/Sitemap/types.js.map +1 -0
- package/build/components-nextjs/StorySeo/StorySeo.d.ts +11 -0
- package/build/components-nextjs/StorySeo/StorySeo.js +39 -0
- package/build/components-nextjs/StorySeo/StorySeo.js.map +1 -0
- package/build/components-nextjs/StorySeo/index.d.ts +1 -0
- package/build/components-nextjs/StorySeo/index.js +2 -0
- package/build/components-nextjs/StorySeo/index.js.map +1 -0
- package/build/components-nextjs/index.d.ts +3 -0
- package/build/components-nextjs/index.js +4 -0
- package/build/components-nextjs/index.js.map +1 -0
- package/build/data-fetching/api/PrezlyApi.js +132 -297
- package/build/data-fetching/api/PrezlyApi.js.map +1 -1
- package/build/data-fetching/api/getPrezlyApi.js +5 -9
- package/build/data-fetching/api/getPrezlyApi.js.map +1 -1
- package/build/data-fetching/api/index.js +2 -14
- package/build/data-fetching/api/index.js.map +1 -1
- package/build/data-fetching/api/languages.js +43 -85
- package/build/data-fetching/api/languages.js.map +1 -1
- package/build/data-fetching/api/queries.js +13 -45
- package/build/data-fetching/api/queries.js.map +1 -1
- package/build/data-fetching/constants.js +2 -5
- package/build/data-fetching/constants.js.map +1 -1
- package/build/data-fetching/getAssetsUrl.js +3 -7
- package/build/data-fetching/getAssetsUrl.js.map +1 -1
- package/build/data-fetching/getLocalizedCategoryData.js +15 -32
- package/build/data-fetching/getLocalizedCategoryData.js.map +1 -1
- package/build/data-fetching/getNewsroomLogoUrl.js +6 -12
- package/build/data-fetching/getNewsroomLogoUrl.js.map +1 -1
- package/build/data-fetching/getPrivacyPortalUrl.js +3 -7
- package/build/data-fetching/getPrivacyPortalUrl.js.map +1 -1
- package/build/data-fetching/getStoryPublicationDate.js +2 -6
- package/build/data-fetching/getStoryPublicationDate.js.map +1 -1
- package/build/data-fetching/getUploadcareGroupUrl.js +3 -7
- package/build/data-fetching/getUploadcareGroupUrl.js.map +1 -1
- package/build/data-fetching/index.js +10 -22
- package/build/data-fetching/index.js.map +1 -1
- package/build/data-fetching/lib/getAlgoliaSettings.js +6 -10
- package/build/data-fetching/lib/getAlgoliaSettings.js.map +1 -1
- package/build/data-fetching/lib/getEnvVariables.js +11 -29
- package/build/data-fetching/lib/getEnvVariables.js.map +1 -1
- package/build/data-fetching/lib/index.js +1 -5
- package/build/data-fetching/lib/index.js.map +1 -1
- package/build/data-fetching/types.js +1 -2
- package/build/index.d.ts +2 -0
- package/build/index.js +7 -17
- package/build/index.js.map +1 -1
- package/build/infinite-loading/apiHandlers/fetchGalleries.d.ts +2 -0
- package/build/infinite-loading/apiHandlers/fetchGalleries.js +19 -0
- package/build/infinite-loading/apiHandlers/fetchGalleries.js.map +1 -0
- package/build/infinite-loading/apiHandlers/fetchStories.d.ts +2 -0
- package/build/infinite-loading/apiHandlers/fetchStories.js +21 -0
- package/build/infinite-loading/apiHandlers/fetchStories.js.map +1 -0
- package/build/infinite-loading/apiHandlers/index.d.ts +2 -0
- package/build/infinite-loading/apiHandlers/index.js +3 -0
- package/build/infinite-loading/apiHandlers/index.js.map +1 -0
- package/build/infinite-loading/index.d.ts +5 -0
- package/build/infinite-loading/index.js +6 -0
- package/build/infinite-loading/index.js.map +1 -0
- package/build/infinite-loading/types.d.ts +5 -0
- package/build/infinite-loading/types.js +2 -0
- package/build/infinite-loading/types.js.map +1 -0
- package/build/infinite-loading/useInfiniteGalleriesLoading.d.ts +13 -0
- package/build/infinite-loading/useInfiniteGalleriesLoading.js +40 -0
- package/build/infinite-loading/useInfiniteGalleriesLoading.js.map +1 -0
- package/build/infinite-loading/useInfiniteLoading.d.ts +16 -0
- package/build/infinite-loading/useInfiniteLoading.js +39 -0
- package/build/infinite-loading/useInfiniteLoading.js.map +1 -0
- package/build/infinite-loading/useInfiniteStoriesLoading.d.ts +13 -0
- package/build/infinite-loading/useInfiniteStoriesLoading.js +53 -0
- package/build/infinite-loading/useInfiniteStoriesLoading.js.map +1 -0
- package/build/intl/index.d.ts +2 -1
- package/build/intl/index.js +5 -21
- package/build/intl/index.js.map +1 -1
- package/build/intl/lang.js +4 -11
- package/build/intl/lang.js.map +1 -1
- package/build/intl/locale.js +21 -27
- package/build/intl/locale.js.map +1 -1
- package/build/intl/localeConfig.d.ts +1 -2
- package/build/intl/localeConfig.js +8 -30
- package/build/intl/localeConfig.js.map +1 -1
- package/build/intl/localeList.d.ts +4 -56
- package/build/intl/localeList.js +1 -2
- package/build/intl/localeList.js.map +1 -1
- package/build/intl/localeObject.js +30 -49
- package/build/intl/localeObject.js.map +1 -1
- package/build/newsroom-context/context.js +18 -34
- package/build/newsroom-context/context.js.map +1 -1
- package/build/newsroom-context/hooks/index.js +11 -23
- package/build/newsroom-context/hooks/index.js.map +1 -1
- package/build/newsroom-context/hooks/useAlgoliaSettings.js +3 -7
- package/build/newsroom-context/hooks/useAlgoliaSettings.js.map +1 -1
- package/build/newsroom-context/hooks/useCategories.js +3 -7
- package/build/newsroom-context/hooks/useCategories.js.map +1 -1
- package/build/newsroom-context/hooks/useCompanyInformation.js +3 -7
- package/build/newsroom-context/hooks/useCompanyInformation.js.map +1 -1
- package/build/newsroom-context/hooks/useCurrentCategory.js +3 -7
- package/build/newsroom-context/hooks/useCurrentCategory.js.map +1 -1
- package/build/newsroom-context/hooks/useCurrentLocale.js +3 -7
- package/build/newsroom-context/hooks/useCurrentLocale.js.map +1 -1
- package/build/newsroom-context/hooks/useCurrentStory.js +3 -7
- package/build/newsroom-context/hooks/useCurrentStory.js.map +1 -1
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js +11 -15
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js.map +1 -1
- package/build/newsroom-context/hooks/useGetTranslationUrl.js +15 -24
- package/build/newsroom-context/hooks/useGetTranslationUrl.js.map +1 -1
- package/build/newsroom-context/hooks/useLanguages.js +3 -7
- package/build/newsroom-context/hooks/useLanguages.js.map +1 -1
- package/build/newsroom-context/hooks/useNewsroom.js +3 -7
- package/build/newsroom-context/hooks/useNewsroom.js.map +1 -1
- package/build/newsroom-context/hooks/useNewsroomContext.js +4 -8
- package/build/newsroom-context/hooks/useNewsroomContext.js.map +1 -1
- package/build/newsroom-context/index.js +2 -17
- package/build/newsroom-context/index.js.map +1 -1
- package/build/types.js +1 -2
- package/package.json +6 -3
- package/src/components-nextjs/PageSeo/PageSeo.tsx +123 -0
- package/src/components-nextjs/PageSeo/index.ts +2 -0
- package/src/components-nextjs/PageSeo/lib/getAbsoluteUrl.ts +7 -0
- package/src/components-nextjs/PageSeo/lib/types.ts +4 -0
- package/src/components-nextjs/Sitemap/SitemapBuilder.ts +56 -0
- package/src/components-nextjs/Sitemap/createPaths.ts +21 -0
- package/src/components-nextjs/Sitemap/getInitialProps.ts +37 -0
- package/src/components-nextjs/Sitemap/index.ts +5 -0
- package/src/components-nextjs/Sitemap/types.ts +5 -0
- package/src/components-nextjs/StorySeo/StorySeo.tsx +68 -0
- package/src/components-nextjs/StorySeo/index.ts +1 -0
- package/src/components-nextjs/index.ts +3 -0
- package/src/index.ts +2 -0
- package/src/infinite-loading/apiHandlers/fetchGalleries.ts +24 -0
- package/src/infinite-loading/apiHandlers/fetchStories.ts +26 -0
- package/src/infinite-loading/apiHandlers/index.ts +2 -0
- package/src/infinite-loading/index.ts +5 -0
- package/src/infinite-loading/types.ts +5 -0
- package/src/infinite-loading/useInfiniteGalleriesLoading.ts +53 -0
- package/src/infinite-loading/useInfiniteLoading.ts +66 -0
- package/src/infinite-loading/useInfiniteStoriesLoading.ts +81 -0
- package/src/intl/index.ts +2 -1
- package/src/intl/{localeConfig.js → localeConfig.ts} +3 -3
- package/src/intl/{localeList.js → localeList.ts} +1 -1
- package/src/intl/localeObject.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrentStory.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useCurrentStory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCurrentStory.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useCurrentStory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,UAAU,eAAe;IAC3B,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IAErC,OAAO,OAAO,CAAC,YAAY,CAAC;AAChC,CAAC"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var intl_1 = require("../../intl");
|
|
7
|
-
var useCurrentLocale_1 = require("./useCurrentLocale");
|
|
8
|
-
var useLanguages_1 = require("./useLanguages");
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { getShortestLocaleCode } from '../../data-fetching';
|
|
3
|
+
import { LocaleObject } from '../../intl';
|
|
4
|
+
import { useCurrentLocale } from './useCurrentLocale';
|
|
5
|
+
import { useLanguages } from './useLanguages';
|
|
9
6
|
/**
|
|
10
7
|
* Determines correct locale slug for the link (trying to shorten the locale code if possible).
|
|
11
8
|
* E.g. if newsroom has a single locale for Dutch (`nl_BE`), it will be shortened to `nl`.
|
|
@@ -13,18 +10,17 @@ var useLanguages_1 = require("./useLanguages");
|
|
|
13
10
|
* `false` means that a default locale should be used (no locale in URL required).
|
|
14
11
|
*/
|
|
15
12
|
function getLinkLocaleSlug(languages, locale) {
|
|
16
|
-
|
|
13
|
+
const shortestLocaleCode = getShortestLocaleCode(languages, locale);
|
|
17
14
|
// When navigating to default language, we don't append the locale to the URL.
|
|
18
15
|
if (!shortestLocaleCode) {
|
|
19
16
|
return shortestLocaleCode;
|
|
20
17
|
}
|
|
21
|
-
return
|
|
18
|
+
return LocaleObject.fromAnyCode(shortestLocaleCode).toUrlSlug();
|
|
22
19
|
}
|
|
23
|
-
function useGetLinkLocaleSlug() {
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
export function useGetLinkLocaleSlug() {
|
|
21
|
+
const currentLocale = useCurrentLocale();
|
|
22
|
+
const languages = useLanguages();
|
|
26
23
|
// The `locale` parameter is mainly used for Language Dropdown
|
|
27
|
-
return
|
|
24
|
+
return useCallback((locale) => getLinkLocaleSlug(languages, locale || currentLocale), [languages, currentLocale]);
|
|
28
25
|
}
|
|
29
|
-
exports.useGetLinkLocaleSlug = useGetLinkLocaleSlug;
|
|
30
26
|
//# sourceMappingURL=useGetLinkLocaleSlug.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetLinkLocaleSlug.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useGetLinkLocaleSlug.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useGetLinkLocaleSlug.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useGetLinkLocaleSlug.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;;GAKG;AACH,SAAS,iBAAiB,CACtB,SAAqC,EACrC,MAAoB;IAEpB,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACpE,8EAA8E;IAC9E,IAAI,CAAC,kBAAkB,EAAE;QACrB,OAAO,kBAAkB,CAAC;KAC7B;IAED,OAAO,YAAY,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,SAAS,EAAE,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,oBAAoB;IAChC,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;IACzC,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IAEjC,8DAA8D;IAC9D,OAAO,WAAW,CACd,CAAC,MAAqB,EAAE,EAAE,CAAC,iBAAiB,CAAC,SAAS,EAAE,MAAM,IAAI,aAAa,CAAC,EAChF,CAAC,SAAS,EAAE,aAAa,CAAC,CAC7B,CAAC;AACN,CAAC"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var data_fetching_1 = require("../../data-fetching");
|
|
7
|
-
var useCurrentCategory_1 = require("./useCurrentCategory");
|
|
8
|
-
var useCurrentStory_1 = require("./useCurrentStory");
|
|
1
|
+
import { useRouter } from 'next/router';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { getCategoryHasTranslation, getCategoryUrl } from '../../data-fetching';
|
|
4
|
+
import { useCurrentCategory } from './useCurrentCategory';
|
|
5
|
+
import { useCurrentStory } from './useCurrentStory';
|
|
9
6
|
/**
|
|
10
7
|
* Determine correct URL for translated stories/categories with a fallback to homepage.
|
|
11
8
|
* E.g. if a story has a translation, the function will return the localized slug URL.
|
|
@@ -14,22 +11,19 @@ var useCurrentStory_1 = require("./useCurrentStory");
|
|
|
14
11
|
*/
|
|
15
12
|
function getTranslationUrl(locale, path, currentCategory, currentStory, noFallback) {
|
|
16
13
|
if (currentCategory) {
|
|
17
|
-
if (
|
|
18
|
-
return
|
|
14
|
+
if (getCategoryHasTranslation(currentCategory, locale)) {
|
|
15
|
+
return getCategoryUrl(currentCategory, locale);
|
|
19
16
|
}
|
|
20
17
|
if (noFallback) {
|
|
21
18
|
return '';
|
|
22
19
|
}
|
|
23
20
|
return '/';
|
|
24
21
|
}
|
|
25
|
-
|
|
22
|
+
const localeCode = locale.toUnderscoreCode();
|
|
26
23
|
if (currentStory && currentStory.culture.locale !== localeCode) {
|
|
27
|
-
|
|
28
|
-
var culture = _a.culture;
|
|
29
|
-
return culture.locale === localeCode;
|
|
30
|
-
});
|
|
24
|
+
const translatedStory = currentStory.translations.find(({ culture }) => culture.locale === localeCode);
|
|
31
25
|
if (translatedStory) {
|
|
32
|
-
return
|
|
26
|
+
return `/${translatedStory.slug}`;
|
|
33
27
|
}
|
|
34
28
|
if (noFallback) {
|
|
35
29
|
return '';
|
|
@@ -42,13 +36,10 @@ function getTranslationUrl(locale, path, currentCategory, currentStory, noFallba
|
|
|
42
36
|
* This hook returns a function that is meant to be used in language pickers and alternate locales list for the pages.
|
|
43
37
|
* `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).
|
|
44
38
|
*/
|
|
45
|
-
function useGetTranslationUrl() {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
return getTranslationUrl(locale, asPath, currentCategory, currentStory, noFallback);
|
|
51
|
-
}, [asPath, currentCategory, currentStory]);
|
|
39
|
+
export function useGetTranslationUrl() {
|
|
40
|
+
const { asPath } = useRouter();
|
|
41
|
+
const currentCategory = useCurrentCategory();
|
|
42
|
+
const currentStory = useCurrentStory();
|
|
43
|
+
return useCallback((locale, noFallback) => getTranslationUrl(locale, asPath, currentCategory, currentStory, noFallback), [asPath, currentCategory, currentStory]);
|
|
52
44
|
}
|
|
53
|
-
exports.useGetTranslationUrl = useGetTranslationUrl;
|
|
54
45
|
//# sourceMappingURL=useGetTranslationUrl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetTranslationUrl.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useGetTranslationUrl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useGetTranslationUrl.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useGetTranslationUrl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGhF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;GAKG;AACH,SAAS,iBAAiB,CACtB,MAAoB,EACpB,IAAY,EACZ,eAA0B,EAC1B,YAA4B,EAC5B,UAAoB;IAEpB,IAAI,eAAe,EAAE;QACjB,IAAI,yBAAyB,CAAC,eAAe,EAAE,MAAM,CAAC,EAAE;YACpD,OAAO,cAAc,CAAC,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,eAAe,GAAG,YAAY,CAAC,YAAY,CAAC,IAAI,CAClD,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,KAAK,UAAU,CACjD,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,MAAM,UAAU,oBAAoB;IAChC,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,CAAC;IAC/B,MAAM,eAAe,GAAG,kBAAkB,EAAE,CAAC;IAC7C,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;IAEvC,OAAO,WAAW,CACd,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"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var useNewsroomContext_1 = require("./useNewsroomContext");
|
|
5
|
-
function useLanguages() {
|
|
6
|
-
var context = (0, useNewsroomContext_1.useNewsroomContext)();
|
|
1
|
+
import { useNewsroomContext } from './useNewsroomContext';
|
|
2
|
+
export function useLanguages() {
|
|
3
|
+
const context = useNewsroomContext();
|
|
7
4
|
return context.languages;
|
|
8
5
|
}
|
|
9
|
-
exports.useLanguages = useLanguages;
|
|
10
6
|
//# sourceMappingURL=useLanguages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLanguages.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useLanguages.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLanguages.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useLanguages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,UAAU,YAAY;IACxB,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IAErC,OAAO,OAAO,CAAC,SAAS,CAAC;AAC7B,CAAC"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var useNewsroomContext_1 = require("./useNewsroomContext");
|
|
5
|
-
function useNewsroom() {
|
|
6
|
-
var context = (0, useNewsroomContext_1.useNewsroomContext)();
|
|
1
|
+
import { useNewsroomContext } from './useNewsroomContext';
|
|
2
|
+
export function useNewsroom() {
|
|
3
|
+
const context = useNewsroomContext();
|
|
7
4
|
return context.newsroom;
|
|
8
5
|
}
|
|
9
|
-
exports.useNewsroom = useNewsroom;
|
|
10
6
|
//# sourceMappingURL=useNewsroom.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNewsroom.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useNewsroom.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useNewsroom.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useNewsroom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,UAAU,WAAW;IACvB,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IAErC,OAAO,OAAO,CAAC,QAAQ,CAAC;AAC5B,CAAC"}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var react_1 = require("react");
|
|
5
|
-
var context_1 = require("../context");
|
|
6
|
-
function useNewsroomContext() {
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { NewsroomContext } from '../context';
|
|
3
|
+
export function useNewsroomContext() {
|
|
7
4
|
// TS Compiler is having a hard time figuring this type implicitly, so we have to set it explicitly
|
|
8
5
|
// See https://github.com/microsoft/TypeScript/issues/5711#issuecomment-340283439
|
|
9
|
-
|
|
6
|
+
const newsroomContext = useContext(NewsroomContext);
|
|
10
7
|
if (!newsroomContext) {
|
|
11
8
|
throw new Error('No `NewsroomContextProvider` found when calling `useNewsroomContext`');
|
|
12
9
|
}
|
|
13
10
|
return newsroomContext;
|
|
14
11
|
}
|
|
15
|
-
exports.useNewsroomContext = useNewsroomContext;
|
|
16
12
|
//# sourceMappingURL=useNewsroomContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNewsroomContext.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useNewsroomContext.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useNewsroomContext.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useNewsroomContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAGnC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,UAAU,kBAAkB;IAC9B,mGAAmG;IACnG,iFAAiF;IACjF,MAAM,eAAe,GAAoC,UAAU,CAAC,eAAe,CAAC,CAAC;IACrF,IAAI,CAAC,eAAe,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAC;KAC3F;IAED,OAAO,eAAe,CAAC;AAC3B,CAAC"}
|
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.NewsroomContextProvider = exports.NewsroomContext = void 0;
|
|
14
|
-
var context_1 = require("./context");
|
|
15
|
-
Object.defineProperty(exports, "NewsroomContext", { enumerable: true, get: function () { return context_1.NewsroomContext; } });
|
|
16
|
-
Object.defineProperty(exports, "NewsroomContextProvider", { enumerable: true, get: function () { return context_1.NewsroomContextProvider; } });
|
|
17
|
-
__exportStar(require("./hooks"), exports);
|
|
1
|
+
export { NewsroomContext, NewsroomContextProvider } from './context';
|
|
2
|
+
export * from './hooks';
|
|
18
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/newsroom-context/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/newsroom-context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAwB,MAAM,WAAW,CAAC;AAC3F,cAAc,SAAS,CAAC"}
|
package/build/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prezly/theme-kit-nextjs",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.4-2",
|
|
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",
|
|
@@ -48,8 +48,11 @@
|
|
|
48
48
|
"react-dom": "^17.x"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@prezly/sdk": "^6.
|
|
52
|
-
"
|
|
51
|
+
"@prezly/sdk": "^6.21.0",
|
|
52
|
+
"@react-hookz/web": "^13.2.1",
|
|
53
|
+
"next-seo": "^5.4.0",
|
|
54
|
+
"parse-data-url": "^4.0.1",
|
|
55
|
+
"string-strip-html": "^9.1.9"
|
|
53
56
|
},
|
|
54
57
|
"devDependencies": {
|
|
55
58
|
"@prezly/eslint-config": "^4.0.0",
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { NextSeo } from 'next-seo';
|
|
2
|
+
import type { NextSeoProps } from 'next-seo';
|
|
3
|
+
import { useRouter } from 'next/router';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import { stripHtml } from 'string-strip-html';
|
|
6
|
+
|
|
7
|
+
import { getNewsroomLogoUrl, getUsedLanguages } from '../../data-fetching';
|
|
8
|
+
import { LocaleObject } from '../../intl';
|
|
9
|
+
import {
|
|
10
|
+
useCompanyInformation,
|
|
11
|
+
useCurrentLocale,
|
|
12
|
+
useCurrentStory,
|
|
13
|
+
useGetLinkLocaleSlug,
|
|
14
|
+
useGetTranslationUrl,
|
|
15
|
+
useLanguages,
|
|
16
|
+
useNewsroom,
|
|
17
|
+
} from '../../newsroom-context';
|
|
18
|
+
|
|
19
|
+
import { getAbsoluteUrl } from './lib/getAbsoluteUrl';
|
|
20
|
+
import type { AlternateLanguageLink } from './lib/types';
|
|
21
|
+
|
|
22
|
+
type Props = NextSeoProps & {
|
|
23
|
+
imageUrl?: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* This component provides base page attributes for every Newsroom page.
|
|
28
|
+
* It depends on information from NewsroomContext, so the component should be placed inside the `NewsroomContextProvider`.
|
|
29
|
+
* You can pass additional props expected by NextSeo component to override any info that is provided by the NewsroomContext.
|
|
30
|
+
*/
|
|
31
|
+
export function PageSeo({
|
|
32
|
+
title,
|
|
33
|
+
description,
|
|
34
|
+
imageUrl,
|
|
35
|
+
canonical,
|
|
36
|
+
openGraph,
|
|
37
|
+
twitter,
|
|
38
|
+
...nextSeoProps
|
|
39
|
+
}: Props) {
|
|
40
|
+
const companyInformation = useCompanyInformation();
|
|
41
|
+
const newsroom = useNewsroom();
|
|
42
|
+
const currentLocale = useCurrentLocale();
|
|
43
|
+
const languages = useLanguages();
|
|
44
|
+
const getTranslationUrl = useGetTranslationUrl();
|
|
45
|
+
const getLinkLocaleSlug = useGetLinkLocaleSlug();
|
|
46
|
+
const currentStory = useCurrentStory();
|
|
47
|
+
const { asPath } = useRouter();
|
|
48
|
+
|
|
49
|
+
const pageTitle = title || companyInformation.name;
|
|
50
|
+
const pageDescription = description || stripHtml(companyInformation.about).result;
|
|
51
|
+
const canonicalUrl =
|
|
52
|
+
canonical || getAbsoluteUrl(asPath, newsroom.url, getLinkLocaleSlug(currentLocale));
|
|
53
|
+
const siteName = companyInformation.name;
|
|
54
|
+
const logoUrl = imageUrl || getNewsroomLogoUrl(newsroom);
|
|
55
|
+
|
|
56
|
+
const alternateLanguageLinks: AlternateLanguageLink[] = useMemo(() => {
|
|
57
|
+
if (!languages.length) {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const alternateLanguages = getUsedLanguages(languages).filter(
|
|
62
|
+
(language) => language.code !== currentLocale.toUnderscoreCode(),
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
return alternateLanguages
|
|
66
|
+
.map((language) => {
|
|
67
|
+
const locale = LocaleObject.fromAnyCode(language.code);
|
|
68
|
+
|
|
69
|
+
const translationLink = getTranslationUrl(locale, true);
|
|
70
|
+
|
|
71
|
+
if (!translationLink) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
hrefLang: locale.toHyphenCode(),
|
|
77
|
+
href: getAbsoluteUrl(
|
|
78
|
+
translationLink,
|
|
79
|
+
newsroom.url,
|
|
80
|
+
currentStory && translationLink !== '/' ? false : getLinkLocaleSlug(locale),
|
|
81
|
+
),
|
|
82
|
+
};
|
|
83
|
+
})
|
|
84
|
+
.filter<AlternateLanguageLink>(Boolean as any);
|
|
85
|
+
}, [
|
|
86
|
+
currentLocale,
|
|
87
|
+
getLinkLocaleSlug,
|
|
88
|
+
getTranslationUrl,
|
|
89
|
+
languages,
|
|
90
|
+
newsroom.url,
|
|
91
|
+
currentStory,
|
|
92
|
+
]);
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<NextSeo
|
|
96
|
+
title={pageTitle}
|
|
97
|
+
description={pageDescription}
|
|
98
|
+
canonical={canonicalUrl}
|
|
99
|
+
openGraph={{
|
|
100
|
+
url: canonicalUrl,
|
|
101
|
+
title: pageTitle,
|
|
102
|
+
description: pageDescription,
|
|
103
|
+
locale: currentLocale.toUnderscoreCode(),
|
|
104
|
+
images: [
|
|
105
|
+
{
|
|
106
|
+
url: logoUrl,
|
|
107
|
+
alt: pageTitle,
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
site_name: siteName,
|
|
111
|
+
...openGraph,
|
|
112
|
+
}}
|
|
113
|
+
twitter={{
|
|
114
|
+
site: siteName,
|
|
115
|
+
cardType: 'summary',
|
|
116
|
+
...twitter,
|
|
117
|
+
}}
|
|
118
|
+
additionalMetaTags={[{ name: 'twitter:image', content: logoUrl }]}
|
|
119
|
+
languageAlternates={alternateLanguageLinks}
|
|
120
|
+
{...nextSeoProps}
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Returns absolute URL based on the path and without any query parameters
|
|
2
|
+
export function getAbsoluteUrl(path: string, origin: string, localeCode?: string | false): string {
|
|
3
|
+
const url = new URL(`${localeCode ? `/${localeCode}` : ''}${path || '/'}`, origin);
|
|
4
|
+
url.search = '';
|
|
5
|
+
|
|
6
|
+
return url.toString();
|
|
7
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { SitemapUrl } from './types';
|
|
2
|
+
|
|
3
|
+
export class SitemapBuilder {
|
|
4
|
+
private baseUrl: string;
|
|
5
|
+
|
|
6
|
+
private urls: SitemapUrl[] = [];
|
|
7
|
+
|
|
8
|
+
constructor(baseUrl: string) {
|
|
9
|
+
this.baseUrl = baseUrl;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public addUrl(location: string) {
|
|
13
|
+
this.urls.push({
|
|
14
|
+
location: this.baseUrl + location,
|
|
15
|
+
changeFrequency: SitemapBuilder.guessFrequency(location),
|
|
16
|
+
priority: SitemapBuilder.guessPriority(location),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
private static guessFrequency(location: string) {
|
|
21
|
+
if (location === '/') return 'daily';
|
|
22
|
+
|
|
23
|
+
return 'weekly';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
private static guessPriority(location: string) {
|
|
27
|
+
if (location === '/') return '0.9';
|
|
28
|
+
|
|
29
|
+
if (location.startsWith('/category/')) {
|
|
30
|
+
return '0.8';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return '0.7';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static serializeLocation(url: SitemapUrl) {
|
|
37
|
+
return [
|
|
38
|
+
'<url>',
|
|
39
|
+
url.location && `\t<loc>${url.location}</loc>`,
|
|
40
|
+
url.changeFrequency && `\t<changefreq>${url.changeFrequency}</changefreq>`,
|
|
41
|
+
url.priority && `\t<priority>${url.priority}</priority>`,
|
|
42
|
+
'</url>',
|
|
43
|
+
]
|
|
44
|
+
.filter(Boolean)
|
|
45
|
+
.join('\n');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
serialize() {
|
|
49
|
+
return [
|
|
50
|
+
'<?xml version="1.0" encoding="UTF-8" ?>',
|
|
51
|
+
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">',
|
|
52
|
+
this.urls.map(SitemapBuilder.serializeLocation).join('\n'),
|
|
53
|
+
'</urlset>',
|
|
54
|
+
].join('\n');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Category, Story } from '@prezly/sdk';
|
|
2
|
+
|
|
3
|
+
export function createPaths(stories: Story[], categories: Category[]) {
|
|
4
|
+
const storiesUrls = stories.map(({ slug }) => `/${slug}`);
|
|
5
|
+
const categoriesUrls = categories
|
|
6
|
+
.map((category) => {
|
|
7
|
+
const translations = Object.values(category.i18n);
|
|
8
|
+
const allSlugs = translations
|
|
9
|
+
.map(({ slug }) => slug || '')
|
|
10
|
+
.filter(Boolean)
|
|
11
|
+
.reduce<string[]>(
|
|
12
|
+
(slugs, slug) => (slugs.includes(slug) ? [...slugs] : [...slugs, slug]),
|
|
13
|
+
[],
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
return allSlugs.map((slug) => `/category/${slug}`);
|
|
17
|
+
})
|
|
18
|
+
.flat();
|
|
19
|
+
|
|
20
|
+
return [...storiesUrls, ...categoriesUrls];
|
|
21
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { NextPageContext } from 'next';
|
|
2
|
+
|
|
3
|
+
import { getPrezlyApi } from '../../data-fetching';
|
|
4
|
+
|
|
5
|
+
import { createPaths } from './createPaths';
|
|
6
|
+
import { SitemapBuilder } from './SitemapBuilder';
|
|
7
|
+
|
|
8
|
+
export async function getInitialProps(ctx: NextPageContext, additionalPaths?: string[]) {
|
|
9
|
+
const { res, req } = ctx;
|
|
10
|
+
|
|
11
|
+
if (!req || !res) {
|
|
12
|
+
// client side
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const baseUrl = req.headers.host || '/';
|
|
17
|
+
|
|
18
|
+
const api = getPrezlyApi(req);
|
|
19
|
+
const stories = await api.getAllStories();
|
|
20
|
+
const categories = await api.getCategories();
|
|
21
|
+
|
|
22
|
+
const paths = createPaths(stories, categories);
|
|
23
|
+
const sitemapBuilder = new SitemapBuilder(baseUrl);
|
|
24
|
+
|
|
25
|
+
sitemapBuilder.addUrl('/');
|
|
26
|
+
paths.forEach((path) => sitemapBuilder.addUrl(path));
|
|
27
|
+
|
|
28
|
+
if (additionalPaths) {
|
|
29
|
+
additionalPaths.forEach((path) => sitemapBuilder.addUrl(path));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
res.setHeader('Content-Type', 'text/xml');
|
|
33
|
+
res.write(sitemapBuilder.serialize());
|
|
34
|
+
res.end();
|
|
35
|
+
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ExtendedStory } from '@prezly/sdk';
|
|
2
|
+
import { ArticleJsonLd, NextSeo } from 'next-seo';
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
story: ExtendedStory;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This components provides additional page attributes for the Story page.
|
|
10
|
+
* It works in conjunction with `PageSeo` component, overidding some of its attributes.
|
|
11
|
+
*/
|
|
12
|
+
export function StorySeo({ story }: Props) {
|
|
13
|
+
const { title, subtitle, published_at, updated_at, author, oembed, newsroom, summary } = story;
|
|
14
|
+
|
|
15
|
+
const authorName = author?.display_name || author?.email || 'Unknown';
|
|
16
|
+
const description = subtitle || summary;
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<>
|
|
20
|
+
<NextSeo
|
|
21
|
+
title={title}
|
|
22
|
+
description={description}
|
|
23
|
+
canonical={oembed.url}
|
|
24
|
+
openGraph={{
|
|
25
|
+
title,
|
|
26
|
+
description,
|
|
27
|
+
url: oembed.url,
|
|
28
|
+
site_name: newsroom.display_name,
|
|
29
|
+
type: 'article',
|
|
30
|
+
article: {
|
|
31
|
+
publishedTime: published_at || undefined,
|
|
32
|
+
modifiedTime: updated_at,
|
|
33
|
+
authors: [authorName],
|
|
34
|
+
},
|
|
35
|
+
...(oembed.thumbnail_url && {
|
|
36
|
+
images: [
|
|
37
|
+
{
|
|
38
|
+
url: oembed.thumbnail_url,
|
|
39
|
+
alt: oembed.title,
|
|
40
|
+
width: oembed.thumbnail_width,
|
|
41
|
+
height: oembed.thumbnail_height,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
}),
|
|
45
|
+
}}
|
|
46
|
+
additionalMetaTags={
|
|
47
|
+
oembed.thumbnail_url
|
|
48
|
+
? [
|
|
49
|
+
{ name: 'twitter:card', content: 'summary_large_image' },
|
|
50
|
+
{ name: 'twitter:image', content: oembed.thumbnail_url },
|
|
51
|
+
]
|
|
52
|
+
: undefined
|
|
53
|
+
}
|
|
54
|
+
/>
|
|
55
|
+
<ArticleJsonLd
|
|
56
|
+
url={oembed.url}
|
|
57
|
+
title={title}
|
|
58
|
+
images={oembed.thumbnail_url ? [oembed.thumbnail_url] : []}
|
|
59
|
+
datePublished={published_at || ''}
|
|
60
|
+
dateModified={updated_at}
|
|
61
|
+
authorName={[authorName]}
|
|
62
|
+
publisherName={newsroom.display_name}
|
|
63
|
+
publisherLogo={newsroom.thumbnail_url}
|
|
64
|
+
description={description}
|
|
65
|
+
/>
|
|
66
|
+
</>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { StorySeo } from './StorySeo';
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
2
|
+
|
|
3
|
+
import { getPrezlyApi } from '../../data-fetching';
|
|
4
|
+
|
|
5
|
+
export async function fetchGalleries(req: NextApiRequest, res: NextApiResponse) {
|
|
6
|
+
if (req.method !== 'POST') {
|
|
7
|
+
res.status(405);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const { page, pageSize } = req.body;
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
const api = getPrezlyApi(req);
|
|
15
|
+
|
|
16
|
+
const { galleries } = await api.getGalleries({ page, pageSize });
|
|
17
|
+
|
|
18
|
+
res.status(200).json({ galleries });
|
|
19
|
+
} catch (error) {
|
|
20
|
+
res.status(500).send({
|
|
21
|
+
message: (error as Error).message,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|