@prezly/theme-kit-nextjs 2.0.1-0 → 2.0.1-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.
- package/build/@types/global.d.js +1 -1
- package/build/adapter-nextjs/api-handlers/fetchGalleries.js +9 -3
- package/build/adapter-nextjs/api-handlers/fetchStories.js +9 -3
- package/build/adapter-nextjs/api-handlers/index.js +19 -2
- package/build/adapter-nextjs/getNewsroomServerSideProps.js +9 -3
- package/build/adapter-nextjs/getNewsroomStaticProps.js +9 -3
- package/build/adapter-nextjs/index.js +71 -6
- package/build/adapter-nextjs/page-props/category.js +27 -19
- package/build/adapter-nextjs/page-props/gallery.js +20 -13
- package/build/adapter-nextjs/page-props/galleryAlbum.js +21 -13
- package/build/adapter-nextjs/page-props/home.js +20 -13
- package/build/adapter-nextjs/page-props/index.js +138 -8
- package/build/adapter-nextjs/page-props/lib/types.js +1 -1
- package/build/adapter-nextjs/page-props/search.js +17 -10
- package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js +9 -2
- package/build/adapter-nextjs/page-props/sitemap/createPaths.js +7 -1
- package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js +13 -7
- package/build/adapter-nextjs/page-props/sitemap/index.js +43 -4
- package/build/adapter-nextjs/page-props/sitemap/types.js +1 -1
- package/build/adapter-nextjs/page-props/story.js +25 -17
- package/build/adapter-nextjs/page-props/storyPreview.js +13 -7
- package/build/adapter-nextjs/processRequest.js +11 -5
- package/build/adapter-nextjs/processStaticRequest.js +7 -1
- package/build/components-nextjs/PageSeo/PageSeo.js +30 -24
- package/build/components-nextjs/PageSeo/index.js +27 -2
- package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js +7 -1
- package/build/components-nextjs/PageSeo/lib/types.js +1 -1
- package/build/components-nextjs/StorySeo/StorySeo.js +12 -6
- package/build/components-nextjs/StorySeo/index.js +12 -1
- package/build/components-nextjs/document.js +19 -10
- package/build/components-nextjs/index.js +26 -3
- package/build/data-fetching/api/PrezlyApi.js +37 -30
- package/build/data-fetching/api/getPrezlyApi.js +11 -5
- package/build/data-fetching/api/index.js +16 -1
- package/build/data-fetching/api/queries.js +15 -5
- package/build/data-fetching/index.js +38 -3
- package/build/data-fetching/lib/getAlgoliaSettings.js +9 -3
- package/build/data-fetching/lib/getEnvVariables.js +10 -3
- package/build/data-fetching/lib/index.js +33 -4
- package/build/data-fetching/lib/isSdkError.js +7 -1
- package/build/data-fetching/lib/isUuid.js +7 -1
- package/build/data-fetching/types.js +1 -1
- package/build/index.js +104 -9
- package/build/infinite-loading/index.js +43 -4
- package/build/infinite-loading/types.js +1 -1
- package/build/infinite-loading/useInfiniteGalleriesLoading.js +9 -3
- package/build/infinite-loading/useInfiniteLoading.js +15 -9
- package/build/infinite-loading/useInfiniteStoriesLoading.js +13 -7
- package/build/intl/index.js +49 -4
- package/build/intl/languages.js +39 -23
- package/build/intl/locale.js +20 -10
- package/build/intl/localeConfig.js +14 -5
- package/build/intl/localeList.js +8 -1
- package/build/intl/localeObject.js +11 -4
- package/build/newsroom-context/context.js +13 -5
- package/build/newsroom-context/hooks/index.js +126 -11
- package/build/newsroom-context/hooks/useAlgoliaSettings.js +9 -3
- package/build/newsroom-context/hooks/useCategories.js +9 -3
- package/build/newsroom-context/hooks/useCompanyInformation.js +9 -3
- package/build/newsroom-context/hooks/useCurrentCategory.js +9 -3
- package/build/newsroom-context/hooks/useCurrentLocale.js +9 -3
- package/build/newsroom-context/hooks/useCurrentStory.js +9 -3
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js +16 -10
- package/build/newsroom-context/hooks/useGetTranslationUrl.js +26 -20
- package/build/newsroom-context/hooks/useLanguages.js +9 -3
- package/build/newsroom-context/hooks/useNewsroom.js +9 -3
- package/build/newsroom-context/hooks/useNewsroomContext.js +10 -4
- package/build/newsroom-context/index.js +34 -2
- package/build/sentry/client.js +9 -3
- package/build/sentry/common.js +7 -1
- package/build/sentry/index.js +19 -2
- package/build/sentry/server.js +9 -3
- package/build/types.js +1 -1
- package/build/utils/boilerplate.js +11 -3
- package/build/utils/constants.js +12 -3
- package/build/utils/getAssetsUrl.js +9 -3
- package/build/utils/getDataRequestLink.js +9 -3
- package/build/utils/getLocalizedCategoryData.js +11 -3
- package/build/utils/getNewsroomLogoUrl.js +12 -5
- package/build/utils/getPrivacyPortalUrl.js +7 -1
- package/build/utils/getStoryPublicationDate.js +7 -1
- package/build/utils/getUploadcareGroupUrl.js +9 -3
- package/build/utils/index.js +115 -10
- package/build/utils/isEmbargoStory.js +7 -1
- package/package.json +2 -3
|
@@ -1,24 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getSearchPageServerSideProps = getSearchPageServerSideProps;
|
|
7
|
+
exports.getSearchPageStaticProps = getSearchPageStaticProps;
|
|
8
|
+
var _getNewsroomServerSideProps = require("../getNewsroomServerSideProps.js");
|
|
9
|
+
var _getNewsroomStaticProps = require("../getNewsroomStaticProps.js");
|
|
10
|
+
var _processRequest = require("../processRequest.js");
|
|
11
|
+
var _processStaticRequest = require("../processStaticRequest.js");
|
|
12
|
+
function getSearchPageServerSideProps(customProps) {
|
|
6
13
|
return async function getServerSideProps(context) {
|
|
7
14
|
const {
|
|
8
15
|
serverSideProps
|
|
9
|
-
} = await getNewsroomServerSideProps(context);
|
|
10
|
-
return processRequest(context, {
|
|
16
|
+
} = await (0, _getNewsroomServerSideProps.getNewsroomServerSideProps)(context);
|
|
17
|
+
return (0, _processRequest.processRequest)(context, {
|
|
11
18
|
...serverSideProps,
|
|
12
19
|
...(typeof customProps === 'function' ? await customProps(context, serverSideProps) : customProps)
|
|
13
20
|
}, '/search');
|
|
14
21
|
};
|
|
15
22
|
}
|
|
16
|
-
|
|
23
|
+
function getSearchPageStaticProps(customProps) {
|
|
17
24
|
return async function getStaticProps(context) {
|
|
18
25
|
const {
|
|
19
26
|
staticProps
|
|
20
|
-
} = await getNewsroomStaticProps(context);
|
|
21
|
-
return processStaticRequest(context, {
|
|
27
|
+
} = await (0, _getNewsroomStaticProps.getNewsroomStaticProps)(context);
|
|
28
|
+
return (0, _processStaticRequest.processStaticRequest)(context, {
|
|
22
29
|
...staticProps,
|
|
23
30
|
...(typeof customProps === 'function' ? await customProps(context, staticProps) : customProps)
|
|
24
31
|
});
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SitemapBuilder = void 0;
|
|
7
|
+
class SitemapBuilder {
|
|
2
8
|
urls = [];
|
|
3
9
|
constructor(baseUrl) {
|
|
4
10
|
this.baseUrl = baseUrl;
|
|
@@ -27,4 +33,5 @@ export class SitemapBuilder {
|
|
|
27
33
|
serialize() {
|
|
28
34
|
return ['<?xml version="1.0" encoding="UTF-8" ?>', '<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">', this.urls.map(SitemapBuilder.serializeLocation).join('\n'), '</urlset>'].join('\n');
|
|
29
35
|
}
|
|
30
|
-
}
|
|
36
|
+
}
|
|
37
|
+
exports.SitemapBuilder = SitemapBuilder;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createPaths = createPaths;
|
|
7
|
+
function createPaths(stories, categories) {
|
|
2
8
|
const storiesUrls = stories.map(({
|
|
3
9
|
slug
|
|
4
10
|
}) => `/${slug}`);
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getSitemapServerSideProps = getSitemapServerSideProps;
|
|
7
|
+
var _index = require("../../../data-fetching/index.js");
|
|
8
|
+
var _createPaths = require("./createPaths.js");
|
|
9
|
+
var _SitemapBuilder = require("./SitemapBuilder.js");
|
|
10
|
+
function getSitemapServerSideProps(additionalPaths) {
|
|
5
11
|
return async function getServerSideProps(ctx) {
|
|
6
12
|
const {
|
|
7
13
|
res,
|
|
@@ -14,11 +20,11 @@ export function getSitemapServerSideProps(additionalPaths) {
|
|
|
14
20
|
};
|
|
15
21
|
}
|
|
16
22
|
const baseUrl = req.headers.host || '/';
|
|
17
|
-
const api = getPrezlyApi(req);
|
|
23
|
+
const api = (0, _index.getPrezlyApi)(req);
|
|
18
24
|
const stories = await api.getAllStories();
|
|
19
25
|
const categories = await api.getCategories();
|
|
20
|
-
const paths = createPaths(stories, categories);
|
|
21
|
-
const sitemapBuilder = new SitemapBuilder(baseUrl);
|
|
26
|
+
const paths = (0, _createPaths.createPaths)(stories, categories);
|
|
27
|
+
const sitemapBuilder = new _SitemapBuilder.SitemapBuilder(baseUrl);
|
|
22
28
|
sitemapBuilder.addUrl('/');
|
|
23
29
|
paths.forEach(path => sitemapBuilder.addUrl(path));
|
|
24
30
|
if (additionalPaths) {
|
|
@@ -1,4 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
getSitemapServerSideProps: true,
|
|
8
|
+
SitemapBuilder: true,
|
|
9
|
+
createPaths: true
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "SitemapBuilder", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () {
|
|
14
|
+
return _SitemapBuilder.SitemapBuilder;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "createPaths", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () {
|
|
20
|
+
return _createPaths.createPaths;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "getSitemapServerSideProps", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () {
|
|
26
|
+
return _getServerSideProps.getSitemapServerSideProps;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
var _getServerSideProps = require("./getServerSideProps.js");
|
|
30
|
+
var _SitemapBuilder = require("./SitemapBuilder.js");
|
|
31
|
+
var _createPaths = require("./createPaths.js");
|
|
32
|
+
var _types = require("./types.js");
|
|
33
|
+
Object.keys(_types).forEach(function (key) {
|
|
34
|
+
if (key === "default" || key === "__esModule") return;
|
|
35
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
36
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
37
|
+
Object.defineProperty(exports, key, {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () {
|
|
40
|
+
return _types[key];
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getStoryPageServerSideProps = getStoryPageServerSideProps;
|
|
7
|
+
exports.getStoryPageStaticPaths = getStoryPageStaticPaths;
|
|
8
|
+
exports.getStoryPageStaticProps = getStoryPageStaticProps;
|
|
9
|
+
var _index = require("../../data-fetching/index.js");
|
|
10
|
+
var _index2 = require("../../intl/index.js");
|
|
11
|
+
var _getNewsroomServerSideProps = require("../getNewsroomServerSideProps.js");
|
|
12
|
+
var _getNewsroomStaticProps = require("../getNewsroomStaticProps.js");
|
|
13
|
+
var _processRequest = require("../processRequest.js");
|
|
14
|
+
var _processStaticRequest = require("../processStaticRequest.js");
|
|
15
|
+
function getStoryPageServerSideProps(customProps) {
|
|
8
16
|
return async function getServerSideProps(context) {
|
|
9
|
-
const api = getPrezlyApi(context.req);
|
|
17
|
+
const api = (0, _index.getPrezlyApi)(context.req);
|
|
10
18
|
const {
|
|
11
19
|
slug
|
|
12
20
|
} = context.params;
|
|
@@ -18,13 +26,13 @@ export function getStoryPageServerSideProps(customProps) {
|
|
|
18
26
|
}
|
|
19
27
|
const {
|
|
20
28
|
serverSideProps
|
|
21
|
-
} = await getNewsroomServerSideProps(context, {
|
|
29
|
+
} = await (0, _getNewsroomServerSideProps.getNewsroomServerSideProps)(context, {
|
|
22
30
|
story
|
|
23
31
|
});
|
|
24
32
|
const {
|
|
25
33
|
locale
|
|
26
34
|
} = context;
|
|
27
|
-
if (locale && locale !== DUMMY_DEFAULT_LOCALE) {
|
|
35
|
+
if (locale && locale !== _index2.DUMMY_DEFAULT_LOCALE) {
|
|
28
36
|
return {
|
|
29
37
|
redirect: {
|
|
30
38
|
destination: `/${slug}`,
|
|
@@ -33,15 +41,15 @@ export function getStoryPageServerSideProps(customProps) {
|
|
|
33
41
|
};
|
|
34
42
|
}
|
|
35
43
|
serverSideProps.newsroomContextProps.currentStory = story;
|
|
36
|
-
return processRequest(context, {
|
|
44
|
+
return (0, _processRequest.processRequest)(context, {
|
|
37
45
|
...serverSideProps,
|
|
38
46
|
...(typeof customProps === 'function' ? await customProps(context, serverSideProps) : customProps)
|
|
39
47
|
});
|
|
40
48
|
};
|
|
41
49
|
}
|
|
42
|
-
|
|
50
|
+
function getStoryPageStaticProps(customProps) {
|
|
43
51
|
return async function getStaticProps(context) {
|
|
44
|
-
const api = getPrezlyApi();
|
|
52
|
+
const api = (0, _index.getPrezlyApi)();
|
|
45
53
|
const {
|
|
46
54
|
slug
|
|
47
55
|
} = context.params;
|
|
@@ -53,18 +61,18 @@ export function getStoryPageStaticProps(customProps) {
|
|
|
53
61
|
}
|
|
54
62
|
const {
|
|
55
63
|
staticProps
|
|
56
|
-
} = await getNewsroomStaticProps(context, {
|
|
64
|
+
} = await (0, _getNewsroomStaticProps.getNewsroomStaticProps)(context, {
|
|
57
65
|
story
|
|
58
66
|
});
|
|
59
67
|
staticProps.newsroomContextProps.currentStory = story;
|
|
60
|
-
return processStaticRequest(context, {
|
|
68
|
+
return (0, _processStaticRequest.processStaticRequest)(context, {
|
|
61
69
|
...staticProps,
|
|
62
70
|
...(typeof customProps === 'function' ? await customProps(context, staticProps) : customProps)
|
|
63
71
|
});
|
|
64
72
|
};
|
|
65
73
|
}
|
|
66
|
-
|
|
67
|
-
const api = getPrezlyApi();
|
|
74
|
+
async function getStoryPageStaticPaths() {
|
|
75
|
+
const api = (0, _index.getPrezlyApi)();
|
|
68
76
|
const stories = await api.getAllStories();
|
|
69
77
|
const paths = stories.map(({
|
|
70
78
|
slug
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getStoryPreviewPageServerSideProps = getStoryPreviewPageServerSideProps;
|
|
7
|
+
var _index = require("../../data-fetching/index.js");
|
|
8
|
+
var _getNewsroomServerSideProps = require("../getNewsroomServerSideProps.js");
|
|
9
|
+
var _processRequest = require("../processRequest.js");
|
|
10
|
+
function getStoryPreviewPageServerSideProps(customProps) {
|
|
5
11
|
return async function getServerSideProps(context) {
|
|
6
|
-
const api = getPrezlyApi(context.req);
|
|
12
|
+
const api = (0, _index.getPrezlyApi)(context.req);
|
|
7
13
|
const {
|
|
8
14
|
uuid
|
|
9
15
|
} = context.params;
|
|
@@ -15,11 +21,11 @@ export function getStoryPreviewPageServerSideProps(customProps) {
|
|
|
15
21
|
}
|
|
16
22
|
const {
|
|
17
23
|
serverSideProps
|
|
18
|
-
} = await getNewsroomServerSideProps(context, {
|
|
24
|
+
} = await (0, _getNewsroomServerSideProps.getNewsroomServerSideProps)(context, {
|
|
19
25
|
story
|
|
20
26
|
});
|
|
21
27
|
serverSideProps.newsroomContextProps.currentStory = story;
|
|
22
|
-
return processRequest(context, {
|
|
28
|
+
return (0, _processRequest.processRequest)(context, {
|
|
23
29
|
...serverSideProps,
|
|
24
30
|
...(typeof customProps === 'function' ? await customProps(context, serverSideProps) : customProps)
|
|
25
31
|
});
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.processRequest = processRequest;
|
|
7
|
+
var _index = require("../intl/index.js");
|
|
2
8
|
/**
|
|
3
9
|
* This function combines the props returned from `getNewsroomServerSideProps` and your optional custom props for the page.
|
|
4
10
|
* It also handles locale redirects, if `canonicalUrl` parameter is provided.
|
|
@@ -8,7 +14,7 @@ import { getRedirectToCanonicalLocale, getShortestLocaleCode, LocaleObject } fro
|
|
|
8
14
|
* @param props Object containing the return of `getNewsroomServerSideProps` and your optional custom props.
|
|
9
15
|
* @param canonicalUrl Optional: a canonical URL for the current page without locale part. If provided, locale redirects will be handled by the function.
|
|
10
16
|
*/
|
|
11
|
-
|
|
17
|
+
function processRequest(context, props, canonicalUrl) {
|
|
12
18
|
const {
|
|
13
19
|
locale: nextLocale,
|
|
14
20
|
query
|
|
@@ -30,9 +36,9 @@ export function processRequest(context, props, canonicalUrl) {
|
|
|
30
36
|
languages,
|
|
31
37
|
localeCode
|
|
32
38
|
} = pageProps.newsroomContextProps;
|
|
33
|
-
const currentLocale = LocaleObject.fromAnyCode(localeCode);
|
|
34
|
-
const shortestLocaleCode = getShortestLocaleCode(languages, currentLocale);
|
|
35
|
-
const redirect = getRedirectToCanonicalLocale(shortestLocaleCode, nextLocale, canonicalUrl, query);
|
|
39
|
+
const currentLocale = _index.LocaleObject.fromAnyCode(localeCode);
|
|
40
|
+
const shortestLocaleCode = (0, _index.getShortestLocaleCode)(languages, currentLocale);
|
|
41
|
+
const redirect = (0, _index.getRedirectToCanonicalLocale)(shortestLocaleCode, nextLocale, canonicalUrl, query);
|
|
36
42
|
if (redirect) {
|
|
37
43
|
return {
|
|
38
44
|
redirect
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.processStaticRequest = processStaticRequest;
|
|
1
7
|
/**
|
|
2
8
|
* This function combines the props returned from `getNewsroomStaticProps` and your optional custom props for the page.
|
|
3
9
|
* See README for usage examples.
|
|
@@ -6,7 +12,7 @@
|
|
|
6
12
|
* @param props Object containing the return of `getNewsroomServerSideProps` and your optional custom props.
|
|
7
13
|
* @param revalidateTimeout Optional: timeout in seconds to use with Next ISR.
|
|
8
14
|
*/
|
|
9
|
-
|
|
15
|
+
function processStaticRequest(context, props, revalidateTimeout) {
|
|
10
16
|
const {
|
|
11
17
|
locale: nextLocale
|
|
12
18
|
} = context;
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PageSeo = PageSeo;
|
|
7
|
+
var _nextSeo = require("next-seo");
|
|
8
|
+
var _router = require("next/router");
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _index = require("../../intl/index.js");
|
|
11
|
+
var _index2 = require("../../newsroom-context/index.js");
|
|
12
|
+
var _index3 = require("../../utils/index.js");
|
|
13
|
+
var _getAbsoluteUrl = require("./lib/getAbsoluteUrl.js");
|
|
1
14
|
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
|
-
import { NextSeo } from 'next-seo';
|
|
3
|
-
import { useRouter } from "next/router.js";
|
|
4
|
-
import { useMemo } from 'react';
|
|
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
15
|
/**
|
|
10
16
|
* This component provides base page attributes for every Newsroom page.
|
|
11
17
|
* It depends on information from NewsroomContext, so the component should be placed inside the `NewsroomContextProvider`.
|
|
12
18
|
* You can pass additional props expected by NextSeo component to override any info that is provided by the NewsroomContext.
|
|
13
19
|
*/
|
|
14
|
-
|
|
20
|
+
function PageSeo({
|
|
15
21
|
title,
|
|
16
22
|
description,
|
|
17
23
|
imageUrl,
|
|
@@ -20,39 +26,39 @@ export function PageSeo({
|
|
|
20
26
|
twitter,
|
|
21
27
|
...nextSeoProps
|
|
22
28
|
}) {
|
|
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();
|
|
29
|
+
const companyInformation = (0, _index2.useCompanyInformation)();
|
|
30
|
+
const newsroom = (0, _index2.useNewsroom)();
|
|
31
|
+
const currentLocale = (0, _index2.useCurrentLocale)();
|
|
32
|
+
const languages = (0, _index2.useLanguages)();
|
|
33
|
+
const getTranslationUrl = (0, _index2.useGetTranslationUrl)();
|
|
34
|
+
const getLinkLocaleSlug = (0, _index2.useGetLinkLocaleSlug)();
|
|
35
|
+
const currentStory = (0, _index2.useCurrentStory)();
|
|
30
36
|
const {
|
|
31
37
|
asPath
|
|
32
|
-
} = useRouter();
|
|
38
|
+
} = (0, _router.useRouter)();
|
|
33
39
|
const pageTitle = title || companyInformation.name;
|
|
34
40
|
const pageDescription = description || companyInformation.about_plaintext;
|
|
35
|
-
const canonicalUrl = canonical || getAbsoluteUrl(asPath, newsroom.url, getLinkLocaleSlug(currentLocale));
|
|
41
|
+
const canonicalUrl = canonical || (0, _getAbsoluteUrl.getAbsoluteUrl)(asPath, newsroom.url, getLinkLocaleSlug(currentLocale));
|
|
36
42
|
const siteName = companyInformation.name;
|
|
37
|
-
const logoUrl = imageUrl || getNewsroomLogoUrl(newsroom);
|
|
38
|
-
const alternateLanguageLinks = useMemo(() => {
|
|
43
|
+
const logoUrl = imageUrl || (0, _index3.getNewsroomLogoUrl)(newsroom);
|
|
44
|
+
const alternateLanguageLinks = (0, _react.useMemo)(() => {
|
|
39
45
|
if (!languages.length) {
|
|
40
46
|
return [];
|
|
41
47
|
}
|
|
42
|
-
const alternateLanguages = getUsedLanguages(languages).filter(language => language.code !== currentLocale.toUnderscoreCode());
|
|
48
|
+
const alternateLanguages = (0, _index.getUsedLanguages)(languages).filter(language => language.code !== currentLocale.toUnderscoreCode());
|
|
43
49
|
return alternateLanguages.map(language => {
|
|
44
|
-
const locale = LocaleObject.fromAnyCode(language.code);
|
|
50
|
+
const locale = _index.LocaleObject.fromAnyCode(language.code);
|
|
45
51
|
const translationLink = getTranslationUrl(locale, true);
|
|
46
52
|
if (!translationLink) {
|
|
47
53
|
return undefined;
|
|
48
54
|
}
|
|
49
55
|
return {
|
|
50
56
|
hrefLang: locale.toHyphenCode(),
|
|
51
|
-
href: getAbsoluteUrl(translationLink, newsroom.url, currentStory && translationLink !== '/' ? false : getLinkLocaleSlug(locale))
|
|
57
|
+
href: (0, _getAbsoluteUrl.getAbsoluteUrl)(translationLink, newsroom.url, currentStory && translationLink !== '/' ? false : getLinkLocaleSlug(locale))
|
|
52
58
|
};
|
|
53
59
|
}).filter(Boolean);
|
|
54
60
|
}, [currentLocale, getLinkLocaleSlug, getTranslationUrl, languages, newsroom.url, currentStory]);
|
|
55
|
-
return /*#__PURE__*/React.createElement(NextSeo, _extends({
|
|
61
|
+
return /*#__PURE__*/React.createElement(_nextSeo.NextSeo, _extends({
|
|
56
62
|
title: pageTitle,
|
|
57
63
|
description: pageDescription,
|
|
58
64
|
canonical: canonicalUrl,
|
|
@@ -82,7 +88,7 @@ export function PageSeo({
|
|
|
82
88
|
additionalLinkTags: [{
|
|
83
89
|
rel: 'alternate',
|
|
84
90
|
type: 'application/rss+xml',
|
|
85
|
-
href: getAbsoluteUrl('/feed', newsroom.url)
|
|
91
|
+
href: (0, _getAbsoluteUrl.getAbsoluteUrl)('/feed', newsroom.url)
|
|
86
92
|
}],
|
|
87
93
|
languageAlternates: alternateLanguageLinks
|
|
88
94
|
}, nextSeoProps));
|
|
@@ -1,2 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
PageSeo: true
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "PageSeo", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return _PageSeo.PageSeo;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
var _PageSeo = require("./PageSeo.js");
|
|
16
|
+
var _types = require("./lib/types.js");
|
|
17
|
+
Object.keys(_types).forEach(function (key) {
|
|
18
|
+
if (key === "default" || key === "__esModule") return;
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
20
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _types[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getAbsoluteUrl = getAbsoluteUrl;
|
|
1
7
|
// Returns absolute URL based on the path and without any query parameters
|
|
2
|
-
|
|
8
|
+
function getAbsoluteUrl(path, origin, localeCode) {
|
|
3
9
|
const url = new URL(`${localeCode ? `/${localeCode}` : ''}${path || '/'}`, origin);
|
|
4
10
|
url.search = '';
|
|
5
11
|
return url.toString();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.StorySeo = StorySeo;
|
|
7
|
+
var _sdk = require("@prezly/sdk");
|
|
8
|
+
var _nextSeo = require("next-seo");
|
|
3
9
|
/**
|
|
4
10
|
* This components provides additional page attributes for the Story page.
|
|
5
11
|
* It works in conjunction with `PageSeo` component, overidding some of its attributes.
|
|
6
12
|
*/
|
|
7
|
-
|
|
13
|
+
function StorySeo({
|
|
8
14
|
story,
|
|
9
15
|
noindex
|
|
10
16
|
}) {
|
|
@@ -20,8 +26,8 @@ export function StorySeo({
|
|
|
20
26
|
} = story;
|
|
21
27
|
const authorName = author?.display_name || author?.email || 'Unknown';
|
|
22
28
|
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, {
|
|
29
|
+
const indexable = newsroom.is_indexable && story.visibility === _sdk.Story.Visibility.PUBLIC;
|
|
30
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_nextSeo.NextSeo, {
|
|
25
31
|
title: title,
|
|
26
32
|
description: description,
|
|
27
33
|
canonical: oembed.url,
|
|
@@ -59,7 +65,7 @@ export function StorySeo({
|
|
|
59
65
|
type: 'application/json',
|
|
60
66
|
href: `${oembed.url}.json`
|
|
61
67
|
}]
|
|
62
|
-
}), /*#__PURE__*/React.createElement(ArticleJsonLd, {
|
|
68
|
+
}), /*#__PURE__*/React.createElement(_nextSeo.ArticleJsonLd, {
|
|
63
69
|
url: oembed.url,
|
|
64
70
|
title: title,
|
|
65
71
|
images: oembed.thumbnail_url ? [oembed.thumbnail_url] : [],
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "StorySeo", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _StorySeo.StorySeo;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _StorySeo = require("./StorySeo.js");
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PrezlyThemeDocument = void 0;
|
|
7
|
+
var _document = _interopRequireWildcard(require("next/document"));
|
|
8
|
+
var _index = require("../intl/index.js");
|
|
9
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
|
+
class PrezlyThemeDocument extends _document.default {
|
|
4
12
|
getLocaleCode() {
|
|
5
13
|
const {
|
|
6
14
|
newsroomContextProps
|
|
@@ -12,20 +20,21 @@ export class PrezlyThemeDocument extends Document {
|
|
|
12
20
|
const {
|
|
13
21
|
localeCode
|
|
14
22
|
} = newsroomContextProps ?? {
|
|
15
|
-
localeCode: DEFAULT_LOCALE
|
|
23
|
+
localeCode: _index.DEFAULT_LOCALE
|
|
16
24
|
};
|
|
17
25
|
return localeCode;
|
|
18
26
|
}
|
|
19
27
|
render() {
|
|
20
|
-
const locale = LocaleObject.fromAnyCode(this.getLocaleCode());
|
|
28
|
+
const locale = _index.LocaleObject.fromAnyCode(this.getLocaleCode());
|
|
21
29
|
// TODO: The direction can be pulled from the Language object
|
|
22
|
-
const direction = getLocaleDirection(locale);
|
|
23
|
-
return /*#__PURE__*/React.createElement(Html, {
|
|
30
|
+
const direction = (0, _index.getLocaleDirection)(locale);
|
|
31
|
+
return /*#__PURE__*/React.createElement(_document.Html, {
|
|
24
32
|
lang: locale.toHyphenCode(),
|
|
25
33
|
dir: direction
|
|
26
|
-
}, /*#__PURE__*/React.createElement(Head, null, /*#__PURE__*/React.createElement("meta", {
|
|
34
|
+
}, /*#__PURE__*/React.createElement(_document.Head, null, /*#__PURE__*/React.createElement("meta", {
|
|
27
35
|
name: "og:locale",
|
|
28
36
|
content: locale.toHyphenCode()
|
|
29
|
-
})), /*#__PURE__*/React.createElement("body", null, /*#__PURE__*/React.createElement(Main, null), /*#__PURE__*/React.createElement(NextScript, null)));
|
|
37
|
+
})), /*#__PURE__*/React.createElement("body", null, /*#__PURE__*/React.createElement(_document.Main, null), /*#__PURE__*/React.createElement(_document.NextScript, null)));
|
|
30
38
|
}
|
|
31
|
-
}
|
|
39
|
+
}
|
|
40
|
+
exports.PrezlyThemeDocument = PrezlyThemeDocument;
|
|
@@ -1,3 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "PageSeo", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _index.PageSeo;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "PrezlyThemeDocument", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _document.PrezlyThemeDocument;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "StorySeo", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _index2.StorySeo;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var _index = require("./PageSeo/index.js");
|
|
25
|
+
var _index2 = require("./StorySeo/index.js");
|
|
26
|
+
var _document = require("./document.js");
|