@prezly/theme-kit-nextjs 1.14.1-0 → 1.15.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/README.md +55 -0
- package/build/adapter-nextjs/getNewsroomStaticProps.d.ts +15 -0
- package/build/adapter-nextjs/getNewsroomStaticProps.js +69 -0
- package/build/adapter-nextjs/getNewsroomStaticProps.js.map +1 -0
- package/build/adapter-nextjs/index.d.ts +2 -0
- package/build/adapter-nextjs/index.js +2 -0
- package/build/adapter-nextjs/index.js.map +1 -1
- package/build/adapter-nextjs/page-props/category.d.ts +3 -1
- package/build/adapter-nextjs/page-props/category.js +104 -1
- package/build/adapter-nextjs/page-props/category.js.map +1 -1
- package/build/adapter-nextjs/page-props/gallery.d.ts +2 -1
- package/build/adapter-nextjs/page-props/gallery.js +48 -1
- package/build/adapter-nextjs/page-props/gallery.js.map +1 -1
- package/build/adapter-nextjs/page-props/galleryAlbum.d.ts +3 -1
- package/build/adapter-nextjs/page-props/galleryAlbum.js +61 -1
- package/build/adapter-nextjs/page-props/galleryAlbum.js.map +1 -1
- package/build/adapter-nextjs/page-props/home.d.ts +2 -1
- package/build/adapter-nextjs/page-props/home.js +48 -1
- package/build/adapter-nextjs/page-props/home.js.map +1 -1
- package/build/adapter-nextjs/page-props/index.d.ts +6 -6
- package/build/adapter-nextjs/page-props/index.js +10 -1
- package/build/adapter-nextjs/page-props/index.js.map +1 -1
- package/build/adapter-nextjs/page-props/lib/types.d.ts +2 -2
- package/build/adapter-nextjs/page-props/search.d.ts +1 -0
- package/build/adapter-nextjs/page-props/search.js +30 -1
- package/build/adapter-nextjs/page-props/search.js.map +1 -1
- package/build/adapter-nextjs/page-props/story.d.ts +10 -1
- package/build/adapter-nextjs/page-props/story.js +69 -1
- package/build/adapter-nextjs/page-props/story.js.map +1 -1
- package/build/adapter-nextjs/processStaticRequest.d.ts +11 -0
- package/build/adapter-nextjs/processStaticRequest.js +37 -0
- package/build/adapter-nextjs/processStaticRequest.js.map +1 -0
- package/build/data-fetching/api/PrezlyApi.d.ts +3 -2
- package/build/data-fetching/api/PrezlyApi.js +22 -4
- package/build/data-fetching/api/PrezlyApi.js.map +1 -1
- package/build/intl/languages.js +1 -1
- package/build/intl/languages.js.map +1 -1
- package/build/intl/localeConfig.js +2 -2
- package/build/intl/localeConfig.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/__mocks__/languages.ts +1 -1
- package/src/adapter-nextjs/getNewsroomStaticProps.ts +29 -0
- package/src/adapter-nextjs/index.ts +2 -0
- package/src/adapter-nextjs/page-props/category.ts +85 -2
- package/src/adapter-nextjs/page-props/gallery.ts +48 -1
- package/src/adapter-nextjs/page-props/galleryAlbum.ts +47 -1
- package/src/adapter-nextjs/page-props/home.ts +46 -1
- package/src/adapter-nextjs/page-props/index.ts +24 -6
- package/src/adapter-nextjs/page-props/lib/types.ts +2 -2
- package/src/adapter-nextjs/page-props/search.ts +19 -0
- package/src/adapter-nextjs/page-props/story.ts +49 -1
- package/src/adapter-nextjs/processStaticRequest.ts +32 -0
- package/src/data-fetching/api/PrezlyApi.ts +19 -5
- package/src/intl/languages.ts +1 -1
- package/src/intl/localeConfig.js +2 -2
package/README.md
CHANGED
|
@@ -254,6 +254,61 @@ export const getServerSideProps = getSitemapServerSideProps(additionalPaths);
|
|
|
254
254
|
|
|
255
255
|
If you need a more customized approach, you can build your own Sitemap by extending the `SitemapBuilder` class exported from the library, as well as referring to the code in the [Sitemap](./tree/main/src/adapter-nextjs/page-props/sitemap) component directory.
|
|
256
256
|
|
|
257
|
+
### Experimental: Static Site Generation
|
|
258
|
+
|
|
259
|
+
For self-hosted applications, we now provide an option to use SSG in your project. However, this comes with some limitations:
|
|
260
|
+
|
|
261
|
+
- Multi-langugage is not yet supported. Make sure to remove the `i18n` property from your `next.config.js`.
|
|
262
|
+
- Sitemap will still use SSR to set the XML Content-Type headers on the response.
|
|
263
|
+
- Story preview page needs to use SSR to ensure that content is always up to date.
|
|
264
|
+
|
|
265
|
+
The workflow is pretty much the same as with our default SSR approach. You will need to use the new `getNewsroomStaticProps` and `processStaticRequest` methods. Note that `getNewsroomStaticProps` returns its props in the `staticProps` property. The data is still the same as in the SSR methods, so apart from multi-language, this should be a drop-in replacement for your pages.
|
|
266
|
+
```tsx
|
|
267
|
+
import { getNewsroomStaticProps, processStaticRequest } from '@prezly/theme-kit-nextjs';
|
|
268
|
+
import type { GetStaticProps } from 'next';
|
|
269
|
+
|
|
270
|
+
/* Your Page component code */
|
|
271
|
+
|
|
272
|
+
export const getStaticProps: GetServerSideProps<Props> = async (context) => {
|
|
273
|
+
const { api, staticProps } = await getNewsroomStaticProps(context);
|
|
274
|
+
|
|
275
|
+
/* Your logic to get additional props for this page */
|
|
276
|
+
|
|
277
|
+
return processStaticRequest(
|
|
278
|
+
context,
|
|
279
|
+
{
|
|
280
|
+
...serverSideProps,
|
|
281
|
+
myProp: 'My Custom Prop',
|
|
282
|
+
},
|
|
283
|
+
);
|
|
284
|
+
};
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
We also have added all of the page helpers (except Story Preview) for SSG prop fetching. Here's an example for the Home page:
|
|
288
|
+
```ts
|
|
289
|
+
import { getHomepageStaticProps } from '@prezly/theme-kit-nextjs';
|
|
290
|
+
|
|
291
|
+
/* ...your page component */
|
|
292
|
+
|
|
293
|
+
export const getStaticProps = getHomepageStaticProps({});
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
For dynamic pages, like `/story/[slug]`, we also provide `getStaticPaths` helper functions:
|
|
298
|
+
```tsx
|
|
299
|
+
import { getStoryPageStaticPaths, getStoryPageStaticProps } from '@prezly/theme-kit-nextjs';
|
|
300
|
+
|
|
301
|
+
/* Your Page component code */
|
|
302
|
+
|
|
303
|
+
export const getStaticProps = getStoryPageStaticProps({});
|
|
304
|
+
|
|
305
|
+
export const getStaticPaths = getStoryPageStaticPaths;
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
These are available for `/category/[slug]`, `/story/[slug]` and `/media/album/[uuid]` pages.
|
|
309
|
+
|
|
310
|
+
You can find all of the helper methods in the [page-props](./tree/main/src/adapter-nextjs/page-props) directory.
|
|
311
|
+
|
|
257
312
|
----
|
|
258
313
|
|
|
259
314
|
## What's next
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Story } from '@prezly/sdk';
|
|
2
|
+
import type { GetStaticPropsContext } from 'next';
|
|
3
|
+
interface Options {
|
|
4
|
+
loadHomepageContacts?: boolean;
|
|
5
|
+
story?: Story;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Use this function in your `getNewsroomStaticProps` page methods to retrieve the data necessary for the NewsroomContextProvider and `processRequest` function.
|
|
9
|
+
* See README for usage examples.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getNewsroomStaticProps(context: GetStaticPropsContext, options?: Options): Promise<{
|
|
12
|
+
api: import("../data-fetching/api/PrezlyApi").PrezlyApi;
|
|
13
|
+
staticProps: import("..").PageProps & import("..").ServerSidePageProps;
|
|
14
|
+
}>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getNewsroomStaticProps = void 0;
|
|
40
|
+
var data_fetching_1 = require("../data-fetching");
|
|
41
|
+
/**
|
|
42
|
+
* Use this function in your `getNewsroomStaticProps` page methods to retrieve the data necessary for the NewsroomContextProvider and `processRequest` function.
|
|
43
|
+
* See README for usage examples.
|
|
44
|
+
*/
|
|
45
|
+
function getNewsroomStaticProps(context, options) {
|
|
46
|
+
if (options === void 0) { options = {}; }
|
|
47
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
+
var locale, api, staticProps, _a;
|
|
49
|
+
return __generator(this, function (_b) {
|
|
50
|
+
switch (_b.label) {
|
|
51
|
+
case 0:
|
|
52
|
+
locale = context.locale;
|
|
53
|
+
api = (0, data_fetching_1.getPrezlyApi)();
|
|
54
|
+
return [4 /*yield*/, api.getNewsroomServerSideProps(undefined, locale, options.story)];
|
|
55
|
+
case 1:
|
|
56
|
+
staticProps = _b.sent();
|
|
57
|
+
if (!options.loadHomepageContacts) return [3 /*break*/, 3];
|
|
58
|
+
_a = staticProps.newsroomContextProps;
|
|
59
|
+
return [4 /*yield*/, api.getNewsroomContacts()];
|
|
60
|
+
case 2:
|
|
61
|
+
_a.contacts = _b.sent();
|
|
62
|
+
_b.label = 3;
|
|
63
|
+
case 3: return [2 /*return*/, { api: api, staticProps: staticProps }];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
exports.getNewsroomStaticProps = getNewsroomStaticProps;
|
|
69
|
+
//# sourceMappingURL=getNewsroomStaticProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getNewsroomStaticProps.js","sourceRoot":"","sources":["../../src/adapter-nextjs/getNewsroomStaticProps.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,kDAAgD;AAOhD;;;GAGG;AACH,SAAsB,sBAAsB,CACxC,OAA8B,EAC9B,OAAqB;IAArB,wBAAA,EAAA,YAAqB;;;;;;oBAEb,MAAM,GAAK,OAAO,OAAZ,CAAa;oBAErB,GAAG,GAAG,IAAA,4BAAY,GAAE,CAAC;oBACP,qBAAM,GAAG,CAAC,0BAA0B,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,EAAA;;oBAApF,WAAW,GAAG,SAAsE;yBAEtF,OAAO,CAAC,oBAAoB,EAA5B,wBAA4B;oBAC5B,KAAA,WAAW,CAAC,oBAAoB,CAAA;oBAAY,qBAAM,GAAG,CAAC,mBAAmB,EAAE,EAAA;;oBAA3E,GAAiC,QAAQ,GAAG,SAA+B,CAAC;;wBAGhF,sBAAO,EAAE,GAAG,KAAA,EAAE,WAAW,aAAA,EAAE,EAAC;;;;CAC/B;AAdD,wDAcC"}
|
|
@@ -16,6 +16,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./api-handlers"), exports);
|
|
18
18
|
__exportStar(require("./getNewsroomServerSideProps"), exports);
|
|
19
|
+
__exportStar(require("./getNewsroomStaticProps"), exports);
|
|
19
20
|
__exportStar(require("./page-props"), exports);
|
|
20
21
|
__exportStar(require("./processRequest"), exports);
|
|
22
|
+
__exportStar(require("./processStaticRequest"), exports);
|
|
21
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapter-nextjs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,+DAA6C;AAC7C,+CAA6B;AAC7B,mDAAiC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapter-nextjs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,+DAA6C;AAC7C,2DAAyC;AACzC,+CAA6B;AAC7B,mDAAiC;AACjC,yDAAuC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExtraStoryFields, Story } from '@prezly/sdk';
|
|
2
|
-
import type { GetServerSidePropsContext, GetServerSidePropsResult } from 'next';
|
|
2
|
+
import type { GetServerSidePropsContext, GetServerSidePropsResult, GetStaticPathsResult, GetStaticPropsContext, GetStaticPropsResult } from 'next';
|
|
3
3
|
import type { PaginationProps } from '../../infinite-loading/types';
|
|
4
4
|
import type { PropsFunction } from './lib/types';
|
|
5
5
|
export interface CategoryPageProps<StoryType extends Story = Story> {
|
|
@@ -11,4 +11,6 @@ interface Options {
|
|
|
11
11
|
pageSize?: number;
|
|
12
12
|
}
|
|
13
13
|
export declare function getCategoryPageServerSideProps<CustomProps extends Record<string, any>, StoryType extends Story = Story>(customProps: CustomProps | PropsFunction<CustomProps>, options?: Options): (context: GetServerSidePropsContext) => Promise<GetServerSidePropsResult<CategoryPageProps<StoryType> & CustomProps>>;
|
|
14
|
+
export declare function getCategoryPageStaticProps<CustomProps extends Record<string, any>, StoryType extends Story = Story>(customProps: CustomProps | PropsFunction<CustomProps>, options?: Options): (context: GetStaticPropsContext) => Promise<GetStaticPropsResult<CategoryPageProps<StoryType> & CustomProps>>;
|
|
15
|
+
export declare function getCategoryPageStaticPaths(): Promise<GetStaticPathsResult>;
|
|
14
16
|
export {};
|
|
@@ -46,11 +46,31 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
50
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
51
|
+
if (!m) return o;
|
|
52
|
+
var i = m.call(o), r, ar = [], e;
|
|
53
|
+
try {
|
|
54
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
55
|
+
}
|
|
56
|
+
catch (error) { e = { error: error }; }
|
|
57
|
+
finally {
|
|
58
|
+
try {
|
|
59
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
60
|
+
}
|
|
61
|
+
finally { if (e) throw e.error; }
|
|
62
|
+
}
|
|
63
|
+
return ar;
|
|
64
|
+
};
|
|
49
65
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.getCategoryPageServerSideProps = void 0;
|
|
66
|
+
exports.getCategoryPageStaticPaths = exports.getCategoryPageStaticProps = exports.getCategoryPageServerSideProps = void 0;
|
|
67
|
+
var data_fetching_1 = require("../../data-fetching");
|
|
68
|
+
var intl_1 = require("../../intl");
|
|
51
69
|
var utils_1 = require("../../utils");
|
|
52
70
|
var getNewsroomServerSideProps_1 = require("../getNewsroomServerSideProps");
|
|
71
|
+
var getNewsroomStaticProps_1 = require("../getNewsroomStaticProps");
|
|
53
72
|
var processRequest_1 = require("../processRequest");
|
|
73
|
+
var processStaticRequest_1 = require("../processStaticRequest");
|
|
54
74
|
function getCategoryPageServerSideProps(customProps, options) {
|
|
55
75
|
var _a = options || {}, _b = _a.pageSize, pageSize = _b === void 0 ? utils_1.DEFAULT_PAGE_SIZE : _b, extraStoryFields = _a.extraStoryFields;
|
|
56
76
|
return function getServerSideProps(context) {
|
|
@@ -105,4 +125,87 @@ function getCategoryPageServerSideProps(customProps, options) {
|
|
|
105
125
|
};
|
|
106
126
|
}
|
|
107
127
|
exports.getCategoryPageServerSideProps = getCategoryPageServerSideProps;
|
|
128
|
+
function getCategoryPageStaticProps(customProps, options) {
|
|
129
|
+
var _a = options || {}, _b = _a.pageSize, pageSize = _b === void 0 ? utils_1.DEFAULT_PAGE_SIZE : _b, extraStoryFields = _a.extraStoryFields;
|
|
130
|
+
return function getStaticProps(context) {
|
|
131
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
132
|
+
var _a, api, staticProps, slug, category, localeCode, _b, stories, storiesTotal, _c, _d, _e, _f;
|
|
133
|
+
return __generator(this, function (_g) {
|
|
134
|
+
switch (_g.label) {
|
|
135
|
+
case 0: return [4 /*yield*/, (0, getNewsroomStaticProps_1.getNewsroomStaticProps)(context)];
|
|
136
|
+
case 1:
|
|
137
|
+
_a = _g.sent(), api = _a.api, staticProps = _a.staticProps;
|
|
138
|
+
slug = context.params.slug;
|
|
139
|
+
return [4 /*yield*/, api.getCategoryBySlug(slug)];
|
|
140
|
+
case 2:
|
|
141
|
+
category = _g.sent();
|
|
142
|
+
if (!category) {
|
|
143
|
+
return [2 /*return*/, {
|
|
144
|
+
notFound: true,
|
|
145
|
+
}];
|
|
146
|
+
}
|
|
147
|
+
localeCode = staticProps.newsroomContextProps.localeCode;
|
|
148
|
+
return [4 /*yield*/, api.getStoriesFromCategory(category, {
|
|
149
|
+
pageSize: pageSize,
|
|
150
|
+
include: extraStoryFields,
|
|
151
|
+
localeCode: localeCode,
|
|
152
|
+
})];
|
|
153
|
+
case 3:
|
|
154
|
+
_b = _g.sent(), stories = _b.stories, storiesTotal = _b.storiesTotal;
|
|
155
|
+
_c = processStaticRequest_1.processStaticRequest;
|
|
156
|
+
_d = [context];
|
|
157
|
+
_e = [__assign(__assign({}, staticProps), { newsroomContextProps: __assign(__assign({}, staticProps.newsroomContextProps), { currentCategory: category }),
|
|
158
|
+
// TODO: This is temporary until return types from API are figured out
|
|
159
|
+
stories: stories, pagination: {
|
|
160
|
+
itemsTotal: storiesTotal,
|
|
161
|
+
currentPage: 1,
|
|
162
|
+
pageSize: pageSize,
|
|
163
|
+
} })];
|
|
164
|
+
if (!(typeof customProps === 'function')) return [3 /*break*/, 5];
|
|
165
|
+
return [4 /*yield*/, customProps(context, staticProps)];
|
|
166
|
+
case 4:
|
|
167
|
+
_f = _g.sent();
|
|
168
|
+
return [3 /*break*/, 6];
|
|
169
|
+
case 5:
|
|
170
|
+
_f = customProps;
|
|
171
|
+
_g.label = 6;
|
|
172
|
+
case 6: return [2 /*return*/, _c.apply(void 0, _d.concat([__assign.apply(void 0, _e.concat([(_f)]))]))];
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
exports.getCategoryPageStaticProps = getCategoryPageStaticProps;
|
|
179
|
+
function getCategoryPageStaticPaths() {
|
|
180
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
181
|
+
var api, _a, categories, defaultLanguage, locale, paths;
|
|
182
|
+
return __generator(this, function (_b) {
|
|
183
|
+
switch (_b.label) {
|
|
184
|
+
case 0:
|
|
185
|
+
api = (0, data_fetching_1.getPrezlyApi)();
|
|
186
|
+
return [4 /*yield*/, Promise.all([
|
|
187
|
+
api.getCategories(),
|
|
188
|
+
api.getNewsroomDefaultLanguage(),
|
|
189
|
+
])];
|
|
190
|
+
case 1:
|
|
191
|
+
_a = __read.apply(void 0, [_b.sent(), 2]), categories = _a[0], defaultLanguage = _a[1];
|
|
192
|
+
locale = intl_1.LocaleObject.fromAnyCode(defaultLanguage.code);
|
|
193
|
+
paths = categories
|
|
194
|
+
.map(function (category) {
|
|
195
|
+
var slug = (0, utils_1.getLocalizedCategoryData)(category, locale).slug;
|
|
196
|
+
if (!slug) {
|
|
197
|
+
return undefined;
|
|
198
|
+
}
|
|
199
|
+
return { params: { slug: slug } };
|
|
200
|
+
})
|
|
201
|
+
.filter(Boolean);
|
|
202
|
+
return [2 /*return*/, {
|
|
203
|
+
paths: paths,
|
|
204
|
+
fallback: 'blocking',
|
|
205
|
+
}];
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
exports.getCategoryPageStaticPaths = getCategoryPageStaticPaths;
|
|
108
211
|
//# sourceMappingURL=category.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"category.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/category.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"category.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/category.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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+B,OAAc,CAAC,CAAC;oBAE1D,sBAAO;4BACH,KAAK,OAAA;4BACL,QAAQ,EAAE,UAAU;yBACvB,EAAC;;;;CACL;AAvBD,gEAuBC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NewsroomGallery } from '@prezly/sdk';
|
|
2
|
-
import type { GetServerSidePropsContext, GetServerSidePropsResult } from 'next';
|
|
2
|
+
import type { GetServerSidePropsContext, GetServerSidePropsResult, GetStaticPropsContext, GetStaticPropsResult } from 'next';
|
|
3
3
|
import type { PaginationProps } from '../../infinite-loading/types';
|
|
4
4
|
import type { PropsFunction } from './lib/types';
|
|
5
5
|
export interface GalleryPageProps {
|
|
@@ -10,4 +10,5 @@ interface Options {
|
|
|
10
10
|
pageSize?: number;
|
|
11
11
|
}
|
|
12
12
|
export declare function getGalleryPageServerSideProps<CustomProps extends Record<string, any>>(customProps: CustomProps | PropsFunction<CustomProps>, options?: Options): (context: GetServerSidePropsContext) => Promise<GetServerSidePropsResult<GalleryPageProps & CustomProps>>;
|
|
13
|
+
export declare function getGalleryPageStaticProps<CustomProps extends Record<string, any>>(customProps: CustomProps | PropsFunction<CustomProps>, options?: Options): (context: GetStaticPropsContext) => Promise<GetStaticPropsResult<GalleryPageProps & CustomProps>>;
|
|
13
14
|
export {};
|
|
@@ -47,10 +47,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.getGalleryPageServerSideProps = void 0;
|
|
50
|
+
exports.getGalleryPageStaticProps = exports.getGalleryPageServerSideProps = void 0;
|
|
51
51
|
var utils_1 = require("../../utils");
|
|
52
52
|
var getNewsroomServerSideProps_1 = require("../getNewsroomServerSideProps");
|
|
53
|
+
var getNewsroomStaticProps_1 = require("../getNewsroomStaticProps");
|
|
53
54
|
var processRequest_1 = require("../processRequest");
|
|
55
|
+
var processStaticRequest_1 = require("../processStaticRequest");
|
|
54
56
|
function getGalleryPageServerSideProps(customProps, options) {
|
|
55
57
|
var _a = (options || {}).pageSize, pageSize = _a === void 0 ? utils_1.DEFAULT_GALLERY_PAGE_SIZE : _a;
|
|
56
58
|
return function getServerSideProps(context) {
|
|
@@ -98,4 +100,49 @@ function getGalleryPageServerSideProps(customProps, options) {
|
|
|
98
100
|
};
|
|
99
101
|
}
|
|
100
102
|
exports.getGalleryPageServerSideProps = getGalleryPageServerSideProps;
|
|
103
|
+
function getGalleryPageStaticProps(customProps, options) {
|
|
104
|
+
var _a = (options || {}).pageSize, pageSize = _a === void 0 ? utils_1.DEFAULT_GALLERY_PAGE_SIZE : _a;
|
|
105
|
+
return function getStaticProps(context) {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
107
|
+
var _a, api, staticProps, _b, galleries, pagination, uuid, _c, _d, _e, _f;
|
|
108
|
+
return __generator(this, function (_g) {
|
|
109
|
+
switch (_g.label) {
|
|
110
|
+
case 0: return [4 /*yield*/, (0, getNewsroomStaticProps_1.getNewsroomStaticProps)(context)];
|
|
111
|
+
case 1:
|
|
112
|
+
_a = _g.sent(), api = _a.api, staticProps = _a.staticProps;
|
|
113
|
+
return [4 /*yield*/, api.getGalleries({ pageSize: pageSize })];
|
|
114
|
+
case 2:
|
|
115
|
+
_b = _g.sent(), galleries = _b.galleries, pagination = _b.pagination;
|
|
116
|
+
// If there's only one gallery, redirect to it immediately
|
|
117
|
+
if (galleries.length === 1) {
|
|
118
|
+
uuid = galleries[0].uuid;
|
|
119
|
+
return [2 /*return*/, {
|
|
120
|
+
redirect: {
|
|
121
|
+
destination: "/media/album/".concat(uuid),
|
|
122
|
+
permanent: false,
|
|
123
|
+
},
|
|
124
|
+
}];
|
|
125
|
+
}
|
|
126
|
+
_c = processStaticRequest_1.processStaticRequest;
|
|
127
|
+
_d = [context];
|
|
128
|
+
_e = [__assign(__assign({}, staticProps), { galleries: galleries, pagination: {
|
|
129
|
+
itemsTotal: pagination.matched_records_number,
|
|
130
|
+
currentPage: 1,
|
|
131
|
+
pageSize: pageSize,
|
|
132
|
+
} })];
|
|
133
|
+
if (!(typeof customProps === 'function')) return [3 /*break*/, 4];
|
|
134
|
+
return [4 /*yield*/, customProps(context, staticProps)];
|
|
135
|
+
case 3:
|
|
136
|
+
_f = _g.sent();
|
|
137
|
+
return [3 /*break*/, 5];
|
|
138
|
+
case 4:
|
|
139
|
+
_f = customProps;
|
|
140
|
+
_g.label = 5;
|
|
141
|
+
case 5: return [2 /*return*/, _c.apply(void 0, _d.concat([__assign.apply(void 0, _e.concat([(_f)]))]))];
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
exports.getGalleryPageStaticProps = getGalleryPageStaticProps;
|
|
101
148
|
//# sourceMappingURL=gallery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gallery.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/gallery.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"gallery.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/gallery.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,qCAAwD;AACxD,4EAA2E;AAC3E,oEAAmE;AACnE,oDAAmD;AACnD,gEAA+D;AAa/D,SAAgB,6BAA6B,CACzC,WAAqD,EACrD,OAAiB;IAET,IAAA,KAAyC,CAAA,OAAO,IAAI,EAAE,CAAA,SAAlB,EAApC,QAAQ,mBAAG,iCAAyB,KAAA,CAAmB;IAE/D,OAAO,SAAe,kBAAkB,CACpC,OAAkC;;;;;4BAED,qBAAM,IAAA,uDAA0B,EAAC,OAAO,CAAC,EAAA;;wBAApE,KAA2B,SAAyC,EAAlE,GAAG,SAAA,EAAE,eAAe,qBAAA;wBACpB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AmB;IAE/D,OAAO,SAAe,cAAc,CAChC,OAA8B;;;;;4BAED,qBAAM,IAAA,+CAAsB,EAAC,OAAO,CAAC,EAAA;;wBAA5D,KAAuB,SAAqC,EAA1D,GAAG,SAAA,EAAE,WAAW,iBAAA;wBAEU,qBAAM,GAAG,CAAC,YAAY,CAAC,EAAE,QAAQ,UAAA,EAAE,CAAC,EAAA;;wBAAhE,KAA4B,SAAoC,EAA9D,SAAS,eAAA,EAAE,UAAU,gBAAA;wBAE7B,0DAA0D;wBAC1D,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;4BAChB,IAAI,GAAK,SAAS,CAAC,CAAC,CAAC,KAAjB,CAAkB;4BAE9B,sBAAO;oCACH,QAAQ,EAAE;wCACN,WAAW,EAAE,uBAAgB,IAAI,CAAE;wCACnC,SAAS,EAAE,KAAK;qCACnB;iCACJ,EAAC;yBACL;wBAEM,KAAA,2CAAoB,CAAA;8BAAC,OAAO;oDAC5B,WAAW,KACd,SAAS,WAAA,EACT,UAAU,EAAE;oCACR,UAAU,EAAE,UAAU,CAAC,sBAAsB;oCAC7C,WAAW,EAAE,CAAC;oCACd,QAAQ,UAAA;iCACX;6BACG,CAAA,OAAO,WAAW,KAAK,UAAU,CAAA,EAAjC,wBAAiC;wBAC/B,qBAAO,WAA0C,CAAC,OAAO,EAAE,WAAW,CAAC,EAAA;;wBAAvE,KAAA,SAAuE,CAAA;;;wBACvE,KAAA,WAAW,CAAA;;4BAVrB,sBAAO,8DAQA,IAEe,MACpB,EAAC;;;;KACN,CAAC;AACN,CAAC;AAtCD,8DAsCC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { NewsroomGallery } from '@prezly/sdk';
|
|
2
|
-
import type { GetServerSidePropsContext, GetServerSidePropsResult } from 'next';
|
|
2
|
+
import type { GetServerSidePropsContext, GetServerSidePropsResult, GetStaticPathsResult, GetStaticPropsContext, GetStaticPropsResult } from 'next';
|
|
3
3
|
import type { PropsFunction } from './lib/types';
|
|
4
4
|
export interface GalleryAlbumPageProps {
|
|
5
5
|
gallery: NewsroomGallery;
|
|
6
6
|
}
|
|
7
7
|
export declare function getGalleryAlbumPageServerSideProps<CustomProps extends Record<string, any>>(customProps: CustomProps | PropsFunction<CustomProps>): (context: GetServerSidePropsContext) => Promise<GetServerSidePropsResult<GalleryAlbumPageProps & CustomProps>>;
|
|
8
|
+
export declare function getGalleryAlbumPageStaticProps<CustomProps extends Record<string, any>>(customProps: CustomProps | PropsFunction<CustomProps>): (context: GetStaticPropsContext) => Promise<GetStaticPropsResult<GalleryAlbumPageProps & CustomProps>>;
|
|
9
|
+
export declare function getGalleryAlbumPageStaticPaths(): Promise<GetStaticPathsResult>;
|
|
@@ -47,9 +47,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.getGalleryAlbumPageServerSideProps = void 0;
|
|
50
|
+
exports.getGalleryAlbumPageStaticPaths = exports.getGalleryAlbumPageStaticProps = exports.getGalleryAlbumPageServerSideProps = void 0;
|
|
51
|
+
var data_fetching_1 = require("../../data-fetching");
|
|
51
52
|
var getNewsroomServerSideProps_1 = require("../getNewsroomServerSideProps");
|
|
53
|
+
var getNewsroomStaticProps_1 = require("../getNewsroomStaticProps");
|
|
52
54
|
var processRequest_1 = require("../processRequest");
|
|
55
|
+
var processStaticRequest_1 = require("../processStaticRequest");
|
|
53
56
|
function getGalleryAlbumPageServerSideProps(customProps) {
|
|
54
57
|
return function getServerSideProps(context) {
|
|
55
58
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -84,4 +87,61 @@ function getGalleryAlbumPageServerSideProps(customProps) {
|
|
|
84
87
|
};
|
|
85
88
|
}
|
|
86
89
|
exports.getGalleryAlbumPageServerSideProps = getGalleryAlbumPageServerSideProps;
|
|
90
|
+
function getGalleryAlbumPageStaticProps(customProps) {
|
|
91
|
+
return function getStaticProps(context) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
+
var _a, api, staticProps, uuid, gallery, _b, _c, _d, _e;
|
|
94
|
+
return __generator(this, function (_f) {
|
|
95
|
+
switch (_f.label) {
|
|
96
|
+
case 0: return [4 /*yield*/, (0, getNewsroomStaticProps_1.getNewsroomStaticProps)(context)];
|
|
97
|
+
case 1:
|
|
98
|
+
_a = _f.sent(), api = _a.api, staticProps = _a.staticProps;
|
|
99
|
+
uuid = context.params.uuid;
|
|
100
|
+
return [4 /*yield*/, api.getGallery(uuid)];
|
|
101
|
+
case 2:
|
|
102
|
+
gallery = _f.sent();
|
|
103
|
+
if (!gallery || !gallery.images_number) {
|
|
104
|
+
return [2 /*return*/, { notFound: true }];
|
|
105
|
+
}
|
|
106
|
+
_b = processStaticRequest_1.processStaticRequest;
|
|
107
|
+
_c = [context];
|
|
108
|
+
_d = [__assign(__assign({}, staticProps), { gallery: gallery })];
|
|
109
|
+
if (!(typeof customProps === 'function')) return [3 /*break*/, 4];
|
|
110
|
+
return [4 /*yield*/, customProps(context, staticProps)];
|
|
111
|
+
case 3:
|
|
112
|
+
_e = _f.sent();
|
|
113
|
+
return [3 /*break*/, 5];
|
|
114
|
+
case 4:
|
|
115
|
+
_e = customProps;
|
|
116
|
+
_f.label = 5;
|
|
117
|
+
case 5: return [2 /*return*/, _b.apply(void 0, _c.concat([__assign.apply(void 0, _d.concat([(_e)]))]))];
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
exports.getGalleryAlbumPageStaticProps = getGalleryAlbumPageStaticProps;
|
|
124
|
+
function getGalleryAlbumPageStaticPaths() {
|
|
125
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
126
|
+
var api, galleries, paths;
|
|
127
|
+
return __generator(this, function (_a) {
|
|
128
|
+
switch (_a.label) {
|
|
129
|
+
case 0:
|
|
130
|
+
api = (0, data_fetching_1.getPrezlyApi)();
|
|
131
|
+
return [4 /*yield*/, api.getGalleries({})];
|
|
132
|
+
case 1:
|
|
133
|
+
galleries = (_a.sent()).galleries;
|
|
134
|
+
paths = galleries.map(function (_a) {
|
|
135
|
+
var uuid = _a.uuid;
|
|
136
|
+
return ({ params: { uuid: uuid } });
|
|
137
|
+
});
|
|
138
|
+
return [2 /*return*/, {
|
|
139
|
+
paths: paths,
|
|
140
|
+
fallback: 'blocking',
|
|
141
|
+
}];
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
exports.getGalleryAlbumPageStaticPaths = getGalleryAlbumPageStaticPaths;
|
|
87
147
|
//# sourceMappingURL=galleryAlbum.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"galleryAlbum.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/galleryAlbum.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"galleryAlbum.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/galleryAlbum.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,qDAAmD;AACnD,4EAA2E;AAC3E,oEAAmE;AACnE,oDAAmD;AACnD,gEAA+D;AAQ/D,SAAgB,kCAAkC,CAC9C,WAAqD;IAErD,OAAO,SAAe,kBAAkB,CACpC,OAAkC;;;;;4BAED,qBAAM,IAAA,uDAA0B,EAAC,OAAO,CAAC,EAAA;;wBAApE,KAA2B,SAAyC,EAAlE,GAAG,SAAA,EAAE,eAAe,qBAAA;wBAEpB,IAAI,GAAK,OAAO,CAAC,MAA0B,KAAvC,CAAwC;wBACpC,qBAAM,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAA;;wBAApC,OAAO,GAAG,SAA0B;wBAE1C,IAAI,CAAC,OAAO,IAAI,CAAC,OAA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A8B;;;;;;oBAC1C,GAAG,GAAG,IAAA,4BAAY,GAAE,CAAC;oBACL,qBAAM,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,EAAA;;oBAAxC,SAAS,GAAK,CAAA,SAA0B,CAAA,UAA/B;oBAEX,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,UAAC,EAAQ;4BAAN,IAAI,UAAA;wBAAO,OAAA,CAAC,EAAE,MAAM,EAAE,EAAE,IAAI,MAAA,EAAE,EAAE,CAAC;oBAAtB,CAAsB,CAAC,CAAC;oBAElE,sBAAO;4BACH,KAAK,OAAA;4BACL,QAAQ,EAAE,UAAU;yBACvB,EAAC;;;;CACL;AAVD,wEAUC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExtraStoryFields, Story } from '@prezly/sdk';
|
|
2
|
-
import type { GetServerSidePropsContext, GetServerSidePropsResult } from 'next';
|
|
2
|
+
import type { GetServerSidePropsContext, GetServerSidePropsResult, GetStaticPropsContext, GetStaticPropsResult } from 'next';
|
|
3
3
|
import type { PaginationProps } from '../../infinite-loading/types';
|
|
4
4
|
import type { PropsFunction } from './lib/types';
|
|
5
5
|
export interface HomePageProps<StoryType extends Story = Story> {
|
|
@@ -11,4 +11,5 @@ interface Options {
|
|
|
11
11
|
pageSize?: number;
|
|
12
12
|
}
|
|
13
13
|
export declare function getHomepageServerSideProps<CustomProps extends Record<string, any>, StoryType extends Story = Story>(customProps: CustomProps | PropsFunction<CustomProps>, options?: Options): (context: GetServerSidePropsContext) => Promise<GetServerSidePropsResult<HomePageProps<StoryType> & CustomProps>>;
|
|
14
|
+
export declare function getHomepageStaticProps<CustomProps extends Record<string, any>, StoryType extends Story = Story>(customProps: CustomProps | PropsFunction<CustomProps>, options?: Options): (context: GetStaticPropsContext) => Promise<GetStaticPropsResult<HomePageProps<StoryType> & CustomProps>>;
|
|
14
15
|
export {};
|
|
@@ -47,10 +47,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.getHomepageServerSideProps = void 0;
|
|
50
|
+
exports.getHomepageStaticProps = exports.getHomepageServerSideProps = void 0;
|
|
51
51
|
var utils_1 = require("../../utils");
|
|
52
52
|
var getNewsroomServerSideProps_1 = require("../getNewsroomServerSideProps");
|
|
53
|
+
var getNewsroomStaticProps_1 = require("../getNewsroomStaticProps");
|
|
53
54
|
var processRequest_1 = require("../processRequest");
|
|
55
|
+
var processStaticRequest_1 = require("../processStaticRequest");
|
|
54
56
|
function getHomepageServerSideProps(customProps, options) {
|
|
55
57
|
var _a = options || {}, _b = _a.pageSize, pageSize = _b === void 0 ? utils_1.DEFAULT_PAGE_SIZE : _b, extraStoryFields = _a.extraStoryFields;
|
|
56
58
|
return function getServerSideProps(context) {
|
|
@@ -99,4 +101,49 @@ function getHomepageServerSideProps(customProps, options) {
|
|
|
99
101
|
};
|
|
100
102
|
}
|
|
101
103
|
exports.getHomepageServerSideProps = getHomepageServerSideProps;
|
|
104
|
+
function getHomepageStaticProps(customProps, options) {
|
|
105
|
+
var _a = options || {}, _b = _a.pageSize, pageSize = _b === void 0 ? utils_1.DEFAULT_PAGE_SIZE : _b, extraStoryFields = _a.extraStoryFields;
|
|
106
|
+
return function getStaticProps(context) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
108
|
+
var _a, api, staticProps, localeCode, storiesPaginated, stories, storiesTotal, _b, _c, _d, _e;
|
|
109
|
+
return __generator(this, function (_f) {
|
|
110
|
+
switch (_f.label) {
|
|
111
|
+
case 0: return [4 /*yield*/, (0, getNewsroomStaticProps_1.getNewsroomStaticProps)(context, {
|
|
112
|
+
loadHomepageContacts: true,
|
|
113
|
+
})];
|
|
114
|
+
case 1:
|
|
115
|
+
_a = _f.sent(), api = _a.api, staticProps = _a.staticProps;
|
|
116
|
+
localeCode = staticProps.newsroomContextProps.localeCode;
|
|
117
|
+
return [4 /*yield*/, api.getStories({
|
|
118
|
+
pageSize: pageSize,
|
|
119
|
+
include: extraStoryFields,
|
|
120
|
+
localeCode: localeCode,
|
|
121
|
+
})];
|
|
122
|
+
case 2:
|
|
123
|
+
storiesPaginated = _f.sent();
|
|
124
|
+
stories = storiesPaginated.stories, storiesTotal = storiesPaginated.storiesTotal;
|
|
125
|
+
_b = processStaticRequest_1.processStaticRequest;
|
|
126
|
+
_c = [context];
|
|
127
|
+
_d = [__assign(__assign({}, staticProps), {
|
|
128
|
+
// TODO: This is temporary until return types from API are figured out
|
|
129
|
+
stories: stories, pagination: {
|
|
130
|
+
itemsTotal: storiesTotal,
|
|
131
|
+
currentPage: 1,
|
|
132
|
+
pageSize: pageSize,
|
|
133
|
+
} })];
|
|
134
|
+
if (!(typeof customProps === 'function')) return [3 /*break*/, 4];
|
|
135
|
+
return [4 /*yield*/, customProps(context, staticProps)];
|
|
136
|
+
case 3:
|
|
137
|
+
_e = _f.sent();
|
|
138
|
+
return [3 /*break*/, 5];
|
|
139
|
+
case 4:
|
|
140
|
+
_e = customProps;
|
|
141
|
+
_f.label = 5;
|
|
142
|
+
case 5: return [2 /*return*/, _b.apply(void 0, _c.concat([__assign.apply(void 0, _d.concat([(_e)]))]))];
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
exports.getHomepageStaticProps = getHomepageStaticProps;
|
|
102
149
|
//# sourceMappingURL=home.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"home.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/home.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"home.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/home.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA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B,sBAAO,8DASA,IAEe,MACpB,EAAC;;;;KACN,CAAC;AACN,CAAC;AApCD,wDAoCC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { getCategoryPageServerSideProps, type CategoryPageProps } from './category';
|
|
2
|
-
export { getGalleryPageServerSideProps, type GalleryPageProps } from './gallery';
|
|
3
|
-
export { getGalleryAlbumPageServerSideProps, type GalleryAlbumPageProps } from './galleryAlbum';
|
|
4
|
-
export { getHomepageServerSideProps, type HomePageProps } from './home';
|
|
5
|
-
export { getSearchPageServerSideProps } from './search';
|
|
1
|
+
export { getCategoryPageServerSideProps, getCategoryPageStaticPaths, getCategoryPageStaticProps, type CategoryPageProps, } from './category';
|
|
2
|
+
export { getGalleryPageServerSideProps, getGalleryPageStaticProps, type GalleryPageProps, } from './gallery';
|
|
3
|
+
export { getGalleryAlbumPageServerSideProps, getGalleryAlbumPageStaticPaths, getGalleryAlbumPageStaticProps, type GalleryAlbumPageProps, } from './galleryAlbum';
|
|
4
|
+
export { getHomepageServerSideProps, getHomepageStaticProps, type HomePageProps } from './home';
|
|
5
|
+
export { getSearchPageServerSideProps, getSearchPageStaticProps } from './search';
|
|
6
6
|
export * from './sitemap';
|
|
7
|
-
export { getStoryPageServerSideProps } from './story';
|
|
7
|
+
export { getStoryPageServerSideProps, getStoryPageStaticPaths, getStoryPageStaticProps, } from './story';
|
|
8
8
|
export { getStoryPreviewPageServerSideProps } from './storyPreview';
|