@prezly/theme-kit-nextjs 1.15.0 → 1.16.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.
- package/build/adapter-nextjs/api-handlers/fetchGalleries.js +15 -69
- package/build/adapter-nextjs/api-handlers/fetchGalleries.js.map +1 -1
- package/build/adapter-nextjs/api-handlers/fetchStories.js +17 -71
- package/build/adapter-nextjs/api-handlers/fetchStories.js.map +1 -1
- package/build/adapter-nextjs/api-handlers/index.js +2 -7
- package/build/adapter-nextjs/api-handlers/index.js.map +1 -1
- package/build/adapter-nextjs/getNewsroomServerSideProps.js +9 -63
- package/build/adapter-nextjs/getNewsroomServerSideProps.js.map +1 -1
- package/build/adapter-nextjs/getNewsroomStaticProps.js +9 -63
- package/build/adapter-nextjs/getNewsroomStaticProps.js.map +1 -1
- package/build/adapter-nextjs/index.js +6 -22
- package/build/adapter-nextjs/index.js.map +1 -1
- package/build/adapter-nextjs/page-props/category.d.ts +1 -1
- package/build/adapter-nextjs/page-props/category.js +95 -202
- package/build/adapter-nextjs/page-props/category.js.map +1 -1
- package/build/adapter-nextjs/page-props/gallery.d.ts +1 -1
- package/build/adapter-nextjs/page-props/gallery.js +59 -141
- package/build/adapter-nextjs/page-props/gallery.js.map +1 -1
- package/build/adapter-nextjs/page-props/galleryAlbum.d.ts +1 -1
- package/build/adapter-nextjs/page-props/galleryAlbum.js +41 -139
- package/build/adapter-nextjs/page-props/galleryAlbum.js.map +1 -1
- package/build/adapter-nextjs/page-props/home.d.ts +1 -1
- package/build/adapter-nextjs/page-props/home.js +58 -142
- package/build/adapter-nextjs/page-props/home.js.map +1 -1
- package/build/adapter-nextjs/page-props/index.js +8 -41
- package/build/adapter-nextjs/page-props/index.js.map +1 -1
- package/build/adapter-nextjs/page-props/lib/types.d.ts +1 -1
- package/build/adapter-nextjs/page-props/lib/types.js +1 -2
- package/build/adapter-nextjs/page-props/search.d.ts +2 -2
- package/build/adapter-nextjs/page-props/search.js +21 -103
- package/build/adapter-nextjs/page-props/search.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js +18 -22
- package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/createPaths.js +10 -45
- package/build/adapter-nextjs/page-props/sitemap/createPaths.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js +29 -81
- package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/index.js +4 -24
- package/build/adapter-nextjs/page-props/sitemap/index.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/types.js +1 -2
- package/build/adapter-nextjs/page-props/story.d.ts +1 -1
- package/build/adapter-nextjs/page-props/story.js +58 -166
- package/build/adapter-nextjs/page-props/story.js.map +1 -1
- package/build/adapter-nextjs/page-props/storyPreview.js +20 -85
- package/build/adapter-nextjs/page-props/storyPreview.js.map +1 -1
- package/build/adapter-nextjs/processRequest.js +9 -24
- package/build/adapter-nextjs/processRequest.js.map +1 -1
- package/build/adapter-nextjs/processStaticRequest.js +3 -18
- package/build/adapter-nextjs/processStaticRequest.js.map +1 -1
- package/build/components-nextjs/PageSeo/PageSeo.js +42 -57
- package/build/components-nextjs/PageSeo/PageSeo.js.map +1 -1
- package/build/components-nextjs/PageSeo/index.js +2 -20
- package/build/components-nextjs/PageSeo/index.js.map +1 -1
- package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js +2 -6
- package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js.map +1 -1
- package/build/components-nextjs/PageSeo/lib/types.js +1 -2
- package/build/components-nextjs/StorySeo/StorySeo.js +28 -36
- package/build/components-nextjs/StorySeo/StorySeo.js.map +1 -1
- package/build/components-nextjs/StorySeo/index.js +1 -5
- package/build/components-nextjs/StorySeo/index.js.map +1 -1
- package/build/components-nextjs/document.d.ts +6 -0
- package/build/components-nextjs/document.js +21 -0
- package/build/components-nextjs/document.js.map +1 -0
- package/build/components-nextjs/index.d.ts +1 -0
- package/build/components-nextjs/index.js +3 -7
- package/build/components-nextjs/index.js.map +1 -1
- package/build/data-fetching/api/PrezlyApi.js +171 -363
- package/build/data-fetching/api/PrezlyApi.js.map +1 -1
- package/build/data-fetching/api/getPrezlyApi.js +5 -9
- package/build/data-fetching/api/getPrezlyApi.js.map +1 -1
- package/build/data-fetching/api/index.js +1 -17
- package/build/data-fetching/api/index.js.map +1 -1
- package/build/data-fetching/api/queries.js +13 -45
- package/build/data-fetching/api/queries.js.map +1 -1
- package/build/data-fetching/index.js +3 -19
- package/build/data-fetching/index.js.map +1 -1
- package/build/data-fetching/lib/getAlgoliaSettings.js +6 -10
- package/build/data-fetching/lib/getAlgoliaSettings.js.map +1 -1
- package/build/data-fetching/lib/getEnvVariables.js +11 -29
- package/build/data-fetching/lib/getEnvVariables.js.map +1 -1
- package/build/data-fetching/lib/index.js +4 -11
- package/build/data-fetching/lib/index.js.map +1 -1
- package/build/data-fetching/lib/isSdkError.js +1 -5
- package/build/data-fetching/lib/isSdkError.js.map +1 -1
- package/build/data-fetching/lib/isUuid.js +2 -6
- package/build/data-fetching/lib/isUuid.js.map +1 -1
- package/build/data-fetching/types.js +1 -2
- package/build/index.d.ts +1 -0
- package/build/index.js +9 -24
- package/build/index.js.map +1 -1
- package/build/infinite-loading/index.js +4 -24
- package/build/infinite-loading/index.js.map +1 -1
- package/build/infinite-loading/types.js +1 -2
- package/build/infinite-loading/useInfiniteGalleriesLoading.js +25 -83
- package/build/infinite-loading/useInfiniteGalleriesLoading.js.map +1 -1
- package/build/infinite-loading/useInfiniteLoading.js +21 -97
- package/build/infinite-loading/useInfiniteLoading.js.map +1 -1
- package/build/infinite-loading/useInfiniteStoriesLoading.js +36 -99
- package/build/infinite-loading/useInfiniteStoriesLoading.js.map +1 -1
- package/build/intl/index.js +4 -25
- package/build/intl/index.js.map +1 -1
- package/build/intl/languages.js +47 -93
- package/build/intl/languages.js.map +1 -1
- package/build/intl/locale.js +21 -27
- package/build/intl/locale.js.map +1 -1
- package/build/intl/localeConfig.js +11 -32
- package/build/intl/localeConfig.js.map +1 -1
- package/build/intl/localeObject.js +30 -49
- package/build/intl/localeObject.js.map +1 -1
- package/build/newsroom-context/context.js +18 -34
- package/build/newsroom-context/context.js.map +1 -1
- package/build/newsroom-context/hooks/index.js +11 -27
- package/build/newsroom-context/hooks/index.js.map +1 -1
- package/build/newsroom-context/hooks/useAlgoliaSettings.js +3 -7
- package/build/newsroom-context/hooks/useAlgoliaSettings.js.map +1 -1
- package/build/newsroom-context/hooks/useCategories.js +3 -7
- package/build/newsroom-context/hooks/useCategories.js.map +1 -1
- package/build/newsroom-context/hooks/useCompanyInformation.js +3 -7
- package/build/newsroom-context/hooks/useCompanyInformation.js.map +1 -1
- package/build/newsroom-context/hooks/useCurrentCategory.js +3 -7
- package/build/newsroom-context/hooks/useCurrentCategory.js.map +1 -1
- package/build/newsroom-context/hooks/useCurrentLocale.js +3 -7
- package/build/newsroom-context/hooks/useCurrentLocale.js.map +1 -1
- package/build/newsroom-context/hooks/useCurrentStory.js +3 -7
- package/build/newsroom-context/hooks/useCurrentStory.js.map +1 -1
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js +10 -14
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js.map +1 -1
- package/build/newsroom-context/hooks/useGetTranslationUrl.js +17 -26
- package/build/newsroom-context/hooks/useGetTranslationUrl.js.map +1 -1
- package/build/newsroom-context/hooks/useLanguages.js +3 -7
- package/build/newsroom-context/hooks/useLanguages.js.map +1 -1
- package/build/newsroom-context/hooks/useNewsroom.js +3 -7
- package/build/newsroom-context/hooks/useNewsroom.js.map +1 -1
- package/build/newsroom-context/hooks/useNewsroomContext.js +4 -8
- package/build/newsroom-context/hooks/useNewsroomContext.js.map +1 -1
- package/build/newsroom-context/index.js +2 -21
- package/build/newsroom-context/index.js.map +1 -1
- package/build/sentry/client.d.ts +2 -0
- package/build/sentry/client.js +5 -0
- package/build/sentry/client.js.map +1 -0
- package/build/sentry/common.d.ts +2 -0
- package/build/sentry/common.js +25 -0
- package/build/sentry/common.js.map +1 -0
- package/build/sentry/index.d.ts +2 -0
- package/build/sentry/index.js +3 -0
- package/build/sentry/index.js.map +1 -0
- package/build/sentry/server.d.ts +2 -0
- package/build/sentry/server.js +5 -0
- package/build/sentry/server.js.map +1 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/types.js +1 -2
- package/build/utils/boilerplate.js +3 -9
- package/build/utils/boilerplate.js.map +1 -1
- package/build/utils/constants.js +3 -6
- package/build/utils/constants.js.map +1 -1
- package/build/utils/getAssetsUrl.js +3 -7
- package/build/utils/getAssetsUrl.js.map +1 -1
- package/build/utils/getDataRequestLink.js +3 -7
- package/build/utils/getDataRequestLink.js.map +1 -1
- package/build/utils/getLocalizedCategoryData.js +15 -32
- package/build/utils/getLocalizedCategoryData.js.map +1 -1
- package/build/utils/getNewsroomLogoUrl.js +6 -12
- package/build/utils/getNewsroomLogoUrl.js.map +1 -1
- package/build/utils/getPrivacyPortalUrl.js +3 -7
- package/build/utils/getPrivacyPortalUrl.js.map +1 -1
- package/build/utils/getStoryPublicationDate.js +2 -6
- package/build/utils/getStoryPublicationDate.js.map +1 -1
- package/build/utils/getUploadcareGroupUrl.js +3 -7
- package/build/utils/getUploadcareGroupUrl.js.map +1 -1
- package/build/utils/index.js +10 -26
- package/build/utils/index.js.map +1 -1
- package/build/utils/isEmbargoStory.js +1 -5
- package/build/utils/isEmbargoStory.js.map +1 -1
- package/package.json +2 -1
- package/src/adapter-nextjs/page-props/category.ts +5 -2
- package/src/adapter-nextjs/page-props/gallery.ts +5 -2
- package/src/adapter-nextjs/page-props/galleryAlbum.ts +5 -2
- package/src/adapter-nextjs/page-props/home.ts +5 -2
- package/src/adapter-nextjs/page-props/lib/types.ts +4 -4
- package/src/adapter-nextjs/page-props/search.ts +10 -3
- package/src/adapter-nextjs/page-props/story.ts +5 -2
- package/src/components-nextjs/document.tsx +38 -0
- package/src/components-nextjs/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/sentry/client.ts +7 -0
- package/src/sentry/common.ts +27 -0
- package/src/sentry/index.ts +2 -0
- package/src/sentry/server.ts +7 -0
|
@@ -1,175 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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';
|
|
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
14
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
while (_) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.getStoryPageStaticPaths = exports.getStoryPageStaticProps = exports.getStoryPageServerSideProps = void 0;
|
|
51
|
-
var data_fetching_1 = require("../../data-fetching");
|
|
52
|
-
var intl_1 = require("../../intl");
|
|
53
|
-
var getNewsroomServerSideProps_1 = require("../getNewsroomServerSideProps");
|
|
54
|
-
var getNewsroomStaticProps_1 = require("../getNewsroomStaticProps");
|
|
55
|
-
var processRequest_1 = require("../processRequest");
|
|
56
|
-
var processStaticRequest_1 = require("../processStaticRequest");
|
|
57
|
-
function getStoryPageServerSideProps(customProps) {
|
|
58
|
-
return function getServerSideProps(context) {
|
|
59
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
60
|
-
var api, slug, story, _a, serverSideProps, locale, _b, _c, _d, _e;
|
|
61
|
-
return __generator(this, function (_f) {
|
|
62
|
-
switch (_f.label) {
|
|
63
|
-
case 0:
|
|
64
|
-
api = (0, data_fetching_1.getPrezlyApi)(context.req);
|
|
65
|
-
slug = context.params.slug;
|
|
66
|
-
if (!slug) return [3 /*break*/, 2];
|
|
67
|
-
return [4 /*yield*/, api.getStoryBySlug(slug)];
|
|
68
|
-
case 1:
|
|
69
|
-
_a = _f.sent();
|
|
70
|
-
return [3 /*break*/, 3];
|
|
71
|
-
case 2:
|
|
72
|
-
_a = null;
|
|
73
|
-
_f.label = 3;
|
|
74
|
-
case 3:
|
|
75
|
-
story = _a;
|
|
76
|
-
if (!story) {
|
|
77
|
-
return [2 /*return*/, { notFound: true }];
|
|
78
|
-
}
|
|
79
|
-
return [4 /*yield*/, (0, getNewsroomServerSideProps_1.getNewsroomServerSideProps)(context, { story: story })];
|
|
80
|
-
case 4:
|
|
81
|
-
serverSideProps = (_f.sent()).serverSideProps;
|
|
82
|
-
locale = context.locale;
|
|
83
|
-
if (locale && locale !== intl_1.DUMMY_DEFAULT_LOCALE) {
|
|
84
|
-
return [2 /*return*/, {
|
|
85
|
-
redirect: {
|
|
86
|
-
destination: "/".concat(slug),
|
|
87
|
-
permanent: true,
|
|
88
|
-
},
|
|
89
|
-
}];
|
|
90
|
-
}
|
|
91
|
-
_b = processRequest_1.processRequest;
|
|
92
|
-
_c = [context];
|
|
93
|
-
_d = [__assign(__assign({}, serverSideProps), { newsroomContextProps: __assign(__assign({}, serverSideProps.newsroomContextProps), { currentStory: story }) })];
|
|
94
|
-
if (!(typeof customProps === 'function')) return [3 /*break*/, 6];
|
|
95
|
-
return [4 /*yield*/, customProps(context, serverSideProps)];
|
|
96
|
-
case 5:
|
|
97
|
-
_e = _f.sent();
|
|
98
|
-
return [3 /*break*/, 7];
|
|
99
|
-
case 6:
|
|
100
|
-
_e = customProps;
|
|
101
|
-
_f.label = 7;
|
|
102
|
-
case 7: return [2 /*return*/, _b.apply(void 0, _c.concat([__assign.apply(void 0, _d.concat([(_e)]))]))];
|
|
103
|
-
}
|
|
104
|
-
});
|
|
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
|
+
return processRequest(context, {
|
|
26
|
+
...serverSideProps,
|
|
27
|
+
newsroomContextProps: {
|
|
28
|
+
...serverSideProps.newsroomContextProps,
|
|
29
|
+
currentStory: story,
|
|
30
|
+
},
|
|
31
|
+
...(typeof customProps === 'function'
|
|
32
|
+
? await customProps(context, serverSideProps)
|
|
33
|
+
: customProps),
|
|
105
34
|
});
|
|
106
35
|
};
|
|
107
36
|
}
|
|
108
|
-
|
|
109
|
-
function
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
case 3:
|
|
127
|
-
story = _a;
|
|
128
|
-
if (!story) {
|
|
129
|
-
return [2 /*return*/, { notFound: true }];
|
|
130
|
-
}
|
|
131
|
-
return [4 /*yield*/, (0, getNewsroomStaticProps_1.getNewsroomStaticProps)(context, { story: story })];
|
|
132
|
-
case 4:
|
|
133
|
-
staticProps = (_f.sent()).staticProps;
|
|
134
|
-
_b = processStaticRequest_1.processStaticRequest;
|
|
135
|
-
_c = [context];
|
|
136
|
-
_d = [__assign(__assign({}, staticProps), { newsroomContextProps: __assign(__assign({}, staticProps.newsroomContextProps), { currentStory: story }) })];
|
|
137
|
-
if (!(typeof customProps === 'function')) return [3 /*break*/, 6];
|
|
138
|
-
return [4 /*yield*/, customProps(context, staticProps)];
|
|
139
|
-
case 5:
|
|
140
|
-
_e = _f.sent();
|
|
141
|
-
return [3 /*break*/, 7];
|
|
142
|
-
case 6:
|
|
143
|
-
_e = customProps;
|
|
144
|
-
_f.label = 7;
|
|
145
|
-
case 7: return [2 /*return*/, _b.apply(void 0, _c.concat([__assign.apply(void 0, _d.concat([(_e)]))]))];
|
|
146
|
-
}
|
|
147
|
-
});
|
|
37
|
+
export function getStoryPageStaticProps(customProps) {
|
|
38
|
+
return async function getStaticProps(context) {
|
|
39
|
+
const api = getPrezlyApi();
|
|
40
|
+
const { slug } = context.params;
|
|
41
|
+
const story = slug ? await api.getStoryBySlug(slug) : null;
|
|
42
|
+
if (!story) {
|
|
43
|
+
return { notFound: true };
|
|
44
|
+
}
|
|
45
|
+
const { staticProps } = await getNewsroomStaticProps(context, { story });
|
|
46
|
+
return processStaticRequest(context, {
|
|
47
|
+
...staticProps,
|
|
48
|
+
newsroomContextProps: {
|
|
49
|
+
...staticProps.newsroomContextProps,
|
|
50
|
+
currentStory: story,
|
|
51
|
+
},
|
|
52
|
+
...(typeof customProps === 'function'
|
|
53
|
+
? await customProps(context, staticProps)
|
|
54
|
+
: customProps),
|
|
148
55
|
});
|
|
149
56
|
};
|
|
150
57
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return [4 /*yield*/, api.getAllStories()];
|
|
160
|
-
case 1:
|
|
161
|
-
stories = _a.sent();
|
|
162
|
-
paths = stories.map(function (_a) {
|
|
163
|
-
var slug = _a.slug;
|
|
164
|
-
return ({ params: { slug: slug } });
|
|
165
|
-
});
|
|
166
|
-
return [2 /*return*/, {
|
|
167
|
-
paths: paths,
|
|
168
|
-
fallback: 'blocking',
|
|
169
|
-
}];
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
});
|
|
58
|
+
export async function getStoryPageStaticPaths() {
|
|
59
|
+
const api = getPrezlyApi();
|
|
60
|
+
const stories = await api.getAllStories();
|
|
61
|
+
const paths = stories.map(({ slug }) => ({ params: { slug } }));
|
|
62
|
+
return {
|
|
63
|
+
paths,
|
|
64
|
+
fallback: 'blocking',
|
|
65
|
+
};
|
|
173
66
|
}
|
|
174
|
-
exports.getStoryPageStaticPaths = getStoryPageStaticPaths;
|
|
175
67
|
//# sourceMappingURL=story.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"story.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/story.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"story.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/story.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,90 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { getPrezlyApi } from '../../data-fetching';
|
|
2
|
+
import { getNewsroomServerSideProps } from '../getNewsroomServerSideProps';
|
|
3
|
+
import { processRequest } from '../processRequest';
|
|
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 };
|
|
8
11
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.getStoryPreviewPageServerSideProps = void 0;
|
|
51
|
-
var data_fetching_1 = require("../../data-fetching");
|
|
52
|
-
var getNewsroomServerSideProps_1 = require("../getNewsroomServerSideProps");
|
|
53
|
-
var processRequest_1 = require("../processRequest");
|
|
54
|
-
function getStoryPreviewPageServerSideProps(customProps) {
|
|
55
|
-
return function getServerSideProps(context) {
|
|
56
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
-
var api, uuid, story, serverSideProps, _a, _b, _c, _d;
|
|
58
|
-
return __generator(this, function (_e) {
|
|
59
|
-
switch (_e.label) {
|
|
60
|
-
case 0:
|
|
61
|
-
api = (0, data_fetching_1.getPrezlyApi)(context.req);
|
|
62
|
-
uuid = context.params.uuid;
|
|
63
|
-
return [4 /*yield*/, api.getStory(uuid)];
|
|
64
|
-
case 1:
|
|
65
|
-
story = _e.sent();
|
|
66
|
-
if (!story) {
|
|
67
|
-
return [2 /*return*/, { notFound: true }];
|
|
68
|
-
}
|
|
69
|
-
return [4 /*yield*/, (0, getNewsroomServerSideProps_1.getNewsroomServerSideProps)(context, { story: story })];
|
|
70
|
-
case 2:
|
|
71
|
-
serverSideProps = (_e.sent()).serverSideProps;
|
|
72
|
-
_a = processRequest_1.processRequest;
|
|
73
|
-
_b = [context];
|
|
74
|
-
_c = [__assign(__assign({}, serverSideProps), { newsroomContextProps: __assign(__assign({}, serverSideProps.newsroomContextProps), { currentStory: story }) })];
|
|
75
|
-
if (!(typeof customProps === 'function')) return [3 /*break*/, 4];
|
|
76
|
-
return [4 /*yield*/, customProps(context, serverSideProps)];
|
|
77
|
-
case 3:
|
|
78
|
-
_d = _e.sent();
|
|
79
|
-
return [3 /*break*/, 5];
|
|
80
|
-
case 4:
|
|
81
|
-
_d = customProps;
|
|
82
|
-
_e.label = 5;
|
|
83
|
-
case 5: return [2 /*return*/, _a.apply(void 0, _b.concat([__assign.apply(void 0, _c.concat([(_d)]))]))];
|
|
84
|
-
}
|
|
85
|
-
});
|
|
12
|
+
const { serverSideProps } = await getNewsroomServerSideProps(context, { story });
|
|
13
|
+
return processRequest(context, {
|
|
14
|
+
...serverSideProps,
|
|
15
|
+
newsroomContextProps: {
|
|
16
|
+
...serverSideProps.newsroomContextProps,
|
|
17
|
+
currentStory: story,
|
|
18
|
+
},
|
|
19
|
+
...(typeof customProps === 'function'
|
|
20
|
+
? await customProps(context, serverSideProps)
|
|
21
|
+
: customProps),
|
|
86
22
|
});
|
|
87
23
|
};
|
|
88
24
|
}
|
|
89
|
-
exports.getStoryPreviewPageServerSideProps = getStoryPreviewPageServerSideProps;
|
|
90
25
|
//# sourceMappingURL=storyPreview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storyPreview.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/storyPreview.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storyPreview.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/storyPreview.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAInD,MAAM,UAAU,kCAAkC,CAC9C,WAAqD;IAErD,OAAO,KAAK,UAAU,kBAAkB,CACpC,OAAkC;QAElC,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACtC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAA0B,CAAC;QACpD,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,KAAK,EAAE;YACR,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;SAC7B;QAED,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,0BAA0B,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAEjF,OAAO,cAAc,CAAC,OAAO,EAAE;YAC3B,GAAG,eAAe;YAClB,oBAAoB,EAAE;gBAClB,GAAG,eAAe,CAAC,oBAAoB;gBACvC,YAAY,EAAE,KAAK;aACtB;YACD,GAAG,CAAC,OAAO,WAAW,KAAK,UAAU;gBACjC,CAAC,CAAC,MAAO,WAA0C,CAAC,OAAO,EAAE,eAAe,CAAC;gBAC7E,CAAC,CAAC,WAAW,CAAC;SACrB,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.processRequest = void 0;
|
|
15
|
-
var intl_1 = require("../intl");
|
|
1
|
+
import { getRedirectToCanonicalLocale, getShortestLocaleCode, LocaleObject } from '../intl';
|
|
16
2
|
/**
|
|
17
3
|
* This function combines the props returned from `getNewsroomServerSideProps` and your optional custom props for the page.
|
|
18
4
|
* It also handles locale redirects, if `canonicalUrl` parameter is provided.
|
|
@@ -22,26 +8,25 @@ var intl_1 = require("../intl");
|
|
|
22
8
|
* @param props Object containing the return of `getNewsroomServerSideProps` and your optional custom props.
|
|
23
9
|
* @param canonicalUrl Optional: a canonical URL for the current page without locale part. If provided, locale redirects will be handled by the function.
|
|
24
10
|
*/
|
|
25
|
-
function processRequest(context, props, canonicalUrl) {
|
|
26
|
-
|
|
27
|
-
|
|
11
|
+
export function processRequest(context, props, canonicalUrl) {
|
|
12
|
+
const { locale: nextLocale, query } = context;
|
|
13
|
+
const { localeResolved, ...pageProps } = props;
|
|
28
14
|
// If no locale was provided by Next, it most likely means that the theme is not supporting multi-language.
|
|
29
15
|
// In that case we won't show 404 page.
|
|
30
16
|
if (!localeResolved && nextLocale) {
|
|
31
17
|
return { notFound: true };
|
|
32
18
|
}
|
|
33
19
|
if (canonicalUrl) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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);
|
|
38
24
|
if (redirect) {
|
|
39
|
-
return { redirect
|
|
25
|
+
return { redirect };
|
|
40
26
|
}
|
|
41
27
|
}
|
|
42
28
|
return {
|
|
43
29
|
props: pageProps,
|
|
44
30
|
};
|
|
45
31
|
}
|
|
46
|
-
exports.processRequest = processRequest;
|
|
47
32
|
//# sourceMappingURL=processRequest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processRequest.js","sourceRoot":"","sources":["../../src/adapter-nextjs/processRequest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"processRequest.js","sourceRoot":"","sources":["../../src/adapter-nextjs/processRequest.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG5F;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAC1B,OAAkC,EAClC,KAA8C,EAC9C,YAAqB;IAErB,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAE9C,MAAM,EAAE,cAAc,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IAE/C,2GAA2G;IAC3G,uCAAuC;IACvC,IAAI,CAAC,cAAc,IAAI,UAAU,EAAE;QAC/B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;KAC7B;IAED,IAAI,YAAY,EAAE;QACd,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,SAAS,CAAC,oBAAoB,CAAC;QACjE,MAAM,aAAa,GAAG,YAAY,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QAC3D,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;QAE3E,MAAM,QAAQ,GAAG,4BAA4B,CACzC,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,KAAK,CACR,CAAC;QACF,IAAI,QAAQ,EAAE;YACV,OAAO,EAAE,QAAQ,EAAE,CAAC;SACvB;KACJ;IAED,OAAO;QACH,KAAK,EAAE,SAA8B;KACxC,CAAC;AACN,CAAC"}
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.processStaticRequest = void 0;
|
|
15
1
|
/**
|
|
16
2
|
* This function combines the props returned from `getNewsroomStaticProps` and your optional custom props for the page.
|
|
17
3
|
* See README for usage examples.
|
|
@@ -20,9 +6,9 @@ exports.processStaticRequest = void 0;
|
|
|
20
6
|
* @param props Object containing the return of `getNewsroomServerSideProps` and your optional custom props.
|
|
21
7
|
* @param revalidateTimeout Optional: timeout in seconds to use with Next ISR.
|
|
22
8
|
*/
|
|
23
|
-
function processStaticRequest(context, props, revalidateTimeout) {
|
|
24
|
-
|
|
25
|
-
|
|
9
|
+
export function processStaticRequest(context, props, revalidateTimeout) {
|
|
10
|
+
const { locale: nextLocale } = context;
|
|
11
|
+
const { localeResolved, ...pageProps } = props;
|
|
26
12
|
// If no locale was provided by Next, it most likely means that the theme is not supporting multi-language.
|
|
27
13
|
// In that case we won't show 404 page.
|
|
28
14
|
if (!localeResolved && nextLocale) {
|
|
@@ -33,5 +19,4 @@ function processStaticRequest(context, props, revalidateTimeout) {
|
|
|
33
19
|
revalidate: revalidateTimeout,
|
|
34
20
|
};
|
|
35
21
|
}
|
|
36
|
-
exports.processStaticRequest = processStaticRequest;
|
|
37
22
|
//# sourceMappingURL=processStaticRequest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processStaticRequest.js","sourceRoot":"","sources":["../../src/adapter-nextjs/processStaticRequest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"processStaticRequest.js","sourceRoot":"","sources":["../../src/adapter-nextjs/processStaticRequest.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAChC,OAA8B,EAC9B,KAA8C,EAC9C,iBAA0B;IAE1B,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAEvC,MAAM,EAAE,cAAc,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IAE/C,2GAA2G;IAC3G,uCAAuC;IACvC,IAAI,CAAC,cAAc,IAAI,UAAU,EAAE;QAC/B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;KAC7B;IAED,OAAO;QACH,KAAK,EAAE,SAA8B;QACrC,UAAU,EAAE,iBAAiB;KAChC,CAAC;AACN,CAAC"}
|
|
@@ -1,71 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
-
var t = {};
|
|
15
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
-
t[p] = s[p];
|
|
17
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
-
t[p[i]] = s[p[i]];
|
|
21
|
-
}
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.PageSeo = void 0;
|
|
26
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
27
|
-
var next_seo_1 = require("next-seo");
|
|
28
|
-
var router_1 = require("next/router");
|
|
29
|
-
var react_1 = require("react");
|
|
30
|
-
var intl_1 = require("../../intl");
|
|
31
|
-
var newsroom_context_1 = require("../../newsroom-context");
|
|
32
|
-
var utils_1 = require("../../utils");
|
|
33
|
-
var getAbsoluteUrl_1 = require("./lib/getAbsoluteUrl");
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { NextSeo } from 'next-seo';
|
|
3
|
+
import { useRouter } from 'next/router';
|
|
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';
|
|
34
9
|
/**
|
|
35
10
|
* This component provides base page attributes for every Newsroom page.
|
|
36
11
|
* It depends on information from NewsroomContext, so the component should be placed inside the `NewsroomContextProvider`.
|
|
37
12
|
* You can pass additional props expected by NextSeo component to override any info that is provided by the NewsroomContext.
|
|
38
13
|
*/
|
|
39
|
-
function PageSeo(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
var alternateLanguageLinks = (0, react_1.useMemo)(function () {
|
|
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(() => {
|
|
55
29
|
if (!languages.length) {
|
|
56
30
|
return [];
|
|
57
31
|
}
|
|
58
|
-
|
|
32
|
+
const alternateLanguages = getUsedLanguages(languages).filter((language) => language.code !== currentLocale.toUnderscoreCode());
|
|
59
33
|
return alternateLanguages
|
|
60
|
-
.map(
|
|
61
|
-
|
|
62
|
-
|
|
34
|
+
.map((language) => {
|
|
35
|
+
const locale = LocaleObject.fromAnyCode(language.code);
|
|
36
|
+
const translationLink = getTranslationUrl(locale, true);
|
|
63
37
|
if (!translationLink) {
|
|
64
38
|
return undefined;
|
|
65
39
|
}
|
|
66
40
|
return {
|
|
67
41
|
hrefLang: locale.toHyphenCode(),
|
|
68
|
-
href:
|
|
42
|
+
href: getAbsoluteUrl(translationLink, newsroom.url, currentStory && translationLink !== '/' ? false : getLinkLocaleSlug(locale)),
|
|
69
43
|
};
|
|
70
44
|
})
|
|
71
45
|
.filter(Boolean);
|
|
@@ -77,12 +51,23 @@ function PageSeo(_a) {
|
|
|
77
51
|
newsroom.url,
|
|
78
52
|
currentStory,
|
|
79
53
|
]);
|
|
80
|
-
return ((
|
|
54
|
+
return (_jsx(NextSeo, { title: pageTitle, description: pageDescription, canonical: canonicalUrl, noindex: newsroom.is_indexable, nofollow: newsroom.is_indexable, openGraph: {
|
|
55
|
+
url: canonicalUrl,
|
|
56
|
+
title: pageTitle,
|
|
57
|
+
description: pageDescription,
|
|
58
|
+
locale: currentLocale.toUnderscoreCode(),
|
|
59
|
+
images: [
|
|
81
60
|
{
|
|
82
61
|
url: logoUrl,
|
|
83
62
|
alt: pageTitle,
|
|
84
63
|
},
|
|
85
|
-
],
|
|
64
|
+
],
|
|
65
|
+
site_name: siteName,
|
|
66
|
+
...openGraph,
|
|
67
|
+
}, twitter: {
|
|
68
|
+
site: siteName,
|
|
69
|
+
cardType: 'summary',
|
|
70
|
+
...twitter,
|
|
71
|
+
}, additionalMetaTags: [{ name: 'twitter:image', content: logoUrl }], languageAlternates: alternateLanguageLinks, ...nextSeoProps }));
|
|
86
72
|
}
|
|
87
|
-
exports.PageSeo = PageSeo;
|
|
88
73
|
//# sourceMappingURL=PageSeo.js.map
|