@prezly/theme-kit-nextjs 5.0.0-alpha.7 → 5.0.0-alpha.9
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 +8 -7
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/infinite-loading/useInfiniteLoading.js +2 -2
- package/build/infinite-loading/useInfiniteLoading.js.map +1 -1
- package/build/server.d.ts +0 -1
- package/build/server.js +0 -1
- package/build/server.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -73,7 +73,7 @@ If you want to support multi-language in your theme, you'll need to make additio
|
|
|
73
73
|
|
|
74
74
|
```js
|
|
75
75
|
const { DUMMY_DEFAULT_LOCALE } = require('@prezly/theme-kit-nextjs');
|
|
76
|
-
const locales = require('@prezly/theme-kit-nextjs/
|
|
76
|
+
const locales = require('@prezly/theme-kit-nextjs/localeConfig');
|
|
77
77
|
|
|
78
78
|
module.exports = {
|
|
79
79
|
/* ...your next config... */
|
|
@@ -128,9 +128,10 @@ export default App;
|
|
|
128
128
|
### Page files (Server-side rendering)
|
|
129
129
|
|
|
130
130
|
Every page requires a bit of boilerplate code to set up.
|
|
131
|
+
Note that server-side code should be imported from `@prezly/theme-kit-nextjs/server`. That prevents the server code and dependencies from leaking into the client bundle.
|
|
131
132
|
|
|
132
133
|
```tsx
|
|
133
|
-
import { getNewsroomServerSideProps, processRequest } from '@prezly/theme-kit-nextjs';
|
|
134
|
+
import { getNewsroomServerSideProps, processRequest } from '@prezly/theme-kit-nextjs/server';
|
|
134
135
|
import type { GetServerSideProps } from 'next';
|
|
135
136
|
import type { FunctionComponent } from 'react';
|
|
136
137
|
|
|
@@ -190,7 +191,7 @@ To reduce boilerplate for common scenarios, the library provides a collection of
|
|
|
190
191
|
|
|
191
192
|
Here's an example of `getServerSideProps` function with no custom props:
|
|
192
193
|
```ts
|
|
193
|
-
import { getHomepageServerSideProps } from '@prezly/theme-kit-nextjs';
|
|
194
|
+
import { getHomepageServerSideProps } from '@prezly/theme-kit-nextjs/server';
|
|
194
195
|
|
|
195
196
|
/* ...your page component */
|
|
196
197
|
|
|
@@ -238,7 +239,7 @@ This kit can also help you with building your Sitemap automatically. Here's what
|
|
|
238
239
|
1. Create a sitemap page file: `/pages/sitemap.xml.ts`
|
|
239
240
|
2. Use this code to display the default Sitemap built with your Newsroom stories:
|
|
240
241
|
```ts
|
|
241
|
-
import { getSitemapServerSideProps } from '@prezly/theme-kit-nextjs';
|
|
242
|
+
import { getSitemapServerSideProps } from '@prezly/theme-kit-nextjs/server';
|
|
242
243
|
import type { NextPage } from 'next';
|
|
243
244
|
|
|
244
245
|
const Sitemap: NextPage = () => null;
|
|
@@ -267,7 +268,7 @@ For self-hosted applications, we now provide an option to use SSG in your projec
|
|
|
267
268
|
|
|
268
269
|
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.
|
|
269
270
|
```tsx
|
|
270
|
-
import { getNewsroomStaticProps, processStaticRequest } from '@prezly/theme-kit-nextjs';
|
|
271
|
+
import { getNewsroomStaticProps, processStaticRequest } from '@prezly/theme-kit-nextjs/server';
|
|
271
272
|
import type { GetStaticProps } from 'next';
|
|
272
273
|
|
|
273
274
|
/* Your Page component code */
|
|
@@ -289,7 +290,7 @@ export const getStaticProps: GetServerSideProps<Props> = async (context) => {
|
|
|
289
290
|
|
|
290
291
|
We also have added all of the page helpers (except Story Preview) for SSG prop fetching. Here's an example for the Home page:
|
|
291
292
|
```ts
|
|
292
|
-
import { getHomepageStaticProps } from '@prezly/theme-kit-nextjs';
|
|
293
|
+
import { getHomepageStaticProps } from '@prezly/theme-kit-nextjs/server';
|
|
293
294
|
|
|
294
295
|
/* ...your page component */
|
|
295
296
|
|
|
@@ -299,7 +300,7 @@ export const getStaticProps = getHomepageStaticProps({});
|
|
|
299
300
|
|
|
300
301
|
For dynamic pages, like `/story/[slug]`, we also provide `getStaticPaths` helper functions:
|
|
301
302
|
```tsx
|
|
302
|
-
import { getStoryPageStaticPaths, getStoryPageStaticProps } from '@prezly/theme-kit-nextjs';
|
|
303
|
+
import { getStoryPageStaticPaths, getStoryPageStaticProps } from '@prezly/theme-kit-nextjs/server';
|
|
303
304
|
|
|
304
305
|
/* Your Page component code */
|
|
305
306
|
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -18,5 +18,6 @@ __exportStar(require("./components-nextjs"), exports);
|
|
|
18
18
|
__exportStar(require("./infinite-loading"), exports);
|
|
19
19
|
__exportStar(require("./intl"), exports);
|
|
20
20
|
__exportStar(require("./newsroom-context"), exports);
|
|
21
|
+
__exportStar(require("./sentry"), exports);
|
|
21
22
|
__exportStar(require("./types"), exports);
|
|
22
23
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,qDAAmC;AACnC,yCAAuB;AACvB,qDAAmC;AACnC,0CAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,qDAAmC;AACnC,yCAAuB;AACvB,qDAAmC;AACnC,2CAAyB;AACzB,0CAAwB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useInfiniteLoading = void 0;
|
|
4
|
-
const
|
|
4
|
+
const useAsync_1 = require("@react-hookz/web/esm/useAsync/useAsync");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
function useInfiniteLoading({ fetchingFn, initialData, pagination, }) {
|
|
7
7
|
const [data, setData] = (0, react_1.useState)(initialData);
|
|
@@ -10,7 +10,7 @@ function useInfiniteLoading({ fetchingFn, initialData, pagination, }) {
|
|
|
10
10
|
const adjustedItemsTotal = withHighlightedStory ? itemsTotal - 1 : itemsTotal;
|
|
11
11
|
const pagesTotal = Math.ceil(adjustedItemsTotal / pageSize);
|
|
12
12
|
const canLoadMore = currentPage < pagesTotal;
|
|
13
|
-
const [{ error, status }, { execute: loadMoreFn }] = (0,
|
|
13
|
+
const [{ error, status }, { execute: loadMoreFn }] = (0, useAsync_1.useAsync)(async () => {
|
|
14
14
|
const nextPage = currentPage + 1;
|
|
15
15
|
const newData = await fetchingFn(nextPage, pageSize);
|
|
16
16
|
setCurrentPage(nextPage);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInfiniteLoading.js","sourceRoot":"","sources":["../../src/infinite-loading/useInfiniteLoading.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"useInfiniteLoading.js","sourceRoot":"","sources":["../../src/infinite-loading/useInfiniteLoading.ts"],"names":[],"mappings":";;;AAAA,qEAAkE;AAClE,iCAAyD;AAmBzD,SAAgB,kBAAkB,CAAI,EAClC,UAAU,EACV,WAAW,EACX,UAAU,GACE;IACZ,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAA,gBAAQ,EAAM,WAAW,CAAC,CAAC;IACnD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,IAAA,gBAAQ,EAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAEvE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,oBAAoB,EAAE,GAAG,UAAU,CAAC;IAClE,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;IAC9E,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,GAAG,QAAQ,CAAC,CAAC;IAC5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,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./adapter-nextjs"), exports);
|
|
18
18
|
__exportStar(require("./data-fetching"), exports);
|
|
19
|
-
__exportStar(require("./sentry"), exports);
|
|
20
19
|
//# sourceMappingURL=server.js.map
|
package/build/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,kDAAgC
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,kDAAgC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prezly/theme-kit-nextjs",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.9",
|
|
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",
|
|
@@ -62,12 +62,12 @@
|
|
|
62
62
|
"next-seo": "^5.4.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@prezly/theme-kit-core": "^5.0.0-alpha.
|
|
66
|
-
"@sentry/nextjs": "7.
|
|
65
|
+
"@prezly/theme-kit-core": "^5.0.0-alpha.9",
|
|
66
|
+
"@sentry/nextjs": "7.50.0"
|
|
67
67
|
},
|
|
68
68
|
"publishConfig": {
|
|
69
69
|
"access": "public"
|
|
70
70
|
},
|
|
71
71
|
"sideEffects": false,
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "b01704b7dfac5d5f67c6afbe2477fa0b46fa165c"
|
|
73
73
|
}
|