@prezly/theme-kit-nextjs 1.16.4 → 1.17.1-0
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/components-nextjs/PageSeo/PageSeo.js +1 -1
- package/build/components-nextjs/PageSeo/PageSeo.js.map +1 -1
- package/build/components-nextjs/StorySeo/StorySeo.d.ts +2 -1
- package/build/components-nextjs/StorySeo/StorySeo.js +2 -2
- package/build/components-nextjs/StorySeo/StorySeo.js.map +1 -1
- package/build/data-fetching/api/PrezlyApi.js +2 -0
- package/build/data-fetching/api/PrezlyApi.js.map +1 -1
- package/build/intl/languages.d.ts +5 -1
- package/build/intl/languages.js +10 -2
- package/build/intl/languages.js.map +1 -1
- package/build/newsroom-context/context.d.ts +6 -2
- package/build/newsroom-context/context.js +2 -1
- package/build/newsroom-context/context.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/utils/getAssetsUrl.d.ts +3 -2
- package/build/utils/getAssetsUrl.js +9 -3
- package/build/utils/getAssetsUrl.js.map +1 -1
- package/build/utils/getNewsroomLogoUrl.js +2 -2
- package/build/utils/getNewsroomLogoUrl.js.map +1 -1
- package/build/utils/getUploadcareGroupUrl.js +3 -0
- package/build/utils/getUploadcareGroupUrl.js.map +1 -1
- package/package.json +8 -8
- package/src/__mocks__/languages.ts +9 -0
- package/src/__mocks__/story.ts +4 -3
- package/src/components-nextjs/PageSeo/PageSeo.tsx +2 -2
- package/src/components-nextjs/StorySeo/StorySeo.tsx +4 -3
- package/src/data-fetching/api/PrezlyApi.ts +3 -0
- package/src/intl/languages.ts +11 -1
- package/src/newsroom-context/context.tsx +7 -0
- package/src/utils/getAssetsUrl.test.ts +24 -3
- package/src/utils/getAssetsUrl.ts +11 -3
- package/src/utils/getNewsroomLogoUrl.ts +2 -2
- package/src/utils/getUploadcareGroupUrl.ts +4 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { UploadedImage } from '@prezly/sdk';
|
|
1
2
|
/**
|
|
2
|
-
* @param uuid
|
|
3
|
+
* @param image The `UploadedImage` object or uuid of the asset hosted on Uploadcare
|
|
3
4
|
* @returns Full asset URL that can be used as a source for <img>, <video> and <a> tags.
|
|
4
5
|
*/
|
|
5
|
-
export declare function getAssetsUrl(
|
|
6
|
+
export declare function getAssetsUrl(image: UploadedImage | string): string;
|
|
@@ -3,11 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getAssetsUrl = void 0;
|
|
4
4
|
const constants_1 = require("./constants");
|
|
5
5
|
/**
|
|
6
|
-
* @param uuid
|
|
6
|
+
* @param image The `UploadedImage` object or uuid of the asset hosted on Uploadcare
|
|
7
7
|
* @returns Full asset URL that can be used as a source for <img>, <video> and <a> tags.
|
|
8
8
|
*/
|
|
9
|
-
function getAssetsUrl(
|
|
10
|
-
|
|
9
|
+
function getAssetsUrl(image) {
|
|
10
|
+
if (typeof image === 'string') {
|
|
11
|
+
return `${constants_1.ASSETS_URL}/${image}/`;
|
|
12
|
+
}
|
|
13
|
+
if (image.effects.length > 0) {
|
|
14
|
+
return `${constants_1.ASSETS_URL}/${image.uuid}/-${image.effects.join('-')}`;
|
|
15
|
+
}
|
|
16
|
+
return `${constants_1.ASSETS_URL}/${image.uuid}/`;
|
|
11
17
|
}
|
|
12
18
|
exports.getAssetsUrl = getAssetsUrl;
|
|
13
19
|
//# sourceMappingURL=getAssetsUrl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAssetsUrl.js","sourceRoot":"","sources":["../../src/utils/getAssetsUrl.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"getAssetsUrl.js","sourceRoot":"","sources":["../../src/utils/getAssetsUrl.ts"],"names":[],"mappings":";;;AAEA,2CAAyC;AAEzC;;;GAGG;AACH,SAAgB,YAAY,CAAC,KAA6B;IACtD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC3B,OAAO,GAAG,sBAAU,IAAI,KAAK,GAAG,CAAC;KACpC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;QAC1B,OAAO,GAAG,sBAAU,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;KACpE;IACD,OAAO,GAAG,sBAAU,IAAI,KAAK,CAAC,IAAI,GAAG,CAAC;AAC1C,CAAC;AARD,oCAQC"}
|
|
@@ -4,7 +4,7 @@ exports.getNewsroomFaviconUrl = exports.getNewsroomLogoUrl = void 0;
|
|
|
4
4
|
const getAssetsUrl_1 = require("./getAssetsUrl");
|
|
5
5
|
function getNewsroomLogoUrl(newsroom) {
|
|
6
6
|
if (newsroom.newsroom_logo) {
|
|
7
|
-
return (0, getAssetsUrl_1.getAssetsUrl)(newsroom.newsroom_logo
|
|
7
|
+
return (0, getAssetsUrl_1.getAssetsUrl)(newsroom.newsroom_logo);
|
|
8
8
|
}
|
|
9
9
|
return '';
|
|
10
10
|
}
|
|
@@ -12,7 +12,7 @@ exports.getNewsroomLogoUrl = getNewsroomLogoUrl;
|
|
|
12
12
|
function getNewsroomFaviconUrl(newsroom, previewSize = 400) {
|
|
13
13
|
const image = newsroom.icon || newsroom.square_logo;
|
|
14
14
|
if (image) {
|
|
15
|
-
return `${(0, getAssetsUrl_1.getAssetsUrl)(image
|
|
15
|
+
return `${(0, getAssetsUrl_1.getAssetsUrl)(image)}-/preview/${previewSize}x${previewSize}/-/quality/best/`;
|
|
16
16
|
}
|
|
17
17
|
return '';
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNewsroomLogoUrl.js","sourceRoot":"","sources":["../../src/utils/getNewsroomLogoUrl.ts"],"names":[],"mappings":";;;AAEA,iDAA8C;AAE9C,SAAgB,kBAAkB,CAAC,QAAkB;IACjD,IAAI,QAAQ,CAAC,aAAa,EAAE;QACxB,OAAO,IAAA,2BAAY,EAAC,QAAQ,CAAC,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"getNewsroomLogoUrl.js","sourceRoot":"","sources":["../../src/utils/getNewsroomLogoUrl.ts"],"names":[],"mappings":";;;AAEA,iDAA8C;AAE9C,SAAgB,kBAAkB,CAAC,QAAkB;IACjD,IAAI,QAAQ,CAAC,aAAa,EAAE;QACxB,OAAO,IAAA,2BAAY,EAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;KAC/C;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AAND,gDAMC;AAED,SAAgB,qBAAqB,CAAC,QAAkB,EAAE,WAAW,GAAG,GAAG;IACvE,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,WAAW,CAAC;IACpD,IAAI,KAAK,EAAE;QACP,OAAO,GAAG,IAAA,2BAAY,EAAC,KAAK,CAAC,aAAa,WAAW,IAAI,WAAW,kBAAkB,CAAC;KAC1F;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AAPD,sDAOC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getUploadcareGroupUrl = void 0;
|
|
4
|
+
const uploadcare_1 = require("@prezly/uploadcare");
|
|
4
5
|
const constants_1 = require("./constants");
|
|
5
6
|
/**
|
|
6
7
|
* This method constructs a URL to download all images in the Gallery as a single archive.
|
|
@@ -10,6 +11,8 @@ const constants_1 = require("./constants");
|
|
|
10
11
|
* @returns URL to an archive containing all of the images in the Gallery.
|
|
11
12
|
*/
|
|
12
13
|
function getUploadcareGroupUrl(uuid, title) {
|
|
14
|
+
// eslint-disable-next-line no-console
|
|
15
|
+
console.log(uploadcare_1.UploadcareImage);
|
|
13
16
|
return `${constants_1.ASSETS_URL}/${uuid}/archive/zip/${encodeURI(title)}.zip`;
|
|
14
17
|
}
|
|
15
18
|
exports.getUploadcareGroupUrl = getUploadcareGroupUrl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUploadcareGroupUrl.js","sourceRoot":"","sources":["../../src/utils/getUploadcareGroupUrl.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AAEzC;;;;;;GAMG;AACH,SAAgB,qBAAqB,CAAC,IAAY,EAAE,KAAa;IAC7D,OAAO,GAAG,sBAAU,IAAI,IAAI,gBAAgB,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC;AACvE,CAAC;
|
|
1
|
+
{"version":3,"file":"getUploadcareGroupUrl.js","sourceRoot":"","sources":["../../src/utils/getUploadcareGroupUrl.ts"],"names":[],"mappings":";;;AAAA,mDAAqD;AAErD,2CAAyC;AAEzC;;;;;;GAMG;AACH,SAAgB,qBAAqB,CAAC,IAAY,EAAE,KAAa;IAC7D,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,4BAAe,CAAC,CAAC;IAC7B,OAAO,GAAG,sBAAU,IAAI,IAAI,gBAAgB,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC;AACvE,CAAC;AAJD,sDAIC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prezly/theme-kit-nextjs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.1-0",
|
|
4
4
|
"description": "Data layer and utility library for developing Prezly themes with NextJS",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -48,26 +48,26 @@
|
|
|
48
48
|
"react-dom": "^17.x || ^18.x"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@prezly/
|
|
52
|
-
"@prezly/
|
|
51
|
+
"@prezly/sdk": "^7.3.0",
|
|
52
|
+
"@prezly/uploadcare": "^2.3.4",
|
|
53
53
|
"@react-hookz/web": "^14.2.2",
|
|
54
54
|
"next-seo": "^5.4.0",
|
|
55
55
|
"parse-data-url": "^4.0.1"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@prezly/eslint-config": "4.2.0",
|
|
59
|
-
"@sentry/nextjs": "7.
|
|
60
|
-
"@types/jest": "28.1.
|
|
59
|
+
"@sentry/nextjs": "7.10.0",
|
|
60
|
+
"@types/jest": "28.1.7",
|
|
61
61
|
"@types/node": "17.0.14",
|
|
62
62
|
"@types/parse-data-url": "3.0.0",
|
|
63
|
-
"@types/react": "18.0.
|
|
63
|
+
"@types/react": "18.0.17",
|
|
64
64
|
"@types/react-dom": "18.0.6",
|
|
65
|
-
"eslint": "8.
|
|
65
|
+
"eslint": "8.22.0",
|
|
66
66
|
"jest": "28.1.3",
|
|
67
67
|
"np": "7.6.2",
|
|
68
68
|
"prettier": "2.7.1",
|
|
69
69
|
"rimraf": "3.0.2",
|
|
70
|
-
"ts-jest": "28.0.
|
|
70
|
+
"ts-jest": "28.0.8",
|
|
71
71
|
"typescript": "4.7.4"
|
|
72
72
|
},
|
|
73
73
|
"publishConfig": {
|
|
@@ -48,6 +48,7 @@ export const LANGUAGES: Record<string, NewsroomLanguageSettings> = {
|
|
|
48
48
|
subscribe_disclaimer:
|
|
49
49
|
'<p>Door uw abonnement te bevestigen, bevestigt u dat u begrijpt dat u zich registreert om materiaal te ontvangen en dat uw gegevens veilig worden verwerkt en opgeslagen.</p>',
|
|
50
50
|
},
|
|
51
|
+
notifications: [],
|
|
51
52
|
},
|
|
52
53
|
nl_NL: {
|
|
53
54
|
code: 'nl_NL',
|
|
@@ -88,6 +89,7 @@ export const LANGUAGES: Record<string, NewsroomLanguageSettings> = {
|
|
|
88
89
|
cookie_statement: '',
|
|
89
90
|
subscribe_disclaimer: '',
|
|
90
91
|
},
|
|
92
|
+
notifications: [],
|
|
91
93
|
},
|
|
92
94
|
en: {
|
|
93
95
|
code: 'en',
|
|
@@ -134,6 +136,7 @@ export const LANGUAGES: Record<string, NewsroomLanguageSettings> = {
|
|
|
134
136
|
subscribe_disclaimer:
|
|
135
137
|
'<p>By confirming your subscription you are confirming you understand that you are registering to receive content and consent to your information being securely processed and stored.</p>',
|
|
136
138
|
},
|
|
139
|
+
notifications: [],
|
|
137
140
|
},
|
|
138
141
|
en_US: {
|
|
139
142
|
code: 'en_US',
|
|
@@ -180,6 +183,7 @@ export const LANGUAGES: Record<string, NewsroomLanguageSettings> = {
|
|
|
180
183
|
subscribe_disclaimer:
|
|
181
184
|
'<p>By confirming your subscription you are confirming you understand that you are registering to receive content and consent to your information being securely processed and stored.</p>',
|
|
182
185
|
},
|
|
186
|
+
notifications: [],
|
|
183
187
|
},
|
|
184
188
|
en_GB: {
|
|
185
189
|
code: 'en_GB',
|
|
@@ -226,6 +230,7 @@ export const LANGUAGES: Record<string, NewsroomLanguageSettings> = {
|
|
|
226
230
|
subscribe_disclaimer:
|
|
227
231
|
'<p>By confirming your subscription you are confirming you understand that you are registering to receive content and consent to your information being securely processed and stored.</p>',
|
|
228
232
|
},
|
|
233
|
+
notifications: [],
|
|
229
234
|
},
|
|
230
235
|
fr: {
|
|
231
236
|
code: 'fr',
|
|
@@ -272,6 +277,7 @@ export const LANGUAGES: Record<string, NewsroomLanguageSettings> = {
|
|
|
272
277
|
subscribe_disclaimer:
|
|
273
278
|
'<p>En confirmant votre inscription, vous confirmez que vous comprenez que vous vous inscrivez pour recevoir du contenu, et consentez à ce que vos données personnelles soient traitées et stockées en toute sécurité.</p>',
|
|
274
279
|
},
|
|
280
|
+
notifications: [],
|
|
275
281
|
},
|
|
276
282
|
fr_BE: {
|
|
277
283
|
code: 'fr_BE',
|
|
@@ -318,6 +324,7 @@ export const LANGUAGES: Record<string, NewsroomLanguageSettings> = {
|
|
|
318
324
|
subscribe_disclaimer:
|
|
319
325
|
'<p>En confirmant votre inscription, vous confirmez que vous comprenez que vous vous inscrivez pour recevoir du contenu, et consentez à ce que vos données personnelles soient traitées et stockées en toute sécurité.</p>',
|
|
320
326
|
},
|
|
327
|
+
notifications: [],
|
|
321
328
|
},
|
|
322
329
|
es_ES: {
|
|
323
330
|
code: 'es_ES',
|
|
@@ -361,6 +368,7 @@ export const LANGUAGES: Record<string, NewsroomLanguageSettings> = {
|
|
|
361
368
|
subscribe_disclaimer:
|
|
362
369
|
'<p>Al confirmar su suscripción, confirma que entiende que se está registrando para recibir contenido y accede a que su información se procese y guarde de manera segura.</p>',
|
|
363
370
|
},
|
|
371
|
+
notifications: [],
|
|
364
372
|
},
|
|
365
373
|
es_419: {
|
|
366
374
|
code: 'es_419',
|
|
@@ -404,5 +412,6 @@ export const LANGUAGES: Record<string, NewsroomLanguageSettings> = {
|
|
|
404
412
|
subscribe_disclaimer:
|
|
405
413
|
'<p>Al confirmar su suscripción, confirma que entiende que se está registrando para recibir contenido y accede a que su información se procese y guarde de manera segura.</p>',
|
|
406
414
|
},
|
|
415
|
+
notifications: [],
|
|
407
416
|
},
|
|
408
417
|
};
|
package/src/__mocks__/story.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ExtendedStory } from '@prezly/sdk';
|
|
2
2
|
import {
|
|
3
|
+
NewsroomStatus,
|
|
3
4
|
StoryLifecycleStatus,
|
|
4
5
|
StoryPublicationStatus,
|
|
5
6
|
StoryVisibility,
|
|
@@ -68,6 +69,7 @@ export const STORY: ExtendedStory = {
|
|
|
68
69
|
thumbnail_url:
|
|
69
70
|
'https://avatars-cdn.prezly.com/newsroom/12698/e4939974b7781d4c61e282713116690387e9b7b1f6302478b13b68e18e0d3055?t=1648556918&v=1',
|
|
70
71
|
timezone: 'europe/london',
|
|
72
|
+
status: NewsroomStatus.ACTIVE,
|
|
71
73
|
is_active: true,
|
|
72
74
|
is_archived: false,
|
|
73
75
|
is_online: true,
|
|
@@ -77,7 +79,6 @@ export const STORY: ExtendedStory = {
|
|
|
77
79
|
url: 'https://the-good-news-room.prezly.com/',
|
|
78
80
|
links: {
|
|
79
81
|
media_gallery_api: 'https://api.prezly.com/v1/rooms/12698/media',
|
|
80
|
-
room_contacts_api: 'https://api.prezly.com/v1/rooms/12698/contacts',
|
|
81
82
|
analytics_and_visibility_settings:
|
|
82
83
|
'https://rock.prezly.com/pressroom/the-good-news-room/ga',
|
|
83
84
|
categories_management:
|
|
@@ -178,6 +179,7 @@ export const STORY: ExtendedStory = {
|
|
|
178
179
|
thumbnail_url:
|
|
179
180
|
'https://avatars-cdn.prezly.com/newsroom/12698/e4939974b7781d4c61e282713116690387e9b7b1f6302478b13b68e18e0d3055?t=1648556918&v=1',
|
|
180
181
|
timezone: 'europe/london',
|
|
182
|
+
status: NewsroomStatus.ACTIVE,
|
|
181
183
|
is_active: true,
|
|
182
184
|
is_archived: false,
|
|
183
185
|
is_online: true,
|
|
@@ -187,7 +189,6 @@ export const STORY: ExtendedStory = {
|
|
|
187
189
|
url: 'https://the-good-news-room.prezly.com/',
|
|
188
190
|
links: {
|
|
189
191
|
media_gallery_api: 'https://api.prezly.com/v1/rooms/12698/media',
|
|
190
|
-
room_contacts_api: 'https://api.prezly.com/v1/rooms/12698/contacts',
|
|
191
192
|
analytics_and_visibility_settings:
|
|
192
193
|
'https://rock.prezly.com/pressroom/the-good-news-room/ga',
|
|
193
194
|
categories_management:
|
|
@@ -277,6 +278,7 @@ export const STORY: ExtendedStory = {
|
|
|
277
278
|
thumbnail_url:
|
|
278
279
|
'https://avatars-cdn.prezly.com/newsroom/12698/e4939974b7781d4c61e282713116690387e9b7b1f6302478b13b68e18e0d3055?t=1648556918&v=1',
|
|
279
280
|
timezone: 'europe/london',
|
|
281
|
+
status: NewsroomStatus.ACTIVE,
|
|
280
282
|
is_active: true,
|
|
281
283
|
is_archived: false,
|
|
282
284
|
is_online: true,
|
|
@@ -286,7 +288,6 @@ export const STORY: ExtendedStory = {
|
|
|
286
288
|
url: 'https://the-good-news-room.prezly.com/',
|
|
287
289
|
links: {
|
|
288
290
|
media_gallery_api: 'https://api.prezly.com/v1/rooms/12698/media',
|
|
289
|
-
room_contacts_api: 'https://api.prezly.com/v1/rooms/12698/contacts',
|
|
290
291
|
analytics_and_visibility_settings:
|
|
291
292
|
'https://rock.prezly.com/pressroom/the-good-news-room/ga',
|
|
292
293
|
categories_management:
|
|
@@ -95,8 +95,8 @@ export function PageSeo({
|
|
|
95
95
|
title={pageTitle}
|
|
96
96
|
description={pageDescription}
|
|
97
97
|
canonical={canonicalUrl}
|
|
98
|
-
noindex={!newsroom.is_indexable}
|
|
99
|
-
nofollow={!newsroom.is_indexable}
|
|
98
|
+
noindex={nextSeoProps.noindex ?? !newsroom.is_indexable}
|
|
99
|
+
nofollow={nextSeoProps.nofollow ?? !newsroom.is_indexable}
|
|
100
100
|
openGraph={{
|
|
101
101
|
url: canonicalUrl,
|
|
102
102
|
title: pageTitle,
|
|
@@ -4,13 +4,14 @@ import { ArticleJsonLd, NextSeo } from 'next-seo';
|
|
|
4
4
|
|
|
5
5
|
type Props = {
|
|
6
6
|
story: ExtendedStory;
|
|
7
|
+
noindex?: boolean;
|
|
7
8
|
};
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* This components provides additional page attributes for the Story page.
|
|
11
12
|
* It works in conjunction with `PageSeo` component, overidding some of its attributes.
|
|
12
13
|
*/
|
|
13
|
-
export function StorySeo({ story }: Props) {
|
|
14
|
+
export function StorySeo({ story, noindex }: Props) {
|
|
14
15
|
const { title, subtitle, published_at, updated_at, author, oembed, newsroom, summary } = story;
|
|
15
16
|
|
|
16
17
|
const authorName = author?.display_name || author?.email || 'Unknown';
|
|
@@ -23,8 +24,8 @@ export function StorySeo({ story }: Props) {
|
|
|
23
24
|
title={title}
|
|
24
25
|
description={description}
|
|
25
26
|
canonical={oembed.url}
|
|
26
|
-
noindex={!indexable}
|
|
27
|
-
nofollow={!indexable}
|
|
27
|
+
noindex={noindex ?? !indexable}
|
|
28
|
+
nofollow={noindex ?? !indexable}
|
|
28
29
|
openGraph={{
|
|
29
30
|
title,
|
|
30
31
|
description,
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
getDefaultLanguage,
|
|
14
14
|
getLanguageFromNextLocaleIsoCode,
|
|
15
15
|
getLanguageFromStory,
|
|
16
|
+
getNotifications,
|
|
16
17
|
LocaleObject,
|
|
17
18
|
} from '../../intl';
|
|
18
19
|
import type { PageProps, ServerSidePageProps } from '../../types';
|
|
@@ -273,6 +274,7 @@ export class PrezlyApi {
|
|
|
273
274
|
// TODO: if no information given for current language, show boilerplate from default language
|
|
274
275
|
const companyInformation = getCompanyInformation(languages, locale);
|
|
275
276
|
|
|
277
|
+
const notifications = getNotifications(languages, locale);
|
|
276
278
|
const algoliaSettings = getAlgoliaSettings(request);
|
|
277
279
|
|
|
278
280
|
return {
|
|
@@ -282,6 +284,7 @@ export class PrezlyApi {
|
|
|
282
284
|
categories,
|
|
283
285
|
languages,
|
|
284
286
|
localeCode,
|
|
287
|
+
notifications,
|
|
285
288
|
themePreset,
|
|
286
289
|
algoliaSettings,
|
|
287
290
|
},
|
package/src/intl/languages.ts
CHANGED
|
@@ -168,7 +168,17 @@ export function getCompanyInformation(languages: NewsroomLanguageSettings[], loc
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
/**
|
|
171
|
-
* Get
|
|
171
|
+
* Get newsroom notifications for the selected locale
|
|
172
|
+
*/
|
|
173
|
+
export function getNotifications(languages: NewsroomLanguageSettings[], locale: LocaleObject) {
|
|
174
|
+
const currentLanguage =
|
|
175
|
+
getLanguageByExactLocaleCode(languages, locale) || getDefaultLanguage(languages);
|
|
176
|
+
|
|
177
|
+
return currentLanguage.notifications;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Get the shortest locale code possible from full locale code
|
|
172
182
|
* First: try shorting to neutral language code (there should be no locales with the same language code)
|
|
173
183
|
* Then: try shorting to region code (there should be no locales with the same region code)
|
|
174
184
|
* Finally: return the original locale code (shorting is not possible)
|
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
NewsroomContact,
|
|
7
7
|
NewsroomLanguageSettings,
|
|
8
8
|
NewsroomThemePreset,
|
|
9
|
+
Notification,
|
|
9
10
|
} from '@prezly/sdk';
|
|
10
11
|
import type { PropsWithChildren } from 'react';
|
|
11
12
|
import { createContext, useMemo } from 'react';
|
|
@@ -47,6 +48,10 @@ export interface NewsroomContextType {
|
|
|
47
48
|
* Currently chosen locale
|
|
48
49
|
*/
|
|
49
50
|
locale: LocaleObject;
|
|
51
|
+
/**
|
|
52
|
+
* Newsroom user-facing notifications (usually displayed as top-edge banners)
|
|
53
|
+
*/
|
|
54
|
+
notifications: Notification[];
|
|
50
55
|
/**
|
|
51
56
|
* Theme settings as set in the Prezly app.
|
|
52
57
|
* You need to provide `PREZLY_THEME_UUID` in environment variables in order for the preset to be loaded.
|
|
@@ -78,6 +83,7 @@ export function NewsroomContextProvider({
|
|
|
78
83
|
companyInformation,
|
|
79
84
|
languages,
|
|
80
85
|
localeCode,
|
|
86
|
+
notifications,
|
|
81
87
|
themePreset,
|
|
82
88
|
algoliaSettings,
|
|
83
89
|
children,
|
|
@@ -98,6 +104,7 @@ export function NewsroomContextProvider({
|
|
|
98
104
|
companyInformation,
|
|
99
105
|
languages,
|
|
100
106
|
locale,
|
|
107
|
+
notifications,
|
|
101
108
|
themePreset,
|
|
102
109
|
algoliaSettings,
|
|
103
110
|
}}
|
|
@@ -1,10 +1,31 @@
|
|
|
1
|
+
import type { UploadedImage } from '@prezly/sdk';
|
|
1
2
|
import { ASSETS_URL } from './constants';
|
|
2
3
|
import { getAssetsUrl } from './getAssetsUrl';
|
|
3
4
|
|
|
5
|
+
const uploadcareImage: UploadedImage = {
|
|
6
|
+
version: 2,
|
|
7
|
+
uuid: '43258238-9e71-49fa-a35e-dca5baf16a3b',
|
|
8
|
+
filename: 'prezly-photographe.png',
|
|
9
|
+
mime_type: 'image/png',
|
|
10
|
+
size: 74234,
|
|
11
|
+
original_width: 1162,
|
|
12
|
+
original_height: 369,
|
|
13
|
+
effects: ['/crop/369x369/0,0/', '/preview/'],
|
|
14
|
+
};
|
|
15
|
+
|
|
4
16
|
describe('getAssetsUrl', () => {
|
|
5
|
-
it('generates correct asset URL', () => {
|
|
6
|
-
const
|
|
17
|
+
it('generates correct asset URL without effects', () => {
|
|
18
|
+
const image = { ...uploadcareImage, effects: [] };
|
|
19
|
+
expect(getAssetsUrl(image)).toBe(`${ASSETS_URL}/${image.uuid}/`);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('generates correct asset URL with effects', () => {
|
|
23
|
+
expect(getAssetsUrl(uploadcareImage)).toBe(
|
|
24
|
+
`${ASSETS_URL}/${uploadcareImage.uuid}/-${uploadcareImage.effects[0]}-${uploadcareImage.effects[1]}`,
|
|
25
|
+
);
|
|
26
|
+
});
|
|
7
27
|
|
|
8
|
-
|
|
28
|
+
it('generates correct asset URL with uuid passed to it', () => {
|
|
29
|
+
expect(getAssetsUrl(uploadcareImage.uuid)).toBe(`${ASSETS_URL}/${uploadcareImage.uuid}/`);
|
|
9
30
|
});
|
|
10
31
|
});
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
import type { UploadedImage } from '@prezly/sdk';
|
|
2
|
+
|
|
1
3
|
import { ASSETS_URL } from './constants';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
|
-
* @param uuid
|
|
6
|
+
* @param image The `UploadedImage` object or uuid of the asset hosted on Uploadcare
|
|
5
7
|
* @returns Full asset URL that can be used as a source for <img>, <video> and <a> tags.
|
|
6
8
|
*/
|
|
7
|
-
export function getAssetsUrl(
|
|
8
|
-
|
|
9
|
+
export function getAssetsUrl(image: UploadedImage | string) {
|
|
10
|
+
if (typeof image === 'string') {
|
|
11
|
+
return `${ASSETS_URL}/${image}/`;
|
|
12
|
+
}
|
|
13
|
+
if (image.effects.length > 0) {
|
|
14
|
+
return `${ASSETS_URL}/${image.uuid}/-${image.effects.join('-')}`;
|
|
15
|
+
}
|
|
16
|
+
return `${ASSETS_URL}/${image.uuid}/`;
|
|
9
17
|
}
|
|
@@ -4,7 +4,7 @@ import { getAssetsUrl } from './getAssetsUrl';
|
|
|
4
4
|
|
|
5
5
|
export function getNewsroomLogoUrl(newsroom: Newsroom): string {
|
|
6
6
|
if (newsroom.newsroom_logo) {
|
|
7
|
-
return getAssetsUrl(newsroom.newsroom_logo
|
|
7
|
+
return getAssetsUrl(newsroom.newsroom_logo);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
return '';
|
|
@@ -13,7 +13,7 @@ export function getNewsroomLogoUrl(newsroom: Newsroom): string {
|
|
|
13
13
|
export function getNewsroomFaviconUrl(newsroom: Newsroom, previewSize = 400): string {
|
|
14
14
|
const image = newsroom.icon || newsroom.square_logo;
|
|
15
15
|
if (image) {
|
|
16
|
-
return `${getAssetsUrl(image
|
|
16
|
+
return `${getAssetsUrl(image)}-/preview/${previewSize}x${previewSize}/-/quality/best/`;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
return '';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { UploadcareImage } from '@prezly/uploadcare';
|
|
2
|
+
|
|
1
3
|
import { ASSETS_URL } from './constants';
|
|
2
4
|
|
|
3
5
|
/**
|
|
@@ -8,5 +10,7 @@ import { ASSETS_URL } from './constants';
|
|
|
8
10
|
* @returns URL to an archive containing all of the images in the Gallery.
|
|
9
11
|
*/
|
|
10
12
|
export function getUploadcareGroupUrl(uuid: string, title: string) {
|
|
13
|
+
// eslint-disable-next-line no-console
|
|
14
|
+
console.log(UploadcareImage);
|
|
11
15
|
return `${ASSETS_URL}/${uuid}/archive/zip/${encodeURI(title)}.zip`;
|
|
12
16
|
}
|