@prezly/theme-kit-nextjs 2.0.0-0 → 2.0.0-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 +8 -13
- package/build/@types/global.d.js +1 -0
- package/build/adapter-nextjs/api-handlers/fetchGalleries.js +26 -18
- package/build/adapter-nextjs/api-handlers/fetchStories.js +36 -20
- package/build/adapter-nextjs/api-handlers/index.js +2 -3
- package/build/adapter-nextjs/getNewsroomServerSideProps.js +15 -10
- package/build/adapter-nextjs/getNewsroomStaticProps.js +14 -10
- package/build/adapter-nextjs/index.js +6 -7
- package/build/adapter-nextjs/page-props/category.js +115 -91
- package/build/adapter-nextjs/page-props/gallery.js +85 -61
- package/build/adapter-nextjs/page-props/galleryAlbum.js +61 -44
- package/build/adapter-nextjs/page-props/home.js +81 -62
- package/build/adapter-nextjs/page-props/index.js +8 -9
- package/build/adapter-nextjs/page-props/lib/types.js +1 -2
- package/build/adapter-nextjs/page-props/search.js +23 -24
- package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js +28 -45
- package/build/adapter-nextjs/page-props/sitemap/createPaths.js +12 -14
- package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js +32 -30
- package/build/adapter-nextjs/page-props/sitemap/index.js +4 -5
- package/build/adapter-nextjs/page-props/sitemap/types.js +1 -2
- package/build/adapter-nextjs/page-props/story.js +74 -55
- package/build/adapter-nextjs/page-props/storyPreview.js +26 -21
- package/build/adapter-nextjs/processRequest.js +33 -20
- package/build/adapter-nextjs/processStaticRequest.js +18 -11
- package/build/components-nextjs/PageSeo/PageSeo.js +81 -71
- package/build/components-nextjs/PageSeo/index.js +2 -3
- package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js +4 -5
- package/build/components-nextjs/PageSeo/lib/types.js +1 -2
- package/build/components-nextjs/StorySeo/StorySeo.js +67 -41
- package/build/components-nextjs/StorySeo/index.js +1 -2
- package/build/components-nextjs/document.js +29 -19
- package/build/components-nextjs/index.js +3 -4
- package/build/data-fetching/api/PrezlyApi.js +205 -185
- package/build/data-fetching/api/getPrezlyApi.js +20 -16
- package/build/data-fetching/api/index.js +1 -2
- package/build/data-fetching/api/queries.js +71 -34
- package/build/data-fetching/index.js +3 -4
- package/build/data-fetching/lib/getAlgoliaSettings.js +21 -17
- package/build/data-fetching/lib/getEnvVariables.js +33 -29
- package/build/data-fetching/lib/index.js +4 -5
- package/build/data-fetching/lib/isSdkError.js +2 -3
- package/build/data-fetching/lib/isUuid.js +2 -3
- package/build/data-fetching/types.js +1 -2
- package/build/index.js +9 -10
- package/build/infinite-loading/index.js +4 -5
- package/build/infinite-loading/types.js +1 -2
- package/build/infinite-loading/useInfiniteGalleriesLoading.js +41 -32
- package/build/infinite-loading/useInfiniteLoading.js +48 -37
- package/build/infinite-loading/useInfiniteStoriesLoading.js +54 -44
- package/build/intl/index.d.ts +1 -1
- package/build/intl/index.js +4 -5
- package/build/intl/index.js.map +1 -1
- package/build/intl/languages.js +135 -97
- package/build/intl/languages.js.map +1 -1
- package/build/intl/locale.d.ts +0 -1
- package/build/intl/locale.js +47 -97
- package/build/intl/locale.js.map +1 -1
- package/build/intl/localeConfig.d.ts +3 -1
- package/build/intl/localeConfig.js +20 -13
- package/build/intl/localeConfig.js.map +1 -1
- package/build/intl/localeList.js +1 -108
- package/build/intl/localeObject.js +79 -74
- package/build/intl/localeObject.js.map +1 -1
- package/build/newsroom-context/context.js +34 -20
- package/build/newsroom-context/hooks/index.js +11 -12
- package/build/newsroom-context/hooks/useAlgoliaSettings.js +4 -5
- package/build/newsroom-context/hooks/useCategories.js +4 -5
- package/build/newsroom-context/hooks/useCompanyInformation.js +4 -5
- package/build/newsroom-context/hooks/useCurrentCategory.js +4 -5
- package/build/newsroom-context/hooks/useCurrentLocale.js +4 -5
- package/build/newsroom-context/hooks/useCurrentStory.js +4 -5
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js +15 -15
- package/build/newsroom-context/hooks/useGetTranslationUrl.js +48 -44
- package/build/newsroom-context/hooks/useLanguages.js +4 -5
- package/build/newsroom-context/hooks/useNewsroom.js +4 -5
- package/build/newsroom-context/hooks/useNewsroomContext.js +9 -10
- package/build/newsroom-context/index.js +2 -3
- package/build/sentry/client.js +3 -4
- package/build/sentry/common.js +25 -24
- package/build/sentry/index.js +2 -3
- package/build/sentry/server.js +3 -4
- package/build/types.js +1 -2
- package/build/utils/boilerplate.js +4 -13
- package/build/utils/constants.js +1 -2
- package/build/utils/getAssetsUrl.js +3 -4
- package/build/utils/getDataRequestLink.js +5 -7
- package/build/utils/getLocalizedCategoryData.js +30 -24
- package/build/utils/getNewsroomLogoUrl.js +12 -13
- package/build/utils/getPrivacyPortalUrl.js +10 -8
- package/build/utils/getStoryPublicationDate.js +8 -9
- package/build/utils/getUploadcareGroupUrl.js +4 -5
- package/build/utils/index.js +10 -11
- package/build/utils/isEmbargoStory.js +2 -3
- package/package.json +17 -2
- package/build/tsconfig.tsbuildinfo +0 -1
|
@@ -1,61 +1,80 @@
|
|
|
1
|
-
import { getPrezlyApi } from
|
|
2
|
-
import { DUMMY_DEFAULT_LOCALE } from
|
|
3
|
-
import { getNewsroomServerSideProps } from
|
|
4
|
-
import { getNewsroomStaticProps } from
|
|
5
|
-
import { processRequest } from
|
|
6
|
-
import { processStaticRequest } from
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
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
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
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
|
|
2
|
-
import { getNewsroomServerSideProps } from
|
|
3
|
-
import { processRequest } from
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
25
|
+
notFound: true
|
|
30
26
|
};
|
|
31
|
-
}
|
|
32
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
19
|
-
revalidate: revalidateTimeout,
|
|
22
|
+
notFound: true
|
|
20
23
|
};
|
|
21
|
-
}
|
|
22
|
-
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
props: pageProps,
|
|
27
|
+
revalidate: revalidateTimeout
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -1,79 +1,89 @@
|
|
|
1
|
-
|
|
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
|
|
6
|
-
import { useCompanyInformation, useCurrentLocale, useCurrentStory, useGetLinkLocaleSlug, useGetTranslationUrl, useLanguages, useNewsroom
|
|
7
|
-
import { getNewsroomLogoUrl } from
|
|
8
|
-
import { getAbsoluteUrl } from
|
|
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({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
newsroom.url,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
|
2
|
-
export * from
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
|
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
|
|
2
|
+
import { DEFAULT_LOCALE, getLocaleDirection, LocaleObject } from "../intl/index.js";
|
|
4
3
|
export class PrezlyThemeDocument extends Document {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
+
}
|