@prezly/theme-kit-nextjs 2.0.1-1 → 2.0.1-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/build/@types/global.d.js +1 -1
- package/build/adapter-nextjs/api-handlers/fetchGalleries.js +3 -9
- package/build/adapter-nextjs/api-handlers/fetchStories.js +3 -9
- package/build/adapter-nextjs/api-handlers/index.js +2 -19
- package/build/adapter-nextjs/getNewsroomServerSideProps.js +3 -9
- package/build/adapter-nextjs/getNewsroomStaticProps.js +3 -9
- package/build/adapter-nextjs/index.js +6 -71
- package/build/adapter-nextjs/page-props/category.js +19 -27
- package/build/adapter-nextjs/page-props/gallery.js +13 -20
- package/build/adapter-nextjs/page-props/galleryAlbum.js +13 -21
- package/build/adapter-nextjs/page-props/home.js +13 -20
- package/build/adapter-nextjs/page-props/index.js +8 -138
- package/build/adapter-nextjs/page-props/lib/types.js +1 -1
- package/build/adapter-nextjs/page-props/search.js +10 -17
- package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js +2 -9
- package/build/adapter-nextjs/page-props/sitemap/createPaths.js +1 -7
- package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js +7 -13
- package/build/adapter-nextjs/page-props/sitemap/index.js +4 -43
- package/build/adapter-nextjs/page-props/sitemap/types.js +1 -1
- package/build/adapter-nextjs/page-props/story.js +17 -25
- package/build/adapter-nextjs/page-props/storyPreview.js +7 -13
- package/build/adapter-nextjs/processRequest.js +5 -11
- package/build/adapter-nextjs/processStaticRequest.js +1 -7
- package/build/components-nextjs/PageSeo/PageSeo.js +24 -30
- package/build/components-nextjs/PageSeo/index.js +2 -27
- package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js +1 -7
- package/build/components-nextjs/PageSeo/lib/types.js +1 -1
- package/build/components-nextjs/StorySeo/StorySeo.js +6 -12
- package/build/components-nextjs/StorySeo/index.js +1 -12
- package/build/components-nextjs/document.d.ts +4 -2
- package/build/components-nextjs/document.js +13 -19
- package/build/components-nextjs/document.js.map +1 -1
- package/build/components-nextjs/index.js +3 -26
- package/build/data-fetching/api/PrezlyApi.js +30 -37
- package/build/data-fetching/api/getPrezlyApi.js +5 -11
- package/build/data-fetching/api/index.js +1 -16
- package/build/data-fetching/api/queries.js +5 -15
- package/build/data-fetching/index.js +3 -38
- package/build/data-fetching/lib/getAlgoliaSettings.js +3 -9
- package/build/data-fetching/lib/getEnvVariables.js +3 -10
- package/build/data-fetching/lib/index.js +4 -33
- package/build/data-fetching/lib/isSdkError.js +1 -7
- package/build/data-fetching/lib/isUuid.js +1 -7
- package/build/data-fetching/types.js +1 -1
- package/build/index.js +9 -104
- package/build/infinite-loading/index.js +4 -43
- package/build/infinite-loading/types.js +1 -1
- package/build/infinite-loading/useInfiniteGalleriesLoading.js +3 -9
- package/build/infinite-loading/useInfiniteLoading.js +9 -15
- package/build/infinite-loading/useInfiniteStoriesLoading.js +7 -13
- package/build/intl/index.js +4 -49
- package/build/intl/languages.js +23 -39
- package/build/intl/locale.js +10 -20
- package/build/intl/localeConfig.js +5 -14
- package/build/intl/localeList.js +1 -8
- package/build/intl/localeObject.js +4 -11
- package/build/newsroom-context/context.js +5 -13
- package/build/newsroom-context/hooks/index.js +11 -126
- package/build/newsroom-context/hooks/useAlgoliaSettings.js +3 -9
- package/build/newsroom-context/hooks/useCategories.js +3 -9
- package/build/newsroom-context/hooks/useCompanyInformation.js +3 -9
- package/build/newsroom-context/hooks/useCurrentCategory.js +3 -9
- package/build/newsroom-context/hooks/useCurrentLocale.js +3 -9
- package/build/newsroom-context/hooks/useCurrentStory.js +3 -9
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js +10 -16
- package/build/newsroom-context/hooks/useGetTranslationUrl.js +20 -26
- package/build/newsroom-context/hooks/useLanguages.js +3 -9
- package/build/newsroom-context/hooks/useNewsroom.js +3 -9
- package/build/newsroom-context/hooks/useNewsroomContext.js +4 -10
- package/build/newsroom-context/index.js +2 -34
- package/build/sentry/client.js +3 -9
- package/build/sentry/common.js +1 -7
- package/build/sentry/index.js +2 -19
- package/build/sentry/server.js +3 -9
- package/build/types.js +1 -1
- package/build/utils/boilerplate.js +3 -11
- package/build/utils/constants.js +3 -12
- package/build/utils/getAssetsUrl.js +3 -9
- package/build/utils/getDataRequestLink.js +3 -9
- package/build/utils/getLocalizedCategoryData.js +3 -11
- package/build/utils/getNewsroomLogoUrl.js +5 -12
- package/build/utils/getPrivacyPortalUrl.js +1 -7
- package/build/utils/getStoryPublicationDate.js +1 -7
- package/build/utils/getUploadcareGroupUrl.js +3 -9
- package/build/utils/index.js +10 -115
- package/build/utils/isEmbargoStory.js +1 -7
- package/package.json +3 -2
|
@@ -1,31 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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) {
|
|
1
|
+
import { getNewsroomServerSideProps } from "../getNewsroomServerSideProps.js";
|
|
2
|
+
import { getNewsroomStaticProps } from "../getNewsroomStaticProps.js";
|
|
3
|
+
import { processRequest } from "../processRequest.js";
|
|
4
|
+
import { processStaticRequest } from "../processStaticRequest.js";
|
|
5
|
+
export function getSearchPageServerSideProps(customProps) {
|
|
13
6
|
return async function getServerSideProps(context) {
|
|
14
7
|
const {
|
|
15
8
|
serverSideProps
|
|
16
|
-
} = await
|
|
17
|
-
return
|
|
9
|
+
} = await getNewsroomServerSideProps(context);
|
|
10
|
+
return processRequest(context, {
|
|
18
11
|
...serverSideProps,
|
|
19
12
|
...(typeof customProps === 'function' ? await customProps(context, serverSideProps) : customProps)
|
|
20
13
|
}, '/search');
|
|
21
14
|
};
|
|
22
15
|
}
|
|
23
|
-
function getSearchPageStaticProps(customProps) {
|
|
16
|
+
export function getSearchPageStaticProps(customProps) {
|
|
24
17
|
return async function getStaticProps(context) {
|
|
25
18
|
const {
|
|
26
19
|
staticProps
|
|
27
|
-
} = await
|
|
28
|
-
return
|
|
20
|
+
} = await getNewsroomStaticProps(context);
|
|
21
|
+
return processStaticRequest(context, {
|
|
29
22
|
...staticProps,
|
|
30
23
|
...(typeof customProps === 'function' ? await customProps(context, staticProps) : customProps)
|
|
31
24
|
});
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.SitemapBuilder = void 0;
|
|
7
|
-
class SitemapBuilder {
|
|
1
|
+
export class SitemapBuilder {
|
|
8
2
|
urls = [];
|
|
9
3
|
constructor(baseUrl) {
|
|
10
4
|
this.baseUrl = baseUrl;
|
|
@@ -33,5 +27,4 @@ class SitemapBuilder {
|
|
|
33
27
|
serialize() {
|
|
34
28
|
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');
|
|
35
29
|
}
|
|
36
|
-
}
|
|
37
|
-
exports.SitemapBuilder = SitemapBuilder;
|
|
30
|
+
}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createPaths = createPaths;
|
|
7
|
-
function createPaths(stories, categories) {
|
|
1
|
+
export function createPaths(stories, categories) {
|
|
8
2
|
const storiesUrls = stories.map(({
|
|
9
3
|
slug
|
|
10
4
|
}) => `/${slug}`);
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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) {
|
|
1
|
+
import { getPrezlyApi } from "../../../data-fetching/index.js";
|
|
2
|
+
import { createPaths } from "./createPaths.js";
|
|
3
|
+
import { SitemapBuilder } from "./SitemapBuilder.js";
|
|
4
|
+
export function getSitemapServerSideProps(additionalPaths) {
|
|
11
5
|
return async function getServerSideProps(ctx) {
|
|
12
6
|
const {
|
|
13
7
|
res,
|
|
@@ -20,11 +14,11 @@ function getSitemapServerSideProps(additionalPaths) {
|
|
|
20
14
|
};
|
|
21
15
|
}
|
|
22
16
|
const baseUrl = req.headers.host || '/';
|
|
23
|
-
const api =
|
|
17
|
+
const api = getPrezlyApi(req);
|
|
24
18
|
const stories = await api.getAllStories();
|
|
25
19
|
const categories = await api.getCategories();
|
|
26
|
-
const paths =
|
|
27
|
-
const sitemapBuilder = new
|
|
20
|
+
const paths = createPaths(stories, categories);
|
|
21
|
+
const sitemapBuilder = new SitemapBuilder(baseUrl);
|
|
28
22
|
sitemapBuilder.addUrl('/');
|
|
29
23
|
paths.forEach(path => sitemapBuilder.addUrl(path));
|
|
30
24
|
if (additionalPaths) {
|
|
@@ -1,43 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
+
export { getSitemapServerSideProps } from "./getServerSideProps.js";
|
|
2
|
+
export { SitemapBuilder } from "./SitemapBuilder.js";
|
|
3
|
+
export { createPaths } from "./createPaths.js";
|
|
4
|
+
export * from "./types.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -1,20 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
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) {
|
|
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
|
+
export function getStoryPageServerSideProps(customProps) {
|
|
16
8
|
return async function getServerSideProps(context) {
|
|
17
|
-
const api =
|
|
9
|
+
const api = getPrezlyApi(context.req);
|
|
18
10
|
const {
|
|
19
11
|
slug
|
|
20
12
|
} = context.params;
|
|
@@ -26,13 +18,13 @@ function getStoryPageServerSideProps(customProps) {
|
|
|
26
18
|
}
|
|
27
19
|
const {
|
|
28
20
|
serverSideProps
|
|
29
|
-
} = await
|
|
21
|
+
} = await getNewsroomServerSideProps(context, {
|
|
30
22
|
story
|
|
31
23
|
});
|
|
32
24
|
const {
|
|
33
25
|
locale
|
|
34
26
|
} = context;
|
|
35
|
-
if (locale && locale !==
|
|
27
|
+
if (locale && locale !== DUMMY_DEFAULT_LOCALE) {
|
|
36
28
|
return {
|
|
37
29
|
redirect: {
|
|
38
30
|
destination: `/${slug}`,
|
|
@@ -41,15 +33,15 @@ function getStoryPageServerSideProps(customProps) {
|
|
|
41
33
|
};
|
|
42
34
|
}
|
|
43
35
|
serverSideProps.newsroomContextProps.currentStory = story;
|
|
44
|
-
return
|
|
36
|
+
return processRequest(context, {
|
|
45
37
|
...serverSideProps,
|
|
46
38
|
...(typeof customProps === 'function' ? await customProps(context, serverSideProps) : customProps)
|
|
47
39
|
});
|
|
48
40
|
};
|
|
49
41
|
}
|
|
50
|
-
function getStoryPageStaticProps(customProps) {
|
|
42
|
+
export function getStoryPageStaticProps(customProps) {
|
|
51
43
|
return async function getStaticProps(context) {
|
|
52
|
-
const api =
|
|
44
|
+
const api = getPrezlyApi();
|
|
53
45
|
const {
|
|
54
46
|
slug
|
|
55
47
|
} = context.params;
|
|
@@ -61,18 +53,18 @@ function getStoryPageStaticProps(customProps) {
|
|
|
61
53
|
}
|
|
62
54
|
const {
|
|
63
55
|
staticProps
|
|
64
|
-
} = await
|
|
56
|
+
} = await getNewsroomStaticProps(context, {
|
|
65
57
|
story
|
|
66
58
|
});
|
|
67
59
|
staticProps.newsroomContextProps.currentStory = story;
|
|
68
|
-
return
|
|
60
|
+
return processStaticRequest(context, {
|
|
69
61
|
...staticProps,
|
|
70
62
|
...(typeof customProps === 'function' ? await customProps(context, staticProps) : customProps)
|
|
71
63
|
});
|
|
72
64
|
};
|
|
73
65
|
}
|
|
74
|
-
async function getStoryPageStaticPaths() {
|
|
75
|
-
const api =
|
|
66
|
+
export async function getStoryPageStaticPaths() {
|
|
67
|
+
const api = getPrezlyApi();
|
|
76
68
|
const stories = await api.getAllStories();
|
|
77
69
|
const paths = stories.map(({
|
|
78
70
|
slug
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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) {
|
|
1
|
+
import { getPrezlyApi } from "../../data-fetching/index.js";
|
|
2
|
+
import { getNewsroomServerSideProps } from "../getNewsroomServerSideProps.js";
|
|
3
|
+
import { processRequest } from "../processRequest.js";
|
|
4
|
+
export function getStoryPreviewPageServerSideProps(customProps) {
|
|
11
5
|
return async function getServerSideProps(context) {
|
|
12
|
-
const api =
|
|
6
|
+
const api = getPrezlyApi(context.req);
|
|
13
7
|
const {
|
|
14
8
|
uuid
|
|
15
9
|
} = context.params;
|
|
@@ -21,11 +15,11 @@ function getStoryPreviewPageServerSideProps(customProps) {
|
|
|
21
15
|
}
|
|
22
16
|
const {
|
|
23
17
|
serverSideProps
|
|
24
|
-
} = await
|
|
18
|
+
} = await getNewsroomServerSideProps(context, {
|
|
25
19
|
story
|
|
26
20
|
});
|
|
27
21
|
serverSideProps.newsroomContextProps.currentStory = story;
|
|
28
|
-
return
|
|
22
|
+
return processRequest(context, {
|
|
29
23
|
...serverSideProps,
|
|
30
24
|
...(typeof customProps === 'function' ? await customProps(context, serverSideProps) : customProps)
|
|
31
25
|
});
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.processRequest = processRequest;
|
|
7
|
-
var _index = require("../intl/index.js");
|
|
1
|
+
import { getRedirectToCanonicalLocale, getShortestLocaleCode, LocaleObject } from "../intl/index.js";
|
|
8
2
|
/**
|
|
9
3
|
* This function combines the props returned from `getNewsroomServerSideProps` and your optional custom props for the page.
|
|
10
4
|
* It also handles locale redirects, if `canonicalUrl` parameter is provided.
|
|
@@ -14,7 +8,7 @@ var _index = require("../intl/index.js");
|
|
|
14
8
|
* @param props Object containing the return of `getNewsroomServerSideProps` and your optional custom props.
|
|
15
9
|
* @param canonicalUrl Optional: a canonical URL for the current page without locale part. If provided, locale redirects will be handled by the function.
|
|
16
10
|
*/
|
|
17
|
-
function processRequest(context, props, canonicalUrl) {
|
|
11
|
+
export function processRequest(context, props, canonicalUrl) {
|
|
18
12
|
const {
|
|
19
13
|
locale: nextLocale,
|
|
20
14
|
query
|
|
@@ -36,9 +30,9 @@ function processRequest(context, props, canonicalUrl) {
|
|
|
36
30
|
languages,
|
|
37
31
|
localeCode
|
|
38
32
|
} = pageProps.newsroomContextProps;
|
|
39
|
-
const currentLocale =
|
|
40
|
-
const shortestLocaleCode =
|
|
41
|
-
const redirect =
|
|
33
|
+
const currentLocale = LocaleObject.fromAnyCode(localeCode);
|
|
34
|
+
const shortestLocaleCode = getShortestLocaleCode(languages, currentLocale);
|
|
35
|
+
const redirect = getRedirectToCanonicalLocale(shortestLocaleCode, nextLocale, canonicalUrl, query);
|
|
42
36
|
if (redirect) {
|
|
43
37
|
return {
|
|
44
38
|
redirect
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.processStaticRequest = processStaticRequest;
|
|
7
1
|
/**
|
|
8
2
|
* This function combines the props returned from `getNewsroomStaticProps` and your optional custom props for the page.
|
|
9
3
|
* See README for usage examples.
|
|
@@ -12,7 +6,7 @@ exports.processStaticRequest = processStaticRequest;
|
|
|
12
6
|
* @param props Object containing the return of `getNewsroomServerSideProps` and your optional custom props.
|
|
13
7
|
* @param revalidateTimeout Optional: timeout in seconds to use with Next ISR.
|
|
14
8
|
*/
|
|
15
|
-
function processStaticRequest(context, props, revalidateTimeout) {
|
|
9
|
+
export function processStaticRequest(context, props, revalidateTimeout) {
|
|
16
10
|
const {
|
|
17
11
|
locale: nextLocale
|
|
18
12
|
} = context;
|
|
@@ -1,23 +1,17 @@
|
|
|
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");
|
|
14
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
|
+
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";
|
|
15
9
|
/**
|
|
16
10
|
* This component provides base page attributes for every Newsroom page.
|
|
17
11
|
* It depends on information from NewsroomContext, so the component should be placed inside the `NewsroomContextProvider`.
|
|
18
12
|
* You can pass additional props expected by NextSeo component to override any info that is provided by the NewsroomContext.
|
|
19
13
|
*/
|
|
20
|
-
function PageSeo({
|
|
14
|
+
export function PageSeo({
|
|
21
15
|
title,
|
|
22
16
|
description,
|
|
23
17
|
imageUrl,
|
|
@@ -26,39 +20,39 @@ function PageSeo({
|
|
|
26
20
|
twitter,
|
|
27
21
|
...nextSeoProps
|
|
28
22
|
}) {
|
|
29
|
-
const companyInformation =
|
|
30
|
-
const newsroom =
|
|
31
|
-
const currentLocale =
|
|
32
|
-
const languages =
|
|
33
|
-
const getTranslationUrl =
|
|
34
|
-
const getLinkLocaleSlug =
|
|
35
|
-
const currentStory =
|
|
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();
|
|
36
30
|
const {
|
|
37
31
|
asPath
|
|
38
|
-
} =
|
|
32
|
+
} = useRouter();
|
|
39
33
|
const pageTitle = title || companyInformation.name;
|
|
40
34
|
const pageDescription = description || companyInformation.about_plaintext;
|
|
41
|
-
const canonicalUrl = canonical ||
|
|
35
|
+
const canonicalUrl = canonical || getAbsoluteUrl(asPath, newsroom.url, getLinkLocaleSlug(currentLocale));
|
|
42
36
|
const siteName = companyInformation.name;
|
|
43
|
-
const logoUrl = imageUrl ||
|
|
44
|
-
const alternateLanguageLinks =
|
|
37
|
+
const logoUrl = imageUrl || getNewsroomLogoUrl(newsroom);
|
|
38
|
+
const alternateLanguageLinks = useMemo(() => {
|
|
45
39
|
if (!languages.length) {
|
|
46
40
|
return [];
|
|
47
41
|
}
|
|
48
|
-
const alternateLanguages =
|
|
42
|
+
const alternateLanguages = getUsedLanguages(languages).filter(language => language.code !== currentLocale.toUnderscoreCode());
|
|
49
43
|
return alternateLanguages.map(language => {
|
|
50
|
-
const locale =
|
|
44
|
+
const locale = LocaleObject.fromAnyCode(language.code);
|
|
51
45
|
const translationLink = getTranslationUrl(locale, true);
|
|
52
46
|
if (!translationLink) {
|
|
53
47
|
return undefined;
|
|
54
48
|
}
|
|
55
49
|
return {
|
|
56
50
|
hrefLang: locale.toHyphenCode(),
|
|
57
|
-
href:
|
|
51
|
+
href: getAbsoluteUrl(translationLink, newsroom.url, currentStory && translationLink !== '/' ? false : getLinkLocaleSlug(locale))
|
|
58
52
|
};
|
|
59
53
|
}).filter(Boolean);
|
|
60
54
|
}, [currentLocale, getLinkLocaleSlug, getTranslationUrl, languages, newsroom.url, currentStory]);
|
|
61
|
-
return /*#__PURE__*/React.createElement(
|
|
55
|
+
return /*#__PURE__*/React.createElement(NextSeo, _extends({
|
|
62
56
|
title: pageTitle,
|
|
63
57
|
description: pageDescription,
|
|
64
58
|
canonical: canonicalUrl,
|
|
@@ -88,7 +82,7 @@ function PageSeo({
|
|
|
88
82
|
additionalLinkTags: [{
|
|
89
83
|
rel: 'alternate',
|
|
90
84
|
type: 'application/rss+xml',
|
|
91
|
-
href:
|
|
85
|
+
href: getAbsoluteUrl('/feed', newsroom.url)
|
|
92
86
|
}],
|
|
93
87
|
languageAlternates: alternateLanguageLinks
|
|
94
88
|
}, nextSeoProps));
|
|
@@ -1,27 +1,2 @@
|
|
|
1
|
-
|
|
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
|
+
export { PageSeo } from "./PageSeo.js";
|
|
2
|
+
export * from "./lib/types.js";
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getAbsoluteUrl = getAbsoluteUrl;
|
|
7
1
|
// Returns absolute URL based on the path and without any query parameters
|
|
8
|
-
function getAbsoluteUrl(path, origin, localeCode) {
|
|
2
|
+
export function getAbsoluteUrl(path, origin, localeCode) {
|
|
9
3
|
const url = new URL(`${localeCode ? `/${localeCode}` : ''}${path || '/'}`, origin);
|
|
10
4
|
url.search = '';
|
|
11
5
|
return url.toString();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
|
|
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");
|
|
1
|
+
import { Story } from '@prezly/sdk';
|
|
2
|
+
import { ArticleJsonLd, NextSeo } from 'next-seo';
|
|
9
3
|
/**
|
|
10
4
|
* This components provides additional page attributes for the Story page.
|
|
11
5
|
* It works in conjunction with `PageSeo` component, overidding some of its attributes.
|
|
12
6
|
*/
|
|
13
|
-
function StorySeo({
|
|
7
|
+
export function StorySeo({
|
|
14
8
|
story,
|
|
15
9
|
noindex
|
|
16
10
|
}) {
|
|
@@ -26,8 +20,8 @@ function StorySeo({
|
|
|
26
20
|
} = story;
|
|
27
21
|
const authorName = author?.display_name || author?.email || 'Unknown';
|
|
28
22
|
const description = subtitle || summary;
|
|
29
|
-
const indexable = newsroom.is_indexable && story.visibility ===
|
|
30
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
|
23
|
+
const indexable = newsroom.is_indexable && story.visibility === Story.Visibility.PUBLIC;
|
|
24
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(NextSeo, {
|
|
31
25
|
title: title,
|
|
32
26
|
description: description,
|
|
33
27
|
canonical: oembed.url,
|
|
@@ -65,7 +59,7 @@ function StorySeo({
|
|
|
65
59
|
type: 'application/json',
|
|
66
60
|
href: `${oembed.url}.json`
|
|
67
61
|
}]
|
|
68
|
-
}), /*#__PURE__*/React.createElement(
|
|
62
|
+
}), /*#__PURE__*/React.createElement(ArticleJsonLd, {
|
|
69
63
|
url: oembed.url,
|
|
70
64
|
title: title,
|
|
71
65
|
images: oembed.thumbnail_url ? [oembed.thumbnail_url] : [],
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
|
|
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
|
+
export { StorySeo } from "./StorySeo.js";
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { DocumentProps } from 'next/document';
|
|
2
2
|
import Document from 'next/document';
|
|
3
|
-
|
|
3
|
+
import { Component } from 'react';
|
|
4
|
+
export declare class PrezlyThemeDocument extends Component<DocumentProps> {
|
|
5
|
+
static getInitialProps: typeof Document.getInitialProps;
|
|
4
6
|
getLocaleCode(): string;
|
|
5
7
|
render(): JSX.Element;
|
|
6
8
|
}
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 {
|
|
1
|
+
import Document, { Head, Html, Main, NextScript } from "next/document.js";
|
|
2
|
+
import { Component } from 'react';
|
|
3
|
+
import { DEFAULT_LOCALE, getLocaleDirection, LocaleObject } from "../intl/index.js";
|
|
4
|
+
// Somehow extending the default Next Document class messes up with the ESM build of the package.
|
|
5
|
+
export class PrezlyThemeDocument extends Component {
|
|
6
|
+
static getInitialProps = Document.getInitialProps;
|
|
12
7
|
getLocaleCode() {
|
|
13
8
|
const {
|
|
14
9
|
newsroomContextProps
|
|
@@ -20,21 +15,20 @@ class PrezlyThemeDocument extends _document.default {
|
|
|
20
15
|
const {
|
|
21
16
|
localeCode
|
|
22
17
|
} = newsroomContextProps ?? {
|
|
23
|
-
localeCode:
|
|
18
|
+
localeCode: DEFAULT_LOCALE
|
|
24
19
|
};
|
|
25
20
|
return localeCode;
|
|
26
21
|
}
|
|
27
22
|
render() {
|
|
28
|
-
const locale =
|
|
23
|
+
const locale = LocaleObject.fromAnyCode(this.getLocaleCode());
|
|
29
24
|
// TODO: The direction can be pulled from the Language object
|
|
30
|
-
const direction =
|
|
31
|
-
return /*#__PURE__*/React.createElement(
|
|
25
|
+
const direction = getLocaleDirection(locale);
|
|
26
|
+
return /*#__PURE__*/React.createElement(Html, {
|
|
32
27
|
lang: locale.toHyphenCode(),
|
|
33
28
|
dir: direction
|
|
34
|
-
}, /*#__PURE__*/React.createElement(
|
|
29
|
+
}, /*#__PURE__*/React.createElement(Head, null, /*#__PURE__*/React.createElement("meta", {
|
|
35
30
|
name: "og:locale",
|
|
36
31
|
content: locale.toHyphenCode()
|
|
37
|
-
})), /*#__PURE__*/React.createElement("body", null, /*#__PURE__*/React.createElement(
|
|
32
|
+
})), /*#__PURE__*/React.createElement("body", null, /*#__PURE__*/React.createElement(Main, null), /*#__PURE__*/React.createElement(NextScript, null)));
|
|
38
33
|
}
|
|
39
|
-
}
|
|
40
|
-
exports.PrezlyThemeDocument = PrezlyThemeDocument;
|
|
34
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../src/components-nextjs/document.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../src/components-nextjs/document.tsx"],"names":[],"mappings":";AACA,OAAO,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG3E,iGAAiG;AACjG,MAAM,OAAO,mBAAoB,SAAQ,SAAwB;IAC7D,MAAM,CAAC,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC;IAElD,aAAa;QACT,MAAM,EACF,oBAAoB;QACpB,gDAAgD;UACnD,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,SAAsB,CAAC;QAE1D,oFAAoF;QACpF,kEAAkE;QAClE,MAAM,EAAE,UAAU,EAAE,GAAG,oBAAoB,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC;QAE9E,OAAO,UAAU,CAAC;IACtB,CAAC;IAED,MAAM;QACF,MAAM,MAAM,GAAG,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;QAC9D,6DAA6D;QAC7D,MAAM,SAAS,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAE7C,OAAO,CACH,MAAC,IAAI,IAAC,IAAI,EAAE,MAAM,CAAC,YAAY,EAAE,EAAE,GAAG,EAAE,SAAS,aAC7C,KAAC,IAAI,cACD,eAAM,IAAI,EAAC,WAAW,EAAC,OAAO,EAAE,MAAM,CAAC,YAAY,EAAE,GAAI,GAEtD,EACP,2BACI,KAAC,IAAI,KAAG,EACR,KAAC,UAAU,KAAG,IACX,IACJ,CACV,CAAC;IACN,CAAC"}
|
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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");
|
|
1
|
+
export { PageSeo } from "./PageSeo/index.js";
|
|
2
|
+
export { StorySeo } from "./StorySeo/index.js";
|
|
3
|
+
export { PrezlyThemeDocument } from "./document.js";
|