@prezly/theme-kit-nextjs 5.0.0-alpha.0 → 5.0.0-alpha.10
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/adapter-nextjs/api-handlers/fetchGalleries.js +2 -0
- package/build/adapter-nextjs/api-handlers/fetchGalleries.js.map +1 -1
- package/build/adapter-nextjs/api-handlers/fetchStories.js +2 -0
- package/build/adapter-nextjs/api-handlers/fetchStories.js.map +1 -1
- package/build/adapter-nextjs/getNewsroomServerSideProps.d.ts +1 -1
- package/build/adapter-nextjs/getNewsroomServerSideProps.js +2 -0
- package/build/adapter-nextjs/getNewsroomServerSideProps.js.map +1 -1
- package/build/adapter-nextjs/getNewsroomStaticProps.d.ts +1 -1
- package/build/adapter-nextjs/getNewsroomStaticProps.js +2 -0
- package/build/adapter-nextjs/getNewsroomStaticProps.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/createPaths.d.ts +1 -1
- package/build/adapter-nextjs/page-props/sitemap/createPaths.js.map +1 -1
- package/build/adapter-nextjs/processRequest.js +1 -0
- package/build/adapter-nextjs/processRequest.js.map +1 -1
- package/build/adapter-nextjs/processStaticRequest.js +2 -0
- package/build/adapter-nextjs/processStaticRequest.js.map +1 -1
- package/build/components-nextjs/StorySeo/StorySeo.d.ts +1 -1
- package/build/components-nextjs/StorySeo/StorySeo.js +2 -2
- package/build/components-nextjs/StorySeo/StorySeo.js.map +1 -1
- package/build/data-fetching/NextPrezlyApi.d.ts +2 -2
- package/build/data-fetching/NextPrezlyApi.js +3 -3
- package/build/data-fetching/NextPrezlyApi.js.map +1 -1
- package/build/data-fetching/getNextPrezlyApi.js +3 -4
- package/build/data-fetching/getNextPrezlyApi.js.map +1 -1
- package/build/index.d.ts +0 -2
- package/build/index.js +0 -2
- 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/intl/languages.d.ts +1 -1
- package/build/intl/languages.js.map +1 -1
- package/build/newsroom-context/context.d.ts +1 -1
- package/build/newsroom-context/context.js.map +1 -1
- package/build/newsroom-context/hooks/useAlgoliaSettings.d.ts +1 -1
- package/build/newsroom-context/hooks/useGetTranslationUrl.js +9 -19
- package/build/newsroom-context/hooks/useGetTranslationUrl.js.map +1 -1
- package/build/server.d.ts +2 -0
- package/build/server.js +19 -0
- package/build/server.js.map +1 -0
- package/package.json +17 -6
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
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fetchGalleries = void 0;
|
|
4
|
+
const theme_kit_core_1 = require("@prezly/theme-kit-core");
|
|
4
5
|
const data_fetching_1 = require("../../data-fetching");
|
|
5
6
|
async function fetchGalleries(req, res) {
|
|
7
|
+
(0, theme_kit_core_1.assertServerEnv)('fetchGalleries');
|
|
6
8
|
if (req.method !== 'POST') {
|
|
7
9
|
res.status(405);
|
|
8
10
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchGalleries.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/api-handlers/fetchGalleries.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"fetchGalleries.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/api-handlers/fetchGalleries.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;AAGzD,uDAAuD;AAEhD,KAAK,UAAU,cAAc,CAAC,GAAmB,EAAE,GAAoB;IAC1E,IAAA,gCAAe,EAAC,gBAAgB,CAAC,CAAC;IAElC,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,EAAE;QACvB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChB,OAAO;KACV;IAED,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC;IAEpC,IAAI;QACA,MAAM,GAAG,GAAG,IAAA,gCAAgB,EAAC,GAAG,CAAC,CAAC;QAElC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,GAAG,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;QAEjE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;KACvC;IAAC,OAAO,KAAK,EAAE;QACZ,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACjB,OAAO,EAAG,KAAe,CAAC,OAAO;SACpC,CAAC,CAAC;KACN;AACL,CAAC;AArBD,wCAqBC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fetchStories = void 0;
|
|
4
|
+
const theme_kit_core_1 = require("@prezly/theme-kit-core");
|
|
4
5
|
const data_fetching_1 = require("../../data-fetching");
|
|
5
6
|
async function fetchStories(req, res) {
|
|
7
|
+
(0, theme_kit_core_1.assertServerEnv)('fetchStories');
|
|
6
8
|
if (req.method !== 'POST') {
|
|
7
9
|
res.status(405);
|
|
8
10
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchStories.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/api-handlers/fetchStories.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"fetchStories.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/api-handlers/fetchStories.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;AAGzD,uDAAuD;AAEhD,KAAK,UAAU,YAAY,CAAC,GAAmB,EAAE,GAAoB;IACxE,IAAA,gCAAe,EAAC,cAAc,CAAC,CAAC;IAEhC,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,EAAE;QACvB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChB,OAAO;KACV;IAED,MAAM,EACF,IAAI,EACJ,QAAQ,EACR,oBAAoB,EACpB,QAAQ,EACR,OAAO,EACP,UAAU,EACV,OAAO,EACP,WAAW,GACd,GAAG,GAAG,CAAC,IAAI,CAAC;IAEb,IAAI;QACA,MAAM,GAAG,GAAG,IAAA,gCAAgB,EAAC,GAAG,CAAC,CAAC;QAElC,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,QAAQ;YAC/B,CAAC,CAAC,GAAG,CAAC,sBAAsB,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;YAC/E,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC;gBACX,IAAI;gBACJ,QAAQ;gBACR,OAAO;gBACP,UAAU;gBACV,oBAAoB;gBACpB,OAAO;gBACP,WAAW;aACd,CAAC,CAAC,CAAC;QAEV,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;KACrC;IAAC,OAAO,KAAK,EAAE;QACZ,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACjB,OAAO,EAAG,KAAe,CAAC,OAAO;SACpC,CAAC,CAAC;KACN;AACL,CAAC;AAxCD,oCAwCC"}
|
|
@@ -2,7 +2,7 @@ import type { Story } from '@prezly/sdk';
|
|
|
2
2
|
import type { GetServerSidePropsContext } from 'next';
|
|
3
3
|
interface Options {
|
|
4
4
|
loadHomepageContacts?: boolean;
|
|
5
|
-
story?: Story
|
|
5
|
+
story?: Pick<Story, 'culture'>;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Use this function in your `getServerSideProps` page methods to retrieve the data necessary for the NewsroomContextProvider and `processRequest` function.
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getNewsroomServerSideProps = void 0;
|
|
4
|
+
const theme_kit_core_1 = require("@prezly/theme-kit-core");
|
|
4
5
|
const data_fetching_1 = require("../data-fetching");
|
|
5
6
|
/**
|
|
6
7
|
* Use this function in your `getServerSideProps` page methods to retrieve the data necessary for the NewsroomContextProvider and `processRequest` function.
|
|
7
8
|
* See README for usage examples.
|
|
8
9
|
*/
|
|
9
10
|
async function getNewsroomServerSideProps(context, options = {}) {
|
|
11
|
+
(0, theme_kit_core_1.assertServerEnv)('getNewsroomServerSideProps');
|
|
10
12
|
const { req: request, locale } = context;
|
|
11
13
|
const api = (0, data_fetching_1.getNextPrezlyApi)(request);
|
|
12
14
|
const serverSideProps = await api.getNewsroomServerSideProps(request, locale, options.story);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNewsroomServerSideProps.js","sourceRoot":"","sources":["../../src/adapter-nextjs/getNewsroomServerSideProps.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"getNewsroomServerSideProps.js","sourceRoot":"","sources":["../../src/adapter-nextjs/getNewsroomServerSideProps.ts"],"names":[],"mappings":";;;AACA,2DAAyD;AAGzD,oDAAoD;AAOpD;;;GAGG;AACI,KAAK,UAAU,0BAA0B,CAC5C,OAAkC,EAClC,UAAmB,EAAE;IAErB,IAAA,gCAAe,EAAC,4BAA4B,CAAC,CAAC;IAC9C,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAEzC,MAAM,GAAG,GAAG,IAAA,gCAAgB,EAAC,OAAO,CAAC,CAAC;IACtC,MAAM,eAAe,GAAG,MAAM,GAAG,CAAC,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAE7F,IAAI,OAAO,CAAC,oBAAoB,EAAE;QAC9B,eAAe,CAAC,oBAAoB,CAAC,QAAQ,GAAG,MAAM,GAAG,CAAC,mBAAmB,EAAE,CAAC;KACnF;IAED,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,CAAC;AACpC,CAAC;AAfD,gEAeC"}
|
|
@@ -2,7 +2,7 @@ import type { Story } from '@prezly/sdk';
|
|
|
2
2
|
import type { GetStaticPropsContext } from 'next';
|
|
3
3
|
interface Options {
|
|
4
4
|
loadHomepageContacts?: boolean;
|
|
5
|
-
story?: Story
|
|
5
|
+
story?: Pick<Story, 'culture'>;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Use this function in your `getNewsroomStaticProps` page methods to retrieve the data necessary for the NewsroomContextProvider and `processRequest` function.
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getNewsroomStaticProps = void 0;
|
|
4
|
+
const theme_kit_core_1 = require("@prezly/theme-kit-core");
|
|
4
5
|
const data_fetching_1 = require("../data-fetching");
|
|
5
6
|
/**
|
|
6
7
|
* Use this function in your `getNewsroomStaticProps` page methods to retrieve the data necessary for the NewsroomContextProvider and `processRequest` function.
|
|
7
8
|
* See README for usage examples.
|
|
8
9
|
*/
|
|
9
10
|
async function getNewsroomStaticProps(context, options = {}) {
|
|
11
|
+
(0, theme_kit_core_1.assertServerEnv)('getNewsroomStaticProps');
|
|
10
12
|
const { locale } = context;
|
|
11
13
|
const api = (0, data_fetching_1.getNextPrezlyApi)();
|
|
12
14
|
const staticProps = await api.getNewsroomServerSideProps(undefined, locale, options.story);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNewsroomStaticProps.js","sourceRoot":"","sources":["../../src/adapter-nextjs/getNewsroomStaticProps.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"getNewsroomStaticProps.js","sourceRoot":"","sources":["../../src/adapter-nextjs/getNewsroomStaticProps.ts"],"names":[],"mappings":";;;AACA,2DAAyD;AAGzD,oDAAoD;AAOpD;;;GAGG;AACI,KAAK,UAAU,sBAAsB,CACxC,OAA8B,EAC9B,UAAmB,EAAE;IAErB,IAAA,gCAAe,EAAC,wBAAwB,CAAC,CAAC;IAC1C,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE3B,MAAM,GAAG,GAAG,IAAA,gCAAgB,GAAE,CAAC;IAC/B,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,0BAA0B,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAE3F,IAAI,OAAO,CAAC,oBAAoB,EAAE;QAC9B,WAAW,CAAC,oBAAoB,CAAC,QAAQ,GAAG,MAAM,GAAG,CAAC,mBAAmB,EAAE,CAAC;KAC/E;IAED,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC;AAChC,CAAC;AAfD,wDAeC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Category, Story } from '@prezly/sdk';
|
|
2
|
-
export declare function createPaths(stories: Story[], categories: Category[]): string[];
|
|
2
|
+
export declare function createPaths(stories: Pick<Story, 'slug'>[], categories: Pick<Category, 'i18n'>[]): string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPaths.js","sourceRoot":"","sources":["../../../../src/adapter-nextjs/page-props/sitemap/createPaths.ts"],"names":[],"mappings":";;;AAEA,SAAgB,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"createPaths.js","sourceRoot":"","sources":["../../../../src/adapter-nextjs/page-props/sitemap/createPaths.ts"],"names":[],"mappings":";;;AAEA,SAAgB,WAAW,CAAC,OAA8B,EAAE,UAAoC;IAC5F,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IAC1D,MAAM,cAAc,GAAG,UAAU;SAC5B,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;QACd,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAClD,MAAM,QAAQ,GAAG,YAAY;aACxB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC;aAC7B,MAAM,CAAC,OAAO,CAAC;aACf,MAAM,CACH,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,IAAI,CAAC,CAAC,EACvE,EAAE,CACL,CAAC;QAEN,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC,CAAC;SACD,IAAI,EAAE,CAAC;IAEZ,OAAO,CAAC,GAAG,WAAW,EAAE,GAAG,cAAc,CAAC,CAAC;AAC/C,CAAC;AAlBD,kCAkBC"}
|
|
@@ -13,6 +13,7 @@ const intl_1 = require("../intl");
|
|
|
13
13
|
* @param canonicalUrl Optional: a canonical URL for the current page without locale part. If provided, locale redirects will be handled by the function.
|
|
14
14
|
*/
|
|
15
15
|
function processRequest(context, props, canonicalUrl) {
|
|
16
|
+
(0, theme_kit_core_1.assertServerEnv)('processRequest');
|
|
16
17
|
const { locale: nextLocale, query } = context;
|
|
17
18
|
const { localeResolved, ...pageProps } = props;
|
|
18
19
|
// If no locale was provided by Next, it most likely means that the theme is not supporting multi-language.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processRequest.js","sourceRoot":"","sources":["../../src/adapter-nextjs/processRequest.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"processRequest.js","sourceRoot":"","sources":["../../src/adapter-nextjs/processRequest.ts"],"names":[],"mappings":";;;AAAA,2DAA8F;AAG9F,kCAAuD;AAGvD;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAC1B,OAAkC,EAClC,KAA8C,EAC9C,YAAqB;IAErB,IAAA,gCAAe,EAAC,gBAAgB,CAAC,CAAC;IAClC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAE9C,MAAM,EAAE,cAAc,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IAE/C,2GAA2G;IAC3G,uCAAuC;IACvC,IAAI,CAAC,cAAc,IAAI,UAAU,EAAE;QAC/B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;KAC7B;IAED,IAAI,YAAY,EAAE;QACd,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,SAAS,CAAC,oBAAoB,CAAC;QACjE,MAAM,aAAa,GAAG,6BAAY,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QAC3D,MAAM,kBAAkB,GAAG,IAAA,sCAAqB,EAAC,SAAS,EAAE,aAAa,CAAC,CAAC;QAE3E,MAAM,QAAQ,GAAG,IAAA,mCAA4B,EACzC,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,KAAK,CACR,CAAC;QACF,IAAI,QAAQ,EAAE;YACV,OAAO,EAAE,QAAQ,EAAE,CAAC;SACvB;KACJ;IAED,OAAO;QACH,KAAK,EAAE,SAA8B;KACxC,CAAC;AACN,CAAC;AAnCD,wCAmCC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.processStaticRequest = void 0;
|
|
4
|
+
const theme_kit_core_1 = require("@prezly/theme-kit-core");
|
|
4
5
|
/**
|
|
5
6
|
* This function combines the props returned from `getNewsroomStaticProps` and your optional custom props for the page.
|
|
6
7
|
* See README for usage examples.
|
|
@@ -10,6 +11,7 @@ exports.processStaticRequest = void 0;
|
|
|
10
11
|
* @param revalidateTimeout Optional: timeout in seconds to use with Next ISR.
|
|
11
12
|
*/
|
|
12
13
|
function processStaticRequest(context, props, revalidateTimeout) {
|
|
14
|
+
(0, theme_kit_core_1.assertServerEnv)('processStaticRequest');
|
|
13
15
|
const { locale: nextLocale } = context;
|
|
14
16
|
const { localeResolved, ...pageProps } = props;
|
|
15
17
|
// If no locale was provided by Next, it most likely means that the theme is not supporting multi-language.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processStaticRequest.js","sourceRoot":"","sources":["../../src/adapter-nextjs/processStaticRequest.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"processStaticRequest.js","sourceRoot":"","sources":["../../src/adapter-nextjs/processStaticRequest.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;AAKzD;;;;;;;GAOG;AACH,SAAgB,oBAAoB,CAChC,OAA8B,EAC9B,KAA8C,EAC9C,iBAA0B;IAE1B,IAAA,gCAAe,EAAC,sBAAsB,CAAC,CAAC;IACxC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAEvC,MAAM,EAAE,cAAc,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IAE/C,2GAA2G;IAC3G,uCAAuC;IACvC,IAAI,CAAC,cAAc,IAAI,UAAU,EAAE;QAC/B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;KAC7B;IAED,OAAO;QACH,KAAK,EAAE,SAA8B;QACrC,UAAU,EAAE,iBAAiB;KAChC,CAAC;AACN,CAAC;AApBD,oDAoBC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ExtendedStory } from '@prezly/sdk';
|
|
3
3
|
type Props = {
|
|
4
|
-
story: ExtendedStory
|
|
4
|
+
story: Pick<ExtendedStory, 'seo_settings' | 'title' | 'subtitle' | 'published_at' | 'updated_at' | 'author' | 'oembed' | 'newsroom' | 'summary' | 'visibility'>;
|
|
5
5
|
noindex?: boolean;
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StorySeo = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const
|
|
5
|
+
const theme_kit_core_1 = require("@prezly/theme-kit-core");
|
|
6
6
|
const next_seo_1 = require("next-seo");
|
|
7
7
|
/**
|
|
8
8
|
* This components provides additional page attributes for the Story page.
|
|
@@ -17,7 +17,7 @@ function StorySeo({ story, noindex }) {
|
|
|
17
17
|
subtitle ||
|
|
18
18
|
summary;
|
|
19
19
|
const canonical = story.seo_settings.canonical_url || oembed.url;
|
|
20
|
-
const indexable = newsroom.is_indexable && story.visibility ===
|
|
20
|
+
const indexable = newsroom.is_indexable && story.visibility === theme_kit_core_1.Visibility.PUBLIC;
|
|
21
21
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(next_seo_1.NextSeo, { title: seoTitle, description: seoDescription, canonical: canonical, noindex: noindex ?? !indexable, nofollow: noindex ?? !indexable, openGraph: {
|
|
22
22
|
title,
|
|
23
23
|
description: seoDescription,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorySeo.js","sourceRoot":"","sources":["../../../src/components-nextjs/StorySeo/StorySeo.tsx"],"names":[],"mappings":";;;;AACA,
|
|
1
|
+
{"version":3,"file":"StorySeo.js","sourceRoot":"","sources":["../../../src/components-nextjs/StorySeo/StorySeo.tsx"],"names":[],"mappings":";;;;AACA,2DAAoD;AACpD,uCAAkD;AAmBlD;;;GAGG;AACH,SAAgB,QAAQ,CAAC,EAAE,KAAK,EAAE,OAAO,EAAS;IAC9C,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAE/F,MAAM,UAAU,GAAG,MAAM,EAAE,YAAY,IAAI,MAAM,EAAE,KAAK,IAAI,SAAS,CAAC;IACtE,MAAM,QAAQ,GACV,KAAK,CAAC,YAAY,CAAC,UAAU,IAAI,KAAK,CAAC,YAAY,CAAC,kBAAkB,IAAI,KAAK,CAAC;IACpF,MAAM,cAAc,GAChB,KAAK,CAAC,YAAY,CAAC,gBAAgB;QACnC,KAAK,CAAC,YAAY,CAAC,wBAAwB;QAC3C,QAAQ;QACR,OAAO,CAAC;IACZ,MAAM,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,aAAa,IAAI,MAAM,CAAC,GAAG,CAAC;IACjE,MAAM,SAAS,GAAG,QAAQ,CAAC,YAAY,IAAI,KAAK,CAAC,UAAU,KAAK,2BAAU,CAAC,MAAM,CAAC;IAElF,OAAO,CACH,6DACI,uBAAC,kBAAO,IACJ,KAAK,EAAE,QAAQ,EACf,WAAW,EAAE,cAAc,EAC3B,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,IAAI,CAAC,SAAS,EAC9B,QAAQ,EAAE,OAAO,IAAI,CAAC,SAAS,EAC/B,SAAS,EAAE;oBACP,KAAK;oBACL,WAAW,EAAE,cAAc;oBAC3B,GAAG,EAAE,MAAM,CAAC,GAAG;oBACf,SAAS,EAAE,QAAQ,CAAC,YAAY;oBAChC,IAAI,EAAE,SAAS;oBACf,OAAO,EAAE;wBACL,aAAa,EAAE,YAAY,IAAI,SAAS;wBACxC,YAAY,EAAE,UAAU;wBACxB,OAAO,EAAE,CAAC,UAAU,CAAC;qBACxB;oBACD,GAAG,CAAC,MAAM,CAAC,aAAa,IAAI;wBACxB,MAAM,EAAE;4BACJ;gCACI,GAAG,EAAE,MAAM,CAAC,aAAa;gCACzB,GAAG,EAAE,MAAM,CAAC,KAAK;gCACjB,KAAK,EAAE,MAAM,CAAC,eAAe;gCAC7B,MAAM,EAAE,MAAM,CAAC,gBAAgB;6BAClC;yBACJ;qBACJ,CAAC;iBACL,EACD,kBAAkB,EACd,MAAM,CAAC,aAAa;oBAChB,CAAC,CAAC;wBACI,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,qBAAqB,EAAE;wBACxD,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,CAAC,aAAa,EAAE;qBAC3D;oBACH,CAAC,CAAC,SAAS,EAEnB,kBAAkB,EAAE;oBAChB;wBACI,GAAG,EAAE,WAAW;wBAChB,IAAI,EAAE,kBAAkB;wBACxB,IAAI,EAAE,GAAG,MAAM,CAAC,GAAG,OAAO;qBAC7B;iBACJ,GACH,EACF,uBAAC,wBAAa,IACV,GAAG,EAAE,MAAM,CAAC,GAAG,EACf,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,EAC1D,aAAa,EAAE,YAAY,IAAI,EAAE,EACjC,YAAY,EAAE,UAAU,EACxB,UAAU,EAAE,CAAC,UAAU,CAAC,EACxB,aAAa,EAAE,QAAQ,CAAC,YAAY,EACpC,aAAa,EAAE,QAAQ,CAAC,aAAa,EACrC,WAAW,EAAE,cAAc,GAC7B,IACH,CACN,CAAC;AACN,CAAC;AAzED,4BAyEC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { Story } from '@prezly/sdk';
|
|
3
|
-
import { PrezlyApi } from '@prezly/theme-kit-core';
|
|
3
|
+
import { PrezlyApi } from '@prezly/theme-kit-core/server';
|
|
4
4
|
import type { IncomingMessage } from 'http';
|
|
5
5
|
import type { PageProps, ServerSidePageProps } from '../types';
|
|
6
6
|
export declare class NextPrezlyApi extends PrezlyApi {
|
|
7
|
-
getNewsroomServerSideProps(request?: IncomingMessage, nextLocaleIsoCode?: string, story?: Story): Promise<PageProps & ServerSidePageProps>;
|
|
7
|
+
getNewsroomServerSideProps(request?: IncomingMessage, nextLocaleIsoCode?: string, story?: Pick<Story, 'culture'>): Promise<PageProps & ServerSidePageProps>;
|
|
8
8
|
}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NextPrezlyApi = void 0;
|
|
4
4
|
const theme_kit_core_1 = require("@prezly/theme-kit-core");
|
|
5
|
+
const server_1 = require("@prezly/theme-kit-core/server");
|
|
5
6
|
const intl_1 = require("../intl");
|
|
6
|
-
class NextPrezlyApi extends
|
|
7
|
+
class NextPrezlyApi extends server_1.PrezlyApi {
|
|
7
8
|
async getNewsroomServerSideProps(request, nextLocaleIsoCode, story) {
|
|
8
9
|
const [newsroom, languages, categories, themePreset] = await Promise.all([
|
|
9
10
|
this.getNewsroom(),
|
|
@@ -17,10 +18,9 @@ class NextPrezlyApi extends theme_kit_core_1.PrezlyApi {
|
|
|
17
18
|
const defaultLanguage = (0, theme_kit_core_1.getDefaultLanguage)(languages);
|
|
18
19
|
const { code: localeCode } = currentLanguage || defaultLanguage;
|
|
19
20
|
const locale = theme_kit_core_1.LocaleObject.fromAnyCode(localeCode);
|
|
20
|
-
// TODO: if no information given for current language, show boilerplate from default language
|
|
21
21
|
const companyInformation = (0, theme_kit_core_1.getCompanyInformation)(languages, locale);
|
|
22
22
|
const notifications = (0, theme_kit_core_1.getNotifications)(languages, locale);
|
|
23
|
-
const algoliaSettings = (0,
|
|
23
|
+
const algoliaSettings = (0, server_1.getAlgoliaSettings)(request);
|
|
24
24
|
return {
|
|
25
25
|
newsroomContextProps: {
|
|
26
26
|
newsroom,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NextPrezlyApi.js","sourceRoot":"","sources":["../../src/data-fetching/NextPrezlyApi.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"NextPrezlyApi.js","sourceRoot":"","sources":["../../src/data-fetching/NextPrezlyApi.ts"],"names":[],"mappings":";;;AACA,2DAMgC;AAChC,0DAA8E;AAG9E,kCAA2D;AAG3D,MAAa,aAAc,SAAQ,kBAAS;IACxC,KAAK,CAAC,0BAA0B,CAC5B,OAAyB,EACzB,iBAA0B,EAC1B,KAA8B;QAE9B,MAAM,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACrE,IAAI,CAAC,WAAW,EAAE;YAClB,IAAI,CAAC,oBAAoB,EAAE;YAC3B,IAAI,CAAC,aAAa,EAAE;YACpB,IAAI,CAAC,cAAc,EAAE;SACxB,CAAC,CAAC;QAEH,MAAM,eAAe,GAAG,KAAK;YACzB,CAAC,CAAC,IAAA,qCAAoB,EAAC,SAAS,EAAE,KAAK,CAAC;YACxC,CAAC,CAAC,IAAA,uCAAgC,EAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;QACrE,MAAM,eAAe,GAAG,IAAA,mCAAkB,EAAC,SAAS,CAAC,CAAC;QAEtD,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,eAAe,IAAI,eAAe,CAAC;QAChE,MAAM,MAAM,GAAG,6BAAY,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QAEpD,MAAM,kBAAkB,GAAG,IAAA,sCAAqB,EAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAEpE,MAAM,aAAa,GAAG,IAAA,iCAAgB,EAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAC1D,MAAM,eAAe,GAAG,IAAA,2BAAkB,EAAC,OAAO,CAAC,CAAC;QAEpD,OAAO;YACH,oBAAoB,EAAE;gBAClB,QAAQ;gBACR,kBAAkB;gBAClB,UAAU;gBACV,SAAS;gBACT,UAAU;gBACV,aAAa;gBACb,WAAW;gBACX,eAAe;aAClB;YACD,cAAc,EAAE,OAAO,CAAC,eAAe,CAAC;SAC3C,CAAC;IACN,CAAC;CACJ;AAxCD,sCAwCC"}
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getNextPrezlyApi = void 0;
|
|
4
4
|
const theme_kit_core_1 = require("@prezly/theme-kit-core");
|
|
5
|
+
const server_1 = require("@prezly/theme-kit-core/server");
|
|
5
6
|
const NextPrezlyApi_1 = require("./NextPrezlyApi");
|
|
6
7
|
function getNextPrezlyApi(req) {
|
|
7
|
-
|
|
8
|
-
throw new Error('"getNextPrezlyApi" should only be used on back-end side.');
|
|
9
|
-
}
|
|
8
|
+
(0, theme_kit_core_1.assertServerEnv)('getNextPrezlyApi');
|
|
10
9
|
// `getEnvVariables` handles both cases for envs parsing - .env and request headers
|
|
11
|
-
const { PREZLY_ACCESS_TOKEN, PREZLY_NEWSROOM_UUID, PREZLY_THEME_UUID } = (0,
|
|
10
|
+
const { PREZLY_ACCESS_TOKEN, PREZLY_NEWSROOM_UUID, PREZLY_THEME_UUID } = (0, server_1.getEnvVariables)(req);
|
|
12
11
|
if (!PREZLY_ACCESS_TOKEN) {
|
|
13
12
|
throw new Error('"PREZLY_ACCESS_TOKEN" is not set in env variables.');
|
|
14
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNextPrezlyApi.js","sourceRoot":"","sources":["../../src/data-fetching/getNextPrezlyApi.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;
|
|
1
|
+
{"version":3,"file":"getNextPrezlyApi.js","sourceRoot":"","sources":["../../src/data-fetching/getNextPrezlyApi.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;AACzD,0DAAgE;AAGhE,mDAAgD;AAEhD,SAAgB,gBAAgB,CAAC,GAAqB;IAClD,IAAA,gCAAe,EAAC,kBAAkB,CAAC,CAAC;IAEpC,mFAAmF;IACnF,MAAM,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,GAAG,IAAA,wBAAe,EAAC,GAAG,CAAC,CAAC;IAE9F,IAAI,CAAC,mBAAmB,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;KACzE;IAED,IAAI,CAAC,oBAAoB,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;KAC1E;IAED,OAAO,IAAI,6BAAa,CAAC,mBAAmB,EAAE,oBAAoB,EAAE,iBAAiB,CAAC,CAAC;AAC3F,CAAC;AAfD,4CAeC"}
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -14,9 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./adapter-nextjs"), exports);
|
|
18
17
|
__exportStar(require("./components-nextjs"), exports);
|
|
19
|
-
__exportStar(require("./data-fetching"), exports);
|
|
20
18
|
__exportStar(require("./infinite-loading"), exports);
|
|
21
19
|
__exportStar(require("./intl"), exports);
|
|
22
20
|
__exportStar(require("./newsroom-context"), exports);
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
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/cjs/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;IAC5D,MAAM,WAAW,GAAG,WAAW,GAAG,UAAU,CAAC;IAE7C,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,GAAG,IAAA,mBAAQ,EAAC,KAAK,IAAI,EAAE;QACrE,MAAM,QAAQ,GAAG,WAAW,GAAG,CAAC,CAAC;QACjC,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACrD,cAAc,CAAC,QAAQ,CAAC,CAAC;QACzB,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,GAAG,WAAW,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAC9B,IAAI,WAAW,EAAE;YACb,UAAU,EAAE,CAAC;SAChB;IACL,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;IAE9B,MAAM,SAAS,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAC/B,OAAO,CAAC,WAAW,CAAC,CAAC;QACrB,cAAc,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;IAE1C,IAAA,iBAAS,EAAC,GAAG,EAAE;QACX,IAAI,KAAK,EAAE;YACP,sCAAsC;YACtC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SACxB;IACL,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO;QACH,WAAW;QACX,WAAW;QACX,IAAI;QACJ,SAAS,EAAE,MAAM,KAAK,SAAS;QAC/B,QAAQ;QACR,SAAS;KACZ,CAAC;AACN,CAAC;AA9CD,gDA8CC"}
|
|
@@ -3,4 +3,4 @@ import type { NewsroomLanguageSettings } from '@prezly/sdk';
|
|
|
3
3
|
* Retrieve a culture with fallback to legacy codes support.
|
|
4
4
|
* Pulled from https://github.com/prezly/prezly/blob/de9900d9890a33502780494aa3fb85c9a732b3c3/lib/model/CulturePeer.php#L91-L114
|
|
5
5
|
*/
|
|
6
|
-
export declare function getLanguageFromNextLocaleIsoCode(languages:
|
|
6
|
+
export declare function getLanguageFromNextLocaleIsoCode<Language extends Pick<NewsroomLanguageSettings, 'is_default' | 'code' | 'public_stories_count'>>(languages: Language[], nextLocaleIsoCode?: string): Language | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"languages.js","sourceRoot":"","sources":["../../src/intl/languages.ts"],"names":[],"mappings":";;;AACA,2DAMgC;AAEhC,qCAAgD;AAEhD;;;GAGG;AACH,SAAgB,gCAAgC,
|
|
1
|
+
{"version":3,"file":"languages.js","sourceRoot":"","sources":["../../src/intl/languages.ts"],"names":[],"mappings":";;;AACA,2DAMgC;AAEhC,qCAAgD;AAEhD;;;GAGG;AACH,SAAgB,gCAAgC,CAE9C,SAAqB,EAAE,iBAA0B;IAC/C,MAAM,eAAe,GAAG,IAAA,mCAAkB,EAAC,SAAS,CAAC,CAAC;IAEtD,IAAI,CAAC,iBAAiB,IAAI,iBAAiB,KAAK,6BAAoB,EAAE;QAClE,OAAO,eAAe,CAAC;KAC1B;IAED,MAAM,MAAM,GAAG,6BAAY,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;IAC3D,IAAI,cAAoC,CAAC;IAEzC,IAAI,iBAAiB,CAAC,MAAM,IAAI,CAAC,IAAI,iBAAiB,CAAC,MAAM,IAAI,CAAC,EAAE;QAChE,2IAA2I;QAC3I,cAAc;YACV,IAAA,6CAA4B,EAAC,SAAS,EAAE,MAAM,CAAC;gBAC/C,IAAA,6CAA4B,EAAC,SAAS,EAAE,MAAM,CAAC;gBAC/C,IAAA,+CAA8B,EAAC,SAAS,EAAE,MAAM,CAAC,CAAC;KACzD;SAAM;QACH,cAAc,GAAG,IAAA,6CAA4B,EAAC,SAAS,EAAE,MAAM,CAAC,CAAC;KACpE;IAED,OAAO,cAAc,CAAC;AAC1B,CAAC;AAvBD,4EAuBC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Category, ExtendedStory, Newsroom, NewsroomCompanyInformation, NewsroomContact, NewsroomLanguageSettings, NewsroomThemePreset, Notification } from '@prezly/sdk';
|
|
2
|
-
import type { AlgoliaSettings } from '@prezly/theme-kit-core';
|
|
3
2
|
import { LocaleObject } from '@prezly/theme-kit-core';
|
|
3
|
+
import type { AlgoliaSettings } from '@prezly/theme-kit-core/server';
|
|
4
4
|
import type { PropsWithChildren } from 'react';
|
|
5
5
|
export interface NewsroomContextType {
|
|
6
6
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/newsroom-context/context.tsx"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/newsroom-context/context.tsx"],"names":[],"mappings":";;;;AAUA,2DAAsE;AAGtE,iCAA+C;AAwDlC,QAAA,eAAe,GAAG,IAAA,qBAAa,EAAkC,SAAS,CAAC,CAAC;AAEzF;;;GAGG;AACH,SAAgB,uBAAuB,CAAC,EACpC,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,aAAa,EACb,WAAW,EACX,eAAe,EACf,QAAQ,GAC8B;IACtC,MAAM,MAAM,GAAG,IAAA,eAAO,EAClB,GAAG,EAAE,CAAC,6BAAY,CAAC,WAAW,CAAC,UAAU,IAAI,+BAAc,CAAC,EAC5D,CAAC,UAAU,CAAC,CACf,CAAC;IAEF,OAAO,CACH,uBAAC,uBAAe,CAAC,QAAQ,IACrB,KAAK,EAAE;YACH,UAAU;YACV,QAAQ;YACR,QAAQ;YACR,eAAe;YACf,YAAY;YACZ,kBAAkB;YAClB,SAAS;YACT,MAAM;YACN,aAAa;YACb,WAAW;YACX,eAAe;SAClB,YAEA,QAAQ,GACc,CAC9B,CAAC;AACN,CAAC;AAtCD,0DAsCC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useAlgoliaSettings(): import("@prezly/theme-kit-core").AlgoliaSettings;
|
|
1
|
+
export declare function useAlgoliaSettings(): import("@prezly/theme-kit-core/server").AlgoliaSettings;
|
|
@@ -1,32 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useGetTranslationUrl = void 0;
|
|
4
|
-
const sdk_1 = require("@prezly/sdk");
|
|
5
4
|
const theme_kit_core_1 = require("@prezly/theme-kit-core");
|
|
6
5
|
const router_1 = require("next/router");
|
|
7
6
|
const react_1 = require("react");
|
|
8
7
|
const useCurrentCategory_1 = require("./useCurrentCategory");
|
|
9
8
|
const useCurrentStory_1 = require("./useCurrentStory");
|
|
10
|
-
// Pulled from SDK types to not leak the `@prezly/sdk` dependency into the client bundle
|
|
11
|
-
// It looks like a hack, but the name of enum must be the same as in SDK
|
|
12
|
-
var Visibility;
|
|
13
|
-
(function (Visibility) {
|
|
14
|
-
Visibility["PUBLIC"] = "public";
|
|
15
|
-
Visibility["EMBARGO"] = "embargo";
|
|
16
|
-
Visibility["PRIVATE"] = "private";
|
|
17
|
-
Visibility["CONFIDENTIAL"] = "confidential";
|
|
18
|
-
})(Visibility || (Visibility = {}));
|
|
19
9
|
function getAllowedTranslationVisibilityValues(story) {
|
|
20
10
|
const { visibility } = story;
|
|
21
11
|
switch (visibility) {
|
|
22
|
-
case Visibility.EMBARGO:
|
|
23
|
-
return [Visibility.EMBARGO, Visibility.PUBLIC];
|
|
24
|
-
case Visibility.PRIVATE:
|
|
25
|
-
return [Visibility.PRIVATE, Visibility.PUBLIC];
|
|
26
|
-
case Visibility.CONFIDENTIAL:
|
|
27
|
-
return [Visibility.CONFIDENTIAL, Visibility.PRIVATE, Visibility.PUBLIC];
|
|
12
|
+
case theme_kit_core_1.Visibility.EMBARGO:
|
|
13
|
+
return [theme_kit_core_1.Visibility.EMBARGO, theme_kit_core_1.Visibility.PUBLIC];
|
|
14
|
+
case theme_kit_core_1.Visibility.PRIVATE:
|
|
15
|
+
return [theme_kit_core_1.Visibility.PRIVATE, theme_kit_core_1.Visibility.PUBLIC];
|
|
16
|
+
case theme_kit_core_1.Visibility.CONFIDENTIAL:
|
|
17
|
+
return [theme_kit_core_1.Visibility.CONFIDENTIAL, theme_kit_core_1.Visibility.PRIVATE, theme_kit_core_1.Visibility.PUBLIC];
|
|
28
18
|
default:
|
|
29
|
-
return [Visibility.PUBLIC];
|
|
19
|
+
return [theme_kit_core_1.Visibility.PUBLIC];
|
|
30
20
|
}
|
|
31
21
|
}
|
|
32
22
|
/**
|
|
@@ -48,8 +38,8 @@ function getTranslationUrl(locale, path, currentCategory, currentStory, noFallba
|
|
|
48
38
|
const localeCode = locale.toUnderscoreCode();
|
|
49
39
|
if (currentStory && currentStory.culture.locale !== localeCode) {
|
|
50
40
|
const allowedVisibilityValues = getAllowedTranslationVisibilityValues(currentStory);
|
|
51
|
-
const translatedStory = currentStory.translations.find(({ culture,
|
|
52
|
-
|
|
41
|
+
const translatedStory = currentStory.translations.find(({ culture, status, visibility }) => culture.locale === localeCode &&
|
|
42
|
+
(0, theme_kit_core_1.isStoryPublished)(status) &&
|
|
53
43
|
allowedVisibilityValues.includes(visibility));
|
|
54
44
|
if (translatedStory) {
|
|
55
45
|
return `/${translatedStory.slug}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetTranslationUrl.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useGetTranslationUrl.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"useGetTranslationUrl.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useGetTranslationUrl.ts"],"names":[],"mappings":";;;AAEA,2DAKgC;AAChC,wCAAwC;AACxC,iCAAoC;AAEpC,6DAA0D;AAC1D,uDAAoD;AAEpD,SAAS,qCAAqC,CAC1C,KAAwC;IAExC,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IAE7B,QAAQ,UAAU,EAAE;QAChB,KAAK,2BAAU,CAAC,OAAO;YACnB,OAAO,CAAC,2BAAU,CAAC,OAAO,EAAE,2BAAU,CAAC,MAAM,CAAC,CAAC;QACnD,KAAK,2BAAU,CAAC,OAAO;YACnB,OAAO,CAAC,2BAAU,CAAC,OAAO,EAAE,2BAAU,CAAC,MAAM,CAAC,CAAC;QACnD,KAAK,2BAAU,CAAC,YAAY;YACxB,OAAO,CAAC,2BAAU,CAAC,YAAY,EAAE,2BAAU,CAAC,OAAO,EAAE,2BAAU,CAAC,MAAM,CAAC,CAAC;QAC5E;YACI,OAAO,CAAC,2BAAU,CAAC,MAAM,CAAC,CAAC;KAClC;AACL,CAAC;AAED;;;;;GAKG;AACH,SAAS,iBAAiB,CACtB,MAAoB,EACpB,IAAY,EACZ,eAAyD,EACzD,YAA4B,EAC5B,UAAoB;IAEpB,IAAI,eAAe,EAAE;QACjB,IAAI,IAAA,0CAAyB,EAAC,eAAe,EAAE,MAAM,CAAC,EAAE;YACpD,OAAO,IAAA,+BAAc,EAAC,eAAe,EAAE,MAAM,CAAC,CAAC;SAClD;QAED,IAAI,UAAU,EAAE;YACZ,OAAO,EAAE,CAAC;SACb;QAED,OAAO,GAAG,CAAC;KACd;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAE7C,IAAI,YAAY,IAAI,YAAY,CAAC,OAAO,CAAC,MAAM,KAAK,UAAU,EAAE;QAC5D,MAAM,uBAAuB,GAAG,qCAAqC,CAAC,YAAY,CAAC,CAAC;QAEpF,MAAM,eAAe,GAAG,YAAY,CAAC,YAAY,CAAC,IAAI,CAClD,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,CAChC,OAAO,CAAC,MAAM,KAAK,UAAU;YAC7B,IAAA,iCAAgB,EAAC,MAAM,CAAC;YACxB,uBAAuB,CAAC,QAAQ,CAAC,UAAU,CAAC,CACnD,CAAC;QACF,IAAI,eAAe,EAAE;YACjB,OAAO,IAAI,eAAe,CAAC,IAAI,EAAE,CAAC;SACrC;QAED,IAAI,UAAU,EAAE;YACZ,OAAO,EAAE,CAAC;SACb;QAED,OAAO,GAAG,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,SAAgB,oBAAoB;IAChC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,kBAAS,GAAE,CAAC;IAC/B,MAAM,eAAe,GAAG,IAAA,uCAAkB,GAAE,CAAC;IAC7C,MAAM,YAAY,GAAG,IAAA,iCAAe,GAAE,CAAC;IAEvC,OAAO,IAAA,mBAAW,EACd,CAAC,MAAoB,EAAE,UAAoB,EAAE,EAAE,CAC3C,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,YAAY,EAAE,UAAU,CAAC,EAChF,CAAC,MAAM,EAAE,eAAe,EAAE,YAAY,CAAC,CAC1C,CAAC;AACN,CAAC;AAVD,oDAUC"}
|
package/build/server.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./adapter-nextjs"), exports);
|
|
18
|
+
__exportStar(require("./data-fetching"), exports);
|
|
19
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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.10",
|
|
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",
|
|
@@ -8,6 +8,17 @@
|
|
|
8
8
|
"build",
|
|
9
9
|
"README.md"
|
|
10
10
|
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": "./build/index.js",
|
|
13
|
+
"./server": "./build/server.js"
|
|
14
|
+
},
|
|
15
|
+
"typesVersions": {
|
|
16
|
+
"*": {
|
|
17
|
+
"server": [
|
|
18
|
+
"build/server.d.ts"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
},
|
|
11
22
|
"engines": {
|
|
12
23
|
"node": ">= 16.x",
|
|
13
24
|
"npm": ">= 8.x"
|
|
@@ -40,8 +51,8 @@
|
|
|
40
51
|
"test": "jest"
|
|
41
52
|
},
|
|
42
53
|
"peerDependencies": {
|
|
43
|
-
"@prezly/sdk": "
|
|
44
|
-
"@prezly/theme-kit-core": "^
|
|
54
|
+
"@prezly/sdk": ">=12 <16",
|
|
55
|
+
"@prezly/theme-kit-core": "^5.0.0-alpha",
|
|
45
56
|
"next": "^12.x || ^13.x",
|
|
46
57
|
"react": "^17.x || ^18.x",
|
|
47
58
|
"react-dom": "^17.x || ^18.x"
|
|
@@ -51,12 +62,12 @@
|
|
|
51
62
|
"next-seo": "^5.4.0"
|
|
52
63
|
},
|
|
53
64
|
"devDependencies": {
|
|
54
|
-
"@prezly/theme-kit-core": "^5.0.0-alpha.
|
|
55
|
-
"@sentry/nextjs": "7.
|
|
65
|
+
"@prezly/theme-kit-core": "^5.0.0-alpha.9",
|
|
66
|
+
"@sentry/nextjs": "7.50.0"
|
|
56
67
|
},
|
|
57
68
|
"publishConfig": {
|
|
58
69
|
"access": "public"
|
|
59
70
|
},
|
|
60
71
|
"sideEffects": false,
|
|
61
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "1bab73fc22c21c0f89b1b4cb08d1c44a2ed733c9"
|
|
62
73
|
}
|