@prezly/theme-kit-nextjs 1.10.0 → 1.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -0
- package/build/adapter-nextjs/page-props/index.d.ts +1 -0
- package/build/adapter-nextjs/page-props/index.js +3 -1
- package/build/adapter-nextjs/page-props/index.js.map +1 -1
- package/build/adapter-nextjs/page-props/search.d.ts +3 -0
- package/build/adapter-nextjs/page-props/search.js +80 -0
- package/build/adapter-nextjs/page-props/search.js.map +1 -0
- package/build/data-fetching/boilerplate.d.ts +4 -0
- package/build/data-fetching/boilerplate.js +24 -0
- package/build/data-fetching/boilerplate.js.map +1 -0
- package/build/data-fetching/getDataRequestLink.d.ts +3 -0
- package/build/data-fetching/getDataRequestLink.js +12 -0
- package/build/data-fetching/getDataRequestLink.js.map +1 -0
- package/build/data-fetching/index.d.ts +3 -0
- package/build/data-fetching/index.js +3 -0
- package/build/data-fetching/index.js.map +1 -1
- package/build/data-fetching/isEmbargoStory.d.ts +6 -0
- package/build/data-fetching/isEmbargoStory.js +8 -0
- package/build/data-fetching/isEmbargoStory.js.map +1 -0
- package/package.json +1 -1
- package/src/adapter-nextjs/page-props/index.ts +1 -0
- package/src/adapter-nextjs/page-props/search.ts +27 -0
- package/src/data-fetching/boilerplate.ts +27 -0
- package/src/data-fetching/getDataRequestLink.ts +14 -0
- package/src/data-fetching/index.ts +3 -0
- package/src/data-fetching/isEmbargoStory.ts +10 -0
package/README.md
CHANGED
|
@@ -181,6 +181,49 @@ This function returns the combined base props and your additional props, with so
|
|
|
181
181
|
|
|
182
182
|
The third argument is needed to properly handle locale redirects. It should contain the URL for the current page without locale prefixes (like `/`, `/media`, `/category/${category.slug}`. If omitted, the redirect logic will not be executing.
|
|
183
183
|
|
|
184
|
+
**Helpers for common pages**
|
|
185
|
+
|
|
186
|
+
To reduce boilerplate for common scenarios, the library provides a collection of prop fetching methods for each of the default Prezly Newsroom pages. All of them support custom props, so you can still have minimal boilerplate with all the same customization. If you have a more specific scenario, you can still use the code shown in the beginning of this section.
|
|
187
|
+
|
|
188
|
+
Here's an example of `getServerSideProps` function with no custom props:
|
|
189
|
+
```ts
|
|
190
|
+
import { getHomepageServerSideProps } from '@prezly/theme-kit-nextjs';
|
|
191
|
+
|
|
192
|
+
/* ...your page component */
|
|
193
|
+
|
|
194
|
+
export const getServerSideProps = getHomepageServerSideProps({});
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
And here's a more sophisticated scenario from Bea Theme, with extra options and custom props that depend on the Next request context and newsroom context props:
|
|
198
|
+
```ts
|
|
199
|
+
import { getHomepageServerSideProps, type HomePageProps } from '@prezly/theme-kit-nextjs';
|
|
200
|
+
import dynamic from 'next/dynamic';
|
|
201
|
+
import type { FunctionComponent } from 'react';
|
|
202
|
+
|
|
203
|
+
import { importMessages, isTrackingEnabled } from '@/utils';
|
|
204
|
+
import type { BasePageProps, StoryWithImage } from 'types';
|
|
205
|
+
|
|
206
|
+
const Stories = dynamic(() => import('@/modules/Stories'), { ssr: true });
|
|
207
|
+
|
|
208
|
+
type Props = BasePageProps & HomePageProps<StoryWithImage>;
|
|
209
|
+
|
|
210
|
+
const IndexPage: FunctionComponent<Props> = ({ stories, pagination }) => (
|
|
211
|
+
<Stories stories={stories} pagination={pagination} />
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
export const getServerSideProps = getHomepageServerSideProps<BasePageProps, StoryWithImage>(
|
|
215
|
+
async (context, { newsroomContextProps }) => ({
|
|
216
|
+
isTrackingEnabled: isTrackingEnabled(context),
|
|
217
|
+
translations: await importMessages(newsroomContextProps.localeCode),
|
|
218
|
+
}),
|
|
219
|
+
{ extraStoryFields: ['thumbnail_image'] },
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
export default IndexPage;
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
You can find all of the helper methods in the [page-props](./tree/main/src/adapter-nextjs/page-props) directory. You can also refer to [Prezly Bea Theme](https://github.com/prezly/theme-nextjs-bea) for usage examples.
|
|
226
|
+
|
|
184
227
|
### SEO Helper components
|
|
185
228
|
|
|
186
229
|
This library provides two components: [PageSeo](./tree/main/src/components-nextjs/PageSeo) and [StorySeo](./tree/main/src/components-nextjs/StorySeo), both based on the [next-seo](https://github.com/garmeeh/next-seo) library. They consume information from the `NewsroomContext` and provide all the necessary tags for your pages, with correct social preview, as well as JsonLD and OpenGraph data for your stories. You can also override the parameters for `PageSeo` component, these will be passed straight to `NextSeo` component. See the JSDoc comments on the exported components to get instructions on their usage.
|
|
@@ -2,5 +2,6 @@ export { getCategoryPageServerSideProps, type CategoryPageProps } from './catego
|
|
|
2
2
|
export { getGalleryPageServerSideProps, type GalleryPageProps } from './gallery';
|
|
3
3
|
export { getGalleryAlbumPageServerSideProps, type GalleryAlbumPageProps } from './galleryAlbum';
|
|
4
4
|
export { getHomepageServerSideProps, type HomePageProps } from './home';
|
|
5
|
+
export { getSearchPageServerSideProps } from './search';
|
|
5
6
|
export { getStoryPageServerSideProps } from './story';
|
|
6
7
|
export { getStoryPreviewPageServerSideProps } from './storyPreview';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getStoryPreviewPageServerSideProps = exports.getStoryPageServerSideProps = exports.getHomepageServerSideProps = exports.getGalleryAlbumPageServerSideProps = exports.getGalleryPageServerSideProps = exports.getCategoryPageServerSideProps = void 0;
|
|
3
|
+
exports.getStoryPreviewPageServerSideProps = exports.getStoryPageServerSideProps = exports.getSearchPageServerSideProps = exports.getHomepageServerSideProps = exports.getGalleryAlbumPageServerSideProps = exports.getGalleryPageServerSideProps = exports.getCategoryPageServerSideProps = void 0;
|
|
4
4
|
var category_1 = require("./category");
|
|
5
5
|
Object.defineProperty(exports, "getCategoryPageServerSideProps", { enumerable: true, get: function () { return category_1.getCategoryPageServerSideProps; } });
|
|
6
6
|
var gallery_1 = require("./gallery");
|
|
@@ -9,6 +9,8 @@ var galleryAlbum_1 = require("./galleryAlbum");
|
|
|
9
9
|
Object.defineProperty(exports, "getGalleryAlbumPageServerSideProps", { enumerable: true, get: function () { return galleryAlbum_1.getGalleryAlbumPageServerSideProps; } });
|
|
10
10
|
var home_1 = require("./home");
|
|
11
11
|
Object.defineProperty(exports, "getHomepageServerSideProps", { enumerable: true, get: function () { return home_1.getHomepageServerSideProps; } });
|
|
12
|
+
var search_1 = require("./search");
|
|
13
|
+
Object.defineProperty(exports, "getSearchPageServerSideProps", { enumerable: true, get: function () { return search_1.getSearchPageServerSideProps; } });
|
|
12
14
|
var story_1 = require("./story");
|
|
13
15
|
Object.defineProperty(exports, "getStoryPageServerSideProps", { enumerable: true, get: function () { return story_1.getStoryPageServerSideProps; } });
|
|
14
16
|
var storyPreview_1 = require("./storyPreview");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/index.ts"],"names":[],"mappings":";;;AAAA,uCAAoF;AAA3E,0HAAA,8BAA8B,OAAA;AACvC,qCAAiF;AAAxE,wHAAA,6BAA6B,OAAA;AACtC,+CAAgG;AAAvF,kIAAA,kCAAkC,OAAA;AAC3C,+BAAwE;AAA/D,kHAAA,0BAA0B,OAAA;AACnC,iCAAsD;AAA7C,oHAAA,2BAA2B,OAAA;AACpC,+CAAoE;AAA3D,kIAAA,kCAAkC,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/index.ts"],"names":[],"mappings":";;;AAAA,uCAAoF;AAA3E,0HAAA,8BAA8B,OAAA;AACvC,qCAAiF;AAAxE,wHAAA,6BAA6B,OAAA;AACtC,+CAAgG;AAAvF,kIAAA,kCAAkC,OAAA;AAC3C,+BAAwE;AAA/D,kHAAA,0BAA0B,OAAA;AACnC,mCAAwD;AAA/C,sHAAA,4BAA4B,OAAA;AACrC,iCAAsD;AAA7C,oHAAA,2BAA2B,OAAA;AACpC,+CAAoE;AAA3D,kIAAA,kCAAkC,OAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { GetServerSidePropsContext, GetServerSidePropsResult } from 'next';
|
|
2
|
+
import type { PropsFunction } from './lib/types';
|
|
3
|
+
export declare function getSearchPageServerSideProps<CustomProps extends Record<string, any>>(customProps: CustomProps | PropsFunction<CustomProps>): (context: GetServerSidePropsContext) => Promise<GetServerSidePropsResult<CustomProps>>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
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.getSearchPageServerSideProps = void 0;
|
|
51
|
+
var getNewsroomServerSideProps_1 = require("../getNewsroomServerSideProps");
|
|
52
|
+
var processRequest_1 = require("../processRequest");
|
|
53
|
+
function getSearchPageServerSideProps(customProps) {
|
|
54
|
+
return function getServerSideProps(context) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
+
var serverSideProps, _a, _b, _c, _d;
|
|
57
|
+
return __generator(this, function (_e) {
|
|
58
|
+
switch (_e.label) {
|
|
59
|
+
case 0: return [4 /*yield*/, (0, getNewsroomServerSideProps_1.getNewsroomServerSideProps)(context)];
|
|
60
|
+
case 1:
|
|
61
|
+
serverSideProps = (_e.sent()).serverSideProps;
|
|
62
|
+
_a = processRequest_1.processRequest;
|
|
63
|
+
_b = [context];
|
|
64
|
+
_c = [__assign({}, serverSideProps)];
|
|
65
|
+
if (!(typeof customProps === 'function')) return [3 /*break*/, 3];
|
|
66
|
+
return [4 /*yield*/, customProps(context, serverSideProps)];
|
|
67
|
+
case 2:
|
|
68
|
+
_d = _e.sent();
|
|
69
|
+
return [3 /*break*/, 4];
|
|
70
|
+
case 3:
|
|
71
|
+
_d = customProps;
|
|
72
|
+
_e.label = 4;
|
|
73
|
+
case 4: return [2 /*return*/, _a.apply(void 0, _b.concat([__assign.apply(void 0, _c.concat([(_d)])), '/search']))];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
exports.getSearchPageServerSideProps = getSearchPageServerSideProps;
|
|
80
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/search.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,4EAA2E;AAC3E,oDAAmD;AAInD,SAAgB,4BAA4B,CACxC,WAAqD;IAErD,OAAO,SAAe,kBAAkB,CACpC,OAAkC;;;;;4BAEN,qBAAM,IAAA,uDAA0B,EAAC,OAAO,CAAC,EAAA;;wBAA7D,eAAe,GAAK,CAAA,SAAyC,CAAA,gBAA9C;wBAEhB,KAAA,+BAAc,CAAA;8BACjB,OAAO;2CAEA,eAAe;6BACd,CAAA,OAAO,WAAW,KAAK,UAAU,CAAA,EAAjC,wBAAiC;wBAC/B,qBAAO,WAA0C,CAAC,OAAO,EAAE,eAAe,CAAC,EAAA;;wBAA3E,KAAA,SAA2E,CAAA;;;wBAC3E,KAAA,WAAW,CAAA;;4BANzB,sBAAO,8DAII,IAEe,KAEtB,SAAS,GACZ,EAAC;;;;KACL,CAAC;AACN,CAAC;AAnBD,oEAmBC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { NewsroomCompanyInformation } from '@prezly/sdk';
|
|
2
|
+
export declare function hasAnySocialMedia(companyInformation: NewsroomCompanyInformation): boolean;
|
|
3
|
+
export declare function hasAnyAboutInformation(companyInformation: NewsroomCompanyInformation): boolean;
|
|
4
|
+
export declare function hasAnyContactInformation(companyInformation: NewsroomCompanyInformation): boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasAnyContactInformation = exports.hasAnyAboutInformation = exports.hasAnySocialMedia = void 0;
|
|
4
|
+
function hasAnySocialMedia(companyInformation) {
|
|
5
|
+
return Boolean(companyInformation.facebook ||
|
|
6
|
+
companyInformation.instagram ||
|
|
7
|
+
companyInformation.linkedin ||
|
|
8
|
+
companyInformation.pinterest ||
|
|
9
|
+
companyInformation.tiktok ||
|
|
10
|
+
companyInformation.twitter ||
|
|
11
|
+
companyInformation.youtube);
|
|
12
|
+
}
|
|
13
|
+
exports.hasAnySocialMedia = hasAnySocialMedia;
|
|
14
|
+
function hasAnyAboutInformation(companyInformation) {
|
|
15
|
+
return Boolean(companyInformation.about ||
|
|
16
|
+
companyInformation.website ||
|
|
17
|
+
hasAnySocialMedia(companyInformation));
|
|
18
|
+
}
|
|
19
|
+
exports.hasAnyAboutInformation = hasAnyAboutInformation;
|
|
20
|
+
function hasAnyContactInformation(companyInformation) {
|
|
21
|
+
return Boolean(companyInformation.address || companyInformation.phone || companyInformation.email);
|
|
22
|
+
}
|
|
23
|
+
exports.hasAnyContactInformation = hasAnyContactInformation;
|
|
24
|
+
//# sourceMappingURL=boilerplate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boilerplate.js","sourceRoot":"","sources":["../../src/data-fetching/boilerplate.ts"],"names":[],"mappings":";;;AAEA,SAAgB,iBAAiB,CAAC,kBAA8C;IAC5E,OAAO,OAAO,CACV,kBAAkB,CAAC,QAAQ;QACvB,kBAAkB,CAAC,SAAS;QAC5B,kBAAkB,CAAC,QAAQ;QAC3B,kBAAkB,CAAC,SAAS;QAC5B,kBAAkB,CAAC,MAAM;QACzB,kBAAkB,CAAC,OAAO;QAC1B,kBAAkB,CAAC,OAAO,CACjC,CAAC;AACN,CAAC;AAVD,8CAUC;AAED,SAAgB,sBAAsB,CAAC,kBAA8C;IACjF,OAAO,OAAO,CACV,kBAAkB,CAAC,KAAK;QACpB,kBAAkB,CAAC,OAAO;QAC1B,iBAAiB,CAAC,kBAAkB,CAAC,CAC5C,CAAC;AACN,CAAC;AAND,wDAMC;AAED,SAAgB,wBAAwB,CAAC,kBAA8C;IACnF,OAAO,OAAO,CACV,kBAAkB,CAAC,OAAO,IAAI,kBAAkB,CAAC,KAAK,IAAI,kBAAkB,CAAC,KAAK,CACrF,CAAC;AACN,CAAC;AAJD,4DAIC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDataRequestLink = void 0;
|
|
4
|
+
var getPrivacyPortalUrl_1 = require("./getPrivacyPortalUrl");
|
|
5
|
+
function getDataRequestLink(newsroom, currentLocale) {
|
|
6
|
+
return (newsroom.custom_data_request_link ||
|
|
7
|
+
(0, getPrivacyPortalUrl_1.getPrivacyPortalUrl)(newsroom, currentLocale, {
|
|
8
|
+
action: 'data-request',
|
|
9
|
+
}));
|
|
10
|
+
}
|
|
11
|
+
exports.getDataRequestLink = getDataRequestLink;
|
|
12
|
+
//# sourceMappingURL=getDataRequestLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDataRequestLink.js","sourceRoot":"","sources":["../../src/data-fetching/getDataRequestLink.ts"],"names":[],"mappings":";;;AAIA,6DAA4D;AAE5D,SAAgB,kBAAkB,CAAC,QAAkB,EAAE,aAA2B;IAC9E,OAAO,CACH,QAAQ,CAAC,wBAAwB;QACjC,IAAA,yCAAmB,EAAC,QAAQ,EAAE,aAAa,EAAE;YACzC,MAAM,EAAE,cAAc;SACzB,CAAC,CACL,CAAC;AACN,CAAC;AAPD,gDAOC"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
export * from './api';
|
|
2
|
+
export * from './boilerplate';
|
|
2
3
|
export * from './constants';
|
|
3
4
|
export * from './getAssetsUrl';
|
|
5
|
+
export * from './getDataRequestLink';
|
|
4
6
|
export * from './getLocalizedCategoryData';
|
|
5
7
|
export * from './getNewsroomLogoUrl';
|
|
6
8
|
export * from './getPrivacyPortalUrl';
|
|
7
9
|
export * from './getStoryPublicationDate';
|
|
8
10
|
export * from './getUploadcareGroupUrl';
|
|
11
|
+
export * from './isEmbargoStory';
|
|
9
12
|
export * from './lib';
|
|
10
13
|
export * from './types';
|
|
@@ -11,13 +11,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./api"), exports);
|
|
14
|
+
__exportStar(require("./boilerplate"), exports);
|
|
14
15
|
__exportStar(require("./constants"), exports);
|
|
15
16
|
__exportStar(require("./getAssetsUrl"), exports);
|
|
17
|
+
__exportStar(require("./getDataRequestLink"), exports);
|
|
16
18
|
__exportStar(require("./getLocalizedCategoryData"), exports);
|
|
17
19
|
__exportStar(require("./getNewsroomLogoUrl"), exports);
|
|
18
20
|
__exportStar(require("./getPrivacyPortalUrl"), exports);
|
|
19
21
|
__exportStar(require("./getStoryPublicationDate"), exports);
|
|
20
22
|
__exportStar(require("./getUploadcareGroupUrl"), exports);
|
|
23
|
+
__exportStar(require("./isEmbargoStory"), exports);
|
|
21
24
|
__exportStar(require("./lib"), exports);
|
|
22
25
|
__exportStar(require("./types"), exports);
|
|
23
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data-fetching/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAsB;AACtB,8CAA4B;AAC5B,iDAA+B;AAC/B,6DAA2C;AAC3C,uDAAqC;AACrC,wDAAsC;AACtC,4DAA0C;AAC1C,0DAAwC;AACxC,wCAAsB;AACtB,0CAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data-fetching/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAsB;AACtB,gDAA8B;AAC9B,8CAA4B;AAC5B,iDAA+B;AAC/B,uDAAqC;AACrC,6DAA2C;AAC3C,uDAAqC;AACrC,wDAAsC;AACtC,4DAA0C;AAC1C,0DAAwC;AACxC,mDAAiC;AACjC,wCAAsB;AACtB,0CAAwB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isEmbargoStory = void 0;
|
|
4
|
+
function isEmbargoStory(story) {
|
|
5
|
+
return story.is_embargo && Boolean(story.published_at);
|
|
6
|
+
}
|
|
7
|
+
exports.isEmbargoStory = isEmbargoStory;
|
|
8
|
+
//# sourceMappingURL=isEmbargoStory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isEmbargoStory.js","sourceRoot":"","sources":["../../src/data-fetching/isEmbargoStory.ts"],"names":[],"mappings":";;;AAOA,SAAgB,cAAc,CAAC,KAAY;IACvC,OAAO,KAAK,CAAC,UAAU,IAAI,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AAC3D,CAAC;AAFD,wCAEC"}
|
package/package.json
CHANGED
|
@@ -2,5 +2,6 @@ export { getCategoryPageServerSideProps, type CategoryPageProps } from './catego
|
|
|
2
2
|
export { getGalleryPageServerSideProps, type GalleryPageProps } from './gallery';
|
|
3
3
|
export { getGalleryAlbumPageServerSideProps, type GalleryAlbumPageProps } from './galleryAlbum';
|
|
4
4
|
export { getHomepageServerSideProps, type HomePageProps } from './home';
|
|
5
|
+
export { getSearchPageServerSideProps } from './search';
|
|
5
6
|
export { getStoryPageServerSideProps } from './story';
|
|
6
7
|
export { getStoryPreviewPageServerSideProps } from './storyPreview';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { GetServerSidePropsContext, GetServerSidePropsResult } from 'next';
|
|
2
|
+
|
|
3
|
+
import { getNewsroomServerSideProps } from '../getNewsroomServerSideProps';
|
|
4
|
+
import { processRequest } from '../processRequest';
|
|
5
|
+
|
|
6
|
+
import type { PropsFunction } from './lib/types';
|
|
7
|
+
|
|
8
|
+
export function getSearchPageServerSideProps<CustomProps extends Record<string, any>>(
|
|
9
|
+
customProps: CustomProps | PropsFunction<CustomProps>,
|
|
10
|
+
) {
|
|
11
|
+
return async function getServerSideProps(
|
|
12
|
+
context: GetServerSidePropsContext,
|
|
13
|
+
): Promise<GetServerSidePropsResult<CustomProps>> {
|
|
14
|
+
const { serverSideProps } = await getNewsroomServerSideProps(context);
|
|
15
|
+
|
|
16
|
+
return processRequest(
|
|
17
|
+
context,
|
|
18
|
+
{
|
|
19
|
+
...serverSideProps,
|
|
20
|
+
...(typeof customProps === 'function'
|
|
21
|
+
? await (customProps as PropsFunction<CustomProps>)(context, serverSideProps)
|
|
22
|
+
: customProps),
|
|
23
|
+
},
|
|
24
|
+
'/search',
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { NewsroomCompanyInformation } from '@prezly/sdk';
|
|
2
|
+
|
|
3
|
+
export function hasAnySocialMedia(companyInformation: NewsroomCompanyInformation): boolean {
|
|
4
|
+
return Boolean(
|
|
5
|
+
companyInformation.facebook ||
|
|
6
|
+
companyInformation.instagram ||
|
|
7
|
+
companyInformation.linkedin ||
|
|
8
|
+
companyInformation.pinterest ||
|
|
9
|
+
companyInformation.tiktok ||
|
|
10
|
+
companyInformation.twitter ||
|
|
11
|
+
companyInformation.youtube,
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function hasAnyAboutInformation(companyInformation: NewsroomCompanyInformation): boolean {
|
|
16
|
+
return Boolean(
|
|
17
|
+
companyInformation.about ||
|
|
18
|
+
companyInformation.website ||
|
|
19
|
+
hasAnySocialMedia(companyInformation),
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function hasAnyContactInformation(companyInformation: NewsroomCompanyInformation): boolean {
|
|
24
|
+
return Boolean(
|
|
25
|
+
companyInformation.address || companyInformation.phone || companyInformation.email,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Newsroom } from '@prezly/sdk';
|
|
2
|
+
|
|
3
|
+
import type { LocaleObject } from '../intl';
|
|
4
|
+
|
|
5
|
+
import { getPrivacyPortalUrl } from './getPrivacyPortalUrl';
|
|
6
|
+
|
|
7
|
+
export function getDataRequestLink(newsroom: Newsroom, currentLocale: LocaleObject) {
|
|
8
|
+
return (
|
|
9
|
+
newsroom.custom_data_request_link ||
|
|
10
|
+
getPrivacyPortalUrl(newsroom, currentLocale, {
|
|
11
|
+
action: 'data-request',
|
|
12
|
+
})
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
export * from './api';
|
|
2
|
+
export * from './boilerplate';
|
|
2
3
|
export * from './constants';
|
|
3
4
|
export * from './getAssetsUrl';
|
|
5
|
+
export * from './getDataRequestLink';
|
|
4
6
|
export * from './getLocalizedCategoryData';
|
|
5
7
|
export * from './getNewsroomLogoUrl';
|
|
6
8
|
export * from './getPrivacyPortalUrl';
|
|
7
9
|
export * from './getStoryPublicationDate';
|
|
8
10
|
export * from './getUploadcareGroupUrl';
|
|
11
|
+
export * from './isEmbargoStory';
|
|
9
12
|
export * from './lib';
|
|
10
13
|
export * from './types';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Story } from '@prezly/sdk';
|
|
2
|
+
|
|
3
|
+
export type EmbargoStory = Omit<Story, 'is_embargo' | 'published_at'> & {
|
|
4
|
+
is_embargo: true;
|
|
5
|
+
published_at: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export function isEmbargoStory(story: Story): story is EmbargoStory {
|
|
9
|
+
return story.is_embargo && Boolean(story.published_at);
|
|
10
|
+
}
|