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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/build/@types/global.d.js +1 -0
  2. package/build/adapter-nextjs/api-handlers/fetchGalleries.js +26 -18
  3. package/build/adapter-nextjs/api-handlers/fetchStories.js +36 -20
  4. package/build/adapter-nextjs/api-handlers/index.js +2 -3
  5. package/build/adapter-nextjs/getNewsroomServerSideProps.js +15 -10
  6. package/build/adapter-nextjs/getNewsroomStaticProps.js +14 -10
  7. package/build/adapter-nextjs/index.js +6 -7
  8. package/build/adapter-nextjs/page-props/category.js +115 -91
  9. package/build/adapter-nextjs/page-props/gallery.js +85 -61
  10. package/build/adapter-nextjs/page-props/galleryAlbum.js +61 -44
  11. package/build/adapter-nextjs/page-props/home.js +81 -62
  12. package/build/adapter-nextjs/page-props/index.js +8 -9
  13. package/build/adapter-nextjs/page-props/lib/types.js +1 -2
  14. package/build/adapter-nextjs/page-props/search.js +23 -24
  15. package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js +28 -45
  16. package/build/adapter-nextjs/page-props/sitemap/createPaths.js +12 -14
  17. package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js +32 -30
  18. package/build/adapter-nextjs/page-props/sitemap/index.js +4 -5
  19. package/build/adapter-nextjs/page-props/sitemap/types.js +1 -2
  20. package/build/adapter-nextjs/page-props/story.js +74 -55
  21. package/build/adapter-nextjs/page-props/storyPreview.js +26 -21
  22. package/build/adapter-nextjs/processRequest.js +33 -20
  23. package/build/adapter-nextjs/processStaticRequest.js +18 -11
  24. package/build/components-nextjs/PageSeo/PageSeo.js +81 -71
  25. package/build/components-nextjs/PageSeo/index.js +2 -3
  26. package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js +4 -5
  27. package/build/components-nextjs/PageSeo/lib/types.js +1 -2
  28. package/build/components-nextjs/StorySeo/StorySeo.js +67 -41
  29. package/build/components-nextjs/StorySeo/index.js +1 -2
  30. package/build/components-nextjs/document.js +29 -19
  31. package/build/components-nextjs/index.js +3 -4
  32. package/build/data-fetching/api/PrezlyApi.js +205 -185
  33. package/build/data-fetching/api/getPrezlyApi.js +20 -16
  34. package/build/data-fetching/api/index.js +1 -2
  35. package/build/data-fetching/api/queries.js +71 -34
  36. package/build/data-fetching/index.js +3 -4
  37. package/build/data-fetching/lib/getAlgoliaSettings.js +21 -17
  38. package/build/data-fetching/lib/getEnvVariables.js +33 -29
  39. package/build/data-fetching/lib/index.js +4 -5
  40. package/build/data-fetching/lib/isSdkError.js +2 -3
  41. package/build/data-fetching/lib/isUuid.js +2 -3
  42. package/build/data-fetching/types.js +1 -2
  43. package/build/index.js +9 -10
  44. package/build/infinite-loading/index.js +4 -5
  45. package/build/infinite-loading/types.js +1 -2
  46. package/build/infinite-loading/useInfiniteGalleriesLoading.js +41 -32
  47. package/build/infinite-loading/useInfiniteLoading.js +48 -37
  48. package/build/infinite-loading/useInfiniteStoriesLoading.js +54 -44
  49. package/build/intl/index.js +4 -5
  50. package/build/intl/languages.js +135 -97
  51. package/build/intl/locale.js +46 -95
  52. package/build/intl/localeConfig.js +7 -13
  53. package/build/intl/localeList.js +1 -108
  54. package/build/intl/localeObject.js +79 -74
  55. package/build/newsroom-context/context.js +34 -20
  56. package/build/newsroom-context/hooks/index.js +11 -12
  57. package/build/newsroom-context/hooks/useAlgoliaSettings.js +4 -5
  58. package/build/newsroom-context/hooks/useCategories.js +4 -5
  59. package/build/newsroom-context/hooks/useCompanyInformation.js +4 -5
  60. package/build/newsroom-context/hooks/useCurrentCategory.js +4 -5
  61. package/build/newsroom-context/hooks/useCurrentLocale.js +4 -5
  62. package/build/newsroom-context/hooks/useCurrentStory.js +4 -5
  63. package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js +15 -15
  64. package/build/newsroom-context/hooks/useGetTranslationUrl.js +48 -44
  65. package/build/newsroom-context/hooks/useLanguages.js +4 -5
  66. package/build/newsroom-context/hooks/useNewsroom.js +4 -5
  67. package/build/newsroom-context/hooks/useNewsroomContext.js +9 -10
  68. package/build/newsroom-context/index.js +2 -3
  69. package/build/sentry/client.js +3 -4
  70. package/build/sentry/common.js +25 -24
  71. package/build/sentry/index.js +2 -3
  72. package/build/sentry/server.js +3 -4
  73. package/build/types.js +1 -2
  74. package/build/utils/boilerplate.js +4 -13
  75. package/build/utils/constants.js +1 -2
  76. package/build/utils/getAssetsUrl.js +3 -4
  77. package/build/utils/getDataRequestLink.js +5 -7
  78. package/build/utils/getLocalizedCategoryData.js +30 -24
  79. package/build/utils/getNewsroomLogoUrl.js +12 -13
  80. package/build/utils/getPrivacyPortalUrl.js +10 -8
  81. package/build/utils/getStoryPublicationDate.js +8 -9
  82. package/build/utils/getUploadcareGroupUrl.js +4 -5
  83. package/build/utils/index.js +10 -11
  84. package/build/utils/isEmbargoStory.js +2 -3
  85. package/package.json +10 -2
  86. package/build/tsconfig.tsbuildinfo +0 -1
@@ -1,61 +1,80 @@
1
- import { getPrezlyApi } from '../../data-fetching';
2
- import { DUMMY_DEFAULT_LOCALE } from '../../intl';
3
- import { getNewsroomServerSideProps } from '../getNewsroomServerSideProps';
4
- import { getNewsroomStaticProps } from '../getNewsroomStaticProps';
5
- import { processRequest } from '../processRequest';
6
- import { processStaticRequest } from '../processStaticRequest';
1
+ import { getPrezlyApi } from "../../data-fetching/index.js";
2
+ import { DUMMY_DEFAULT_LOCALE } from "../../intl/index.js";
3
+ import { getNewsroomServerSideProps } from "../getNewsroomServerSideProps.js";
4
+ import { getNewsroomStaticProps } from "../getNewsroomStaticProps.js";
5
+ import { processRequest } from "../processRequest.js";
6
+ import { processStaticRequest } from "../processStaticRequest.js";
7
7
  export function getStoryPageServerSideProps(customProps) {
8
- return async function getServerSideProps(context) {
9
- const api = getPrezlyApi(context.req);
10
- const { slug } = context.params;
11
- const story = slug ? await api.getStoryBySlug(slug) : null;
12
- if (!story) {
13
- return { notFound: true };
8
+ return async function getServerSideProps(context) {
9
+ const api = getPrezlyApi(context.req);
10
+ const {
11
+ slug
12
+ } = context.params;
13
+ const story = slug ? await api.getStoryBySlug(slug) : null;
14
+ if (!story) {
15
+ return {
16
+ notFound: true
17
+ };
18
+ }
19
+ const {
20
+ serverSideProps
21
+ } = await getNewsroomServerSideProps(context, {
22
+ story
23
+ });
24
+ const {
25
+ locale
26
+ } = context;
27
+ if (locale && locale !== DUMMY_DEFAULT_LOCALE) {
28
+ return {
29
+ redirect: {
30
+ destination: `/${slug}`,
31
+ permanent: true
14
32
  }
15
- const { serverSideProps } = await getNewsroomServerSideProps(context, { story });
16
- const { locale } = context;
17
- if (locale && locale !== DUMMY_DEFAULT_LOCALE) {
18
- return {
19
- redirect: {
20
- destination: `/${slug}`,
21
- permanent: true,
22
- },
23
- };
24
- }
25
- serverSideProps.newsroomContextProps.currentStory = story;
26
- return processRequest(context, {
27
- ...serverSideProps,
28
- ...(typeof customProps === 'function'
29
- ? await customProps(context, serverSideProps)
30
- : customProps),
31
- });
32
- };
33
+ };
34
+ }
35
+ serverSideProps.newsroomContextProps.currentStory = story;
36
+ return processRequest(context, {
37
+ ...serverSideProps,
38
+ ...(typeof customProps === 'function' ? await customProps(context, serverSideProps) : customProps)
39
+ });
40
+ };
33
41
  }
34
42
  export function getStoryPageStaticProps(customProps) {
35
- return async function getStaticProps(context) {
36
- const api = getPrezlyApi();
37
- const { slug } = context.params;
38
- const story = slug ? await api.getStoryBySlug(slug) : null;
39
- if (!story) {
40
- return { notFound: true };
41
- }
42
- const { staticProps } = await getNewsroomStaticProps(context, { story });
43
- staticProps.newsroomContextProps.currentStory = story;
44
- return processStaticRequest(context, {
45
- ...staticProps,
46
- ...(typeof customProps === 'function'
47
- ? await customProps(context, staticProps)
48
- : customProps),
49
- });
50
- };
51
- }
52
- export async function getStoryPageStaticPaths() {
43
+ return async function getStaticProps(context) {
53
44
  const api = getPrezlyApi();
54
- const stories = await api.getAllStories();
55
- const paths = stories.map(({ slug }) => ({ params: { slug } }));
56
- return {
57
- paths,
58
- fallback: 'blocking',
59
- };
45
+ const {
46
+ slug
47
+ } = context.params;
48
+ const story = slug ? await api.getStoryBySlug(slug) : null;
49
+ if (!story) {
50
+ return {
51
+ notFound: true
52
+ };
53
+ }
54
+ const {
55
+ staticProps
56
+ } = await getNewsroomStaticProps(context, {
57
+ story
58
+ });
59
+ staticProps.newsroomContextProps.currentStory = story;
60
+ return processStaticRequest(context, {
61
+ ...staticProps,
62
+ ...(typeof customProps === 'function' ? await customProps(context, staticProps) : customProps)
63
+ });
64
+ };
60
65
  }
61
- //# sourceMappingURL=story.js.map
66
+ export async function getStoryPageStaticPaths() {
67
+ const api = getPrezlyApi();
68
+ const stories = await api.getAllStories();
69
+ const paths = stories.map(({
70
+ slug
71
+ }) => ({
72
+ params: {
73
+ slug
74
+ }
75
+ }));
76
+ return {
77
+ paths,
78
+ fallback: 'blocking'
79
+ };
80
+ }
@@ -1,22 +1,27 @@
1
- import { getPrezlyApi } from '../../data-fetching';
2
- import { getNewsroomServerSideProps } from '../getNewsroomServerSideProps';
3
- import { processRequest } from '../processRequest';
1
+ import { getPrezlyApi } from "../../data-fetching/index.js";
2
+ import { getNewsroomServerSideProps } from "../getNewsroomServerSideProps.js";
3
+ import { processRequest } from "../processRequest.js";
4
4
  export function getStoryPreviewPageServerSideProps(customProps) {
5
- return async function getServerSideProps(context) {
6
- const api = getPrezlyApi(context.req);
7
- const { uuid } = context.params;
8
- const story = await api.getStory(uuid);
9
- if (!story) {
10
- return { notFound: true };
11
- }
12
- const { serverSideProps } = await getNewsroomServerSideProps(context, { story });
13
- serverSideProps.newsroomContextProps.currentStory = story;
14
- return processRequest(context, {
15
- ...serverSideProps,
16
- ...(typeof customProps === 'function'
17
- ? await customProps(context, serverSideProps)
18
- : customProps),
19
- });
20
- };
21
- }
22
- //# sourceMappingURL=storyPreview.js.map
5
+ return async function getServerSideProps(context) {
6
+ const api = getPrezlyApi(context.req);
7
+ const {
8
+ uuid
9
+ } = context.params;
10
+ const story = await api.getStory(uuid);
11
+ if (!story) {
12
+ return {
13
+ notFound: true
14
+ };
15
+ }
16
+ const {
17
+ serverSideProps
18
+ } = await getNewsroomServerSideProps(context, {
19
+ story
20
+ });
21
+ serverSideProps.newsroomContextProps.currentStory = story;
22
+ return processRequest(context, {
23
+ ...serverSideProps,
24
+ ...(typeof customProps === 'function' ? await customProps(context, serverSideProps) : customProps)
25
+ });
26
+ };
27
+ }
@@ -1,4 +1,4 @@
1
- import { getRedirectToCanonicalLocale, getShortestLocaleCode, LocaleObject } from '../intl';
1
+ import { getRedirectToCanonicalLocale, getShortestLocaleCode, LocaleObject } from "../intl/index.js";
2
2
  /**
3
3
  * This function combines the props returned from `getNewsroomServerSideProps` and your optional custom props for the page.
4
4
  * It also handles locale redirects, if `canonicalUrl` parameter is provided.
@@ -9,24 +9,37 @@ import { getRedirectToCanonicalLocale, getShortestLocaleCode, LocaleObject } fro
9
9
  * @param canonicalUrl Optional: a canonical URL for the current page without locale part. If provided, locale redirects will be handled by the function.
10
10
  */
11
11
  export function processRequest(context, props, canonicalUrl) {
12
- const { locale: nextLocale, query } = context;
13
- const { localeResolved, ...pageProps } = props;
14
- // If no locale was provided by Next, it most likely means that the theme is not supporting multi-language.
15
- // In that case we won't show 404 page.
16
- if (!localeResolved && nextLocale) {
17
- return { notFound: true };
18
- }
19
- if (canonicalUrl) {
20
- const { languages, localeCode } = pageProps.newsroomContextProps;
21
- const currentLocale = LocaleObject.fromAnyCode(localeCode);
22
- const shortestLocaleCode = getShortestLocaleCode(languages, currentLocale);
23
- const redirect = getRedirectToCanonicalLocale(shortestLocaleCode, nextLocale, canonicalUrl, query);
24
- if (redirect) {
25
- return { redirect };
26
- }
27
- }
12
+ const {
13
+ locale: nextLocale,
14
+ query
15
+ } = context;
16
+ const {
17
+ localeResolved,
18
+ ...pageProps
19
+ } = props;
20
+
21
+ // If no locale was provided by Next, it most likely means that the theme is not supporting multi-language.
22
+ // In that case we won't show 404 page.
23
+ if (!localeResolved && nextLocale) {
28
24
  return {
29
- props: pageProps,
25
+ notFound: true
30
26
  };
31
- }
32
- //# sourceMappingURL=processRequest.js.map
27
+ }
28
+ if (canonicalUrl) {
29
+ const {
30
+ languages,
31
+ localeCode
32
+ } = pageProps.newsroomContextProps;
33
+ const currentLocale = LocaleObject.fromAnyCode(localeCode);
34
+ const shortestLocaleCode = getShortestLocaleCode(languages, currentLocale);
35
+ const redirect = getRedirectToCanonicalLocale(shortestLocaleCode, nextLocale, canonicalUrl, query);
36
+ if (redirect) {
37
+ return {
38
+ redirect
39
+ };
40
+ }
41
+ }
42
+ return {
43
+ props: pageProps
44
+ };
45
+ }
@@ -7,16 +7,23 @@
7
7
  * @param revalidateTimeout Optional: timeout in seconds to use with Next ISR.
8
8
  */
9
9
  export function processStaticRequest(context, props, revalidateTimeout) {
10
- const { locale: nextLocale } = context;
11
- const { localeResolved, ...pageProps } = props;
12
- // If no locale was provided by Next, it most likely means that the theme is not supporting multi-language.
13
- // In that case we won't show 404 page.
14
- if (!localeResolved && nextLocale) {
15
- return { notFound: true };
16
- }
10
+ const {
11
+ locale: nextLocale
12
+ } = context;
13
+ const {
14
+ localeResolved,
15
+ ...pageProps
16
+ } = props;
17
+
18
+ // If no locale was provided by Next, it most likely means that the theme is not supporting multi-language.
19
+ // In that case we won't show 404 page.
20
+ if (!localeResolved && nextLocale) {
17
21
  return {
18
- props: pageProps,
19
- revalidate: revalidateTimeout,
22
+ notFound: true
20
23
  };
21
- }
22
- //# sourceMappingURL=processStaticRequest.js.map
24
+ }
25
+ return {
26
+ props: pageProps,
27
+ revalidate: revalidateTimeout
28
+ };
29
+ }
@@ -1,79 +1,89 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
  import { NextSeo } from 'next-seo';
3
3
  import { useRouter } from 'next/router';
4
4
  import { useMemo } from 'react';
5
- import { getUsedLanguages, LocaleObject } from '../../intl';
6
- import { useCompanyInformation, useCurrentLocale, useCurrentStory, useGetLinkLocaleSlug, useGetTranslationUrl, useLanguages, useNewsroom, } from '../../newsroom-context';
7
- import { getNewsroomLogoUrl } from '../../utils';
8
- import { getAbsoluteUrl } from './lib/getAbsoluteUrl';
5
+ import { getUsedLanguages, LocaleObject } from "../../intl/index.js";
6
+ import { useCompanyInformation, useCurrentLocale, useCurrentStory, useGetLinkLocaleSlug, useGetTranslationUrl, useLanguages, useNewsroom } from "../../newsroom-context/index.js";
7
+ import { getNewsroomLogoUrl } from "../../utils/index.js";
8
+ import { getAbsoluteUrl } from "./lib/getAbsoluteUrl.js";
9
9
  /**
10
10
  * This component provides base page attributes for every Newsroom page.
11
11
  * It depends on information from NewsroomContext, so the component should be placed inside the `NewsroomContextProvider`.
12
12
  * You can pass additional props expected by NextSeo component to override any info that is provided by the NewsroomContext.
13
13
  */
14
- export function PageSeo({ title, description, imageUrl, canonical, openGraph, twitter, ...nextSeoProps }) {
15
- const companyInformation = useCompanyInformation();
16
- const newsroom = useNewsroom();
17
- const currentLocale = useCurrentLocale();
18
- const languages = useLanguages();
19
- const getTranslationUrl = useGetTranslationUrl();
20
- const getLinkLocaleSlug = useGetLinkLocaleSlug();
21
- const currentStory = useCurrentStory();
22
- const { asPath } = useRouter();
23
- const pageTitle = title || companyInformation.name;
24
- const pageDescription = description || companyInformation.about_plaintext;
25
- const canonicalUrl = canonical || getAbsoluteUrl(asPath, newsroom.url, getLinkLocaleSlug(currentLocale));
26
- const siteName = companyInformation.name;
27
- const logoUrl = imageUrl || getNewsroomLogoUrl(newsroom);
28
- const alternateLanguageLinks = useMemo(() => {
29
- if (!languages.length) {
30
- return [];
31
- }
32
- const alternateLanguages = getUsedLanguages(languages).filter((language) => language.code !== currentLocale.toUnderscoreCode());
33
- return alternateLanguages
34
- .map((language) => {
35
- const locale = LocaleObject.fromAnyCode(language.code);
36
- const translationLink = getTranslationUrl(locale, true);
37
- if (!translationLink) {
38
- return undefined;
39
- }
40
- return {
41
- hrefLang: locale.toHyphenCode(),
42
- href: getAbsoluteUrl(translationLink, newsroom.url, currentStory && translationLink !== '/' ? false : getLinkLocaleSlug(locale)),
43
- };
44
- })
45
- .filter(Boolean);
46
- }, [
47
- currentLocale,
48
- getLinkLocaleSlug,
49
- getTranslationUrl,
50
- languages,
51
- newsroom.url,
52
- currentStory,
53
- ]);
54
- return (_jsx(NextSeo, { title: pageTitle, description: pageDescription, canonical: canonicalUrl, noindex: nextSeoProps.noindex ?? !newsroom.is_indexable, nofollow: nextSeoProps.nofollow ?? !newsroom.is_indexable, openGraph: {
55
- url: canonicalUrl,
56
- title: pageTitle,
57
- description: pageDescription,
58
- locale: currentLocale.toUnderscoreCode(),
59
- images: [
60
- {
61
- url: logoUrl,
62
- alt: pageTitle,
63
- },
64
- ],
65
- site_name: siteName,
66
- ...openGraph,
67
- }, twitter: {
68
- site: siteName,
69
- cardType: 'summary',
70
- ...twitter,
71
- }, additionalMetaTags: [{ name: 'twitter:image', content: logoUrl }], additionalLinkTags: [
72
- {
73
- rel: 'alternate',
74
- type: 'application/rss+xml',
75
- href: getAbsoluteUrl('/feed', newsroom.url),
76
- },
77
- ], languageAlternates: alternateLanguageLinks, ...nextSeoProps }));
78
- }
79
- //# sourceMappingURL=PageSeo.js.map
14
+ export function PageSeo({
15
+ title,
16
+ description,
17
+ imageUrl,
18
+ canonical,
19
+ openGraph,
20
+ twitter,
21
+ ...nextSeoProps
22
+ }) {
23
+ const companyInformation = useCompanyInformation();
24
+ const newsroom = useNewsroom();
25
+ const currentLocale = useCurrentLocale();
26
+ const languages = useLanguages();
27
+ const getTranslationUrl = useGetTranslationUrl();
28
+ const getLinkLocaleSlug = useGetLinkLocaleSlug();
29
+ const currentStory = useCurrentStory();
30
+ const {
31
+ asPath
32
+ } = useRouter();
33
+ const pageTitle = title || companyInformation.name;
34
+ const pageDescription = description || companyInformation.about_plaintext;
35
+ const canonicalUrl = canonical || getAbsoluteUrl(asPath, newsroom.url, getLinkLocaleSlug(currentLocale));
36
+ const siteName = companyInformation.name;
37
+ const logoUrl = imageUrl || getNewsroomLogoUrl(newsroom);
38
+ const alternateLanguageLinks = useMemo(() => {
39
+ if (!languages.length) {
40
+ return [];
41
+ }
42
+ const alternateLanguages = getUsedLanguages(languages).filter(language => language.code !== currentLocale.toUnderscoreCode());
43
+ return alternateLanguages.map(language => {
44
+ const locale = LocaleObject.fromAnyCode(language.code);
45
+ const translationLink = getTranslationUrl(locale, true);
46
+ if (!translationLink) {
47
+ return undefined;
48
+ }
49
+ return {
50
+ hrefLang: locale.toHyphenCode(),
51
+ href: getAbsoluteUrl(translationLink, newsroom.url, currentStory && translationLink !== '/' ? false : getLinkLocaleSlug(locale))
52
+ };
53
+ }).filter(Boolean);
54
+ }, [currentLocale, getLinkLocaleSlug, getTranslationUrl, languages, newsroom.url, currentStory]);
55
+ return /*#__PURE__*/React.createElement(NextSeo, _extends({
56
+ title: pageTitle,
57
+ description: pageDescription,
58
+ canonical: canonicalUrl,
59
+ noindex: nextSeoProps.noindex ?? !newsroom.is_indexable,
60
+ nofollow: nextSeoProps.nofollow ?? !newsroom.is_indexable,
61
+ openGraph: {
62
+ url: canonicalUrl,
63
+ title: pageTitle,
64
+ description: pageDescription,
65
+ locale: currentLocale.toUnderscoreCode(),
66
+ images: [{
67
+ url: logoUrl,
68
+ alt: pageTitle
69
+ }],
70
+ site_name: siteName,
71
+ ...openGraph
72
+ },
73
+ twitter: {
74
+ site: siteName,
75
+ cardType: 'summary',
76
+ ...twitter
77
+ },
78
+ additionalMetaTags: [{
79
+ name: 'twitter:image',
80
+ content: logoUrl
81
+ }],
82
+ additionalLinkTags: [{
83
+ rel: 'alternate',
84
+ type: 'application/rss+xml',
85
+ href: getAbsoluteUrl('/feed', newsroom.url)
86
+ }],
87
+ languageAlternates: alternateLanguageLinks
88
+ }, nextSeoProps));
89
+ }
@@ -1,3 +1,2 @@
1
- export { PageSeo } from './PageSeo';
2
- export * from './lib/types';
3
- //# sourceMappingURL=index.js.map
1
+ export { PageSeo } from "./PageSeo.js";
2
+ export * from "./lib/types.js";
@@ -1,7 +1,6 @@
1
1
  // Returns absolute URL based on the path and without any query parameters
2
2
  export function getAbsoluteUrl(path, origin, localeCode) {
3
- const url = new URL(`${localeCode ? `/${localeCode}` : ''}${path || '/'}`, origin);
4
- url.search = '';
5
- return url.toString();
6
- }
7
- //# sourceMappingURL=getAbsoluteUrl.js.map
3
+ const url = new URL(`${localeCode ? `/${localeCode}` : ''}${path || '/'}`, origin);
4
+ url.search = '';
5
+ return url.toString();
6
+ }
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
1
+ export {};
@@ -1,47 +1,73 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
1
  import { Story } from '@prezly/sdk';
3
2
  import { ArticleJsonLd, NextSeo } from 'next-seo';
4
3
  /**
5
4
  * This components provides additional page attributes for the Story page.
6
5
  * It works in conjunction with `PageSeo` component, overidding some of its attributes.
7
6
  */
8
- export function StorySeo({ story, noindex }) {
9
- const { title, subtitle, published_at, updated_at, author, oembed, newsroom, summary } = story;
10
- const authorName = author?.display_name || author?.email || 'Unknown';
11
- const description = subtitle || summary;
12
- const indexable = newsroom.is_indexable && story.visibility === Story.Visibility.PUBLIC;
13
- return (_jsxs(_Fragment, { children: [_jsx(NextSeo, { title: title, description: description, canonical: oembed.url, noindex: noindex ?? !indexable, nofollow: noindex ?? !indexable, openGraph: {
14
- title,
15
- description,
16
- url: oembed.url,
17
- site_name: newsroom.display_name,
18
- type: 'article',
19
- article: {
20
- publishedTime: published_at || undefined,
21
- modifiedTime: updated_at,
22
- authors: [authorName],
23
- },
24
- ...(oembed.thumbnail_url && {
25
- images: [
26
- {
27
- url: oembed.thumbnail_url,
28
- alt: oembed.title,
29
- width: oembed.thumbnail_width,
30
- height: oembed.thumbnail_height,
31
- },
32
- ],
33
- }),
34
- }, additionalMetaTags: oembed.thumbnail_url
35
- ? [
36
- { name: 'twitter:card', content: 'summary_large_image' },
37
- { name: 'twitter:image', content: oembed.thumbnail_url },
38
- ]
39
- : undefined, additionalLinkTags: [
40
- {
41
- rel: 'alternate',
42
- type: 'application/json',
43
- href: `${oembed.url}.json`,
44
- },
45
- ] }), _jsx(ArticleJsonLd, { url: oembed.url, title: title, images: oembed.thumbnail_url ? [oembed.thumbnail_url] : [], datePublished: published_at || '', dateModified: updated_at, authorName: [authorName], publisherName: newsroom.display_name, publisherLogo: newsroom.thumbnail_url, description: description })] }));
46
- }
47
- //# sourceMappingURL=StorySeo.js.map
7
+ export function StorySeo({
8
+ story,
9
+ noindex
10
+ }) {
11
+ const {
12
+ title,
13
+ subtitle,
14
+ published_at,
15
+ updated_at,
16
+ author,
17
+ oembed,
18
+ newsroom,
19
+ summary
20
+ } = story;
21
+ const authorName = author?.display_name || author?.email || 'Unknown';
22
+ const description = subtitle || summary;
23
+ const indexable = newsroom.is_indexable && story.visibility === Story.Visibility.PUBLIC;
24
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(NextSeo, {
25
+ title: title,
26
+ description: description,
27
+ canonical: oembed.url,
28
+ noindex: noindex ?? !indexable,
29
+ nofollow: noindex ?? !indexable,
30
+ openGraph: {
31
+ title,
32
+ description,
33
+ url: oembed.url,
34
+ site_name: newsroom.display_name,
35
+ type: 'article',
36
+ article: {
37
+ publishedTime: published_at || undefined,
38
+ modifiedTime: updated_at,
39
+ authors: [authorName]
40
+ },
41
+ ...(oembed.thumbnail_url && {
42
+ images: [{
43
+ url: oembed.thumbnail_url,
44
+ alt: oembed.title,
45
+ width: oembed.thumbnail_width,
46
+ height: oembed.thumbnail_height
47
+ }]
48
+ })
49
+ },
50
+ additionalMetaTags: oembed.thumbnail_url ? [{
51
+ name: 'twitter:card',
52
+ content: 'summary_large_image'
53
+ }, {
54
+ name: 'twitter:image',
55
+ content: oembed.thumbnail_url
56
+ }] : undefined,
57
+ additionalLinkTags: [{
58
+ rel: 'alternate',
59
+ type: 'application/json',
60
+ href: `${oembed.url}.json`
61
+ }]
62
+ }), /*#__PURE__*/React.createElement(ArticleJsonLd, {
63
+ url: oembed.url,
64
+ title: title,
65
+ images: oembed.thumbnail_url ? [oembed.thumbnail_url] : [],
66
+ datePublished: published_at || '',
67
+ dateModified: updated_at,
68
+ authorName: [authorName],
69
+ publisherName: newsroom.display_name,
70
+ publisherLogo: newsroom.thumbnail_url,
71
+ description: description
72
+ }));
73
+ }
@@ -1,2 +1 @@
1
- export { StorySeo } from './StorySeo';
2
- //# sourceMappingURL=index.js.map
1
+ export { StorySeo } from "./StorySeo.js";
@@ -1,21 +1,31 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
1
  import Document, { Head, Html, Main, NextScript } from 'next/document';
3
- import { DEFAULT_LOCALE, getLocaleDirection, LocaleObject } from '../intl';
2
+ import { DEFAULT_LOCALE, getLocaleDirection, LocaleObject } from "../intl/index.js";
4
3
  export class PrezlyThemeDocument extends Document {
5
- getLocaleCode() {
6
- const { newsroomContextProps,
7
- // eslint-disable-next-line no-underscore-dangle
8
- } = this.props.__NEXT_DATA__.props.pageProps;
9
- // In some cases (like server errors) the newsroom context props will not be loaded.
10
- // We need to fall back to default locale to keep the app working.
11
- const { localeCode } = newsroomContextProps ?? { localeCode: DEFAULT_LOCALE };
12
- return localeCode;
13
- }
14
- render() {
15
- const locale = LocaleObject.fromAnyCode(this.getLocaleCode());
16
- // TODO: The direction can be pulled from the Language object
17
- const direction = getLocaleDirection(locale);
18
- return (_jsxs(Html, { lang: locale.toHyphenCode(), dir: direction, children: [_jsx(Head, { children: _jsx("meta", { name: "og:locale", content: locale.toHyphenCode() }) }), _jsxs("body", { children: [_jsx(Main, {}), _jsx(NextScript, {})] })] }));
19
- }
20
- }
21
- //# sourceMappingURL=document.js.map
4
+ getLocaleCode() {
5
+ const {
6
+ newsroomContextProps
7
+ // eslint-disable-next-line no-underscore-dangle
8
+ } = this.props.__NEXT_DATA__.props.pageProps;
9
+
10
+ // In some cases (like server errors) the newsroom context props will not be loaded.
11
+ // We need to fall back to default locale to keep the app working.
12
+ const {
13
+ localeCode
14
+ } = newsroomContextProps ?? {
15
+ localeCode: DEFAULT_LOCALE
16
+ };
17
+ return localeCode;
18
+ }
19
+ render() {
20
+ const locale = LocaleObject.fromAnyCode(this.getLocaleCode());
21
+ // TODO: The direction can be pulled from the Language object
22
+ const direction = getLocaleDirection(locale);
23
+ return /*#__PURE__*/React.createElement(Html, {
24
+ lang: locale.toHyphenCode(),
25
+ dir: direction
26
+ }, /*#__PURE__*/React.createElement(Head, null, /*#__PURE__*/React.createElement("meta", {
27
+ name: "og:locale",
28
+ content: locale.toHyphenCode()
29
+ })), /*#__PURE__*/React.createElement("body", null, /*#__PURE__*/React.createElement(Main, null), /*#__PURE__*/React.createElement(NextScript, null)));
30
+ }
31
+ }