@prezly/theme-kit-nextjs 1.1.4 → 1.2.1
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 +36 -64
- package/build/adapter-nextjs/getNewsroomServerSideProps.d.ts +9 -0
- package/build/adapter-nextjs/{getBasePageProps.js → getNewsroomServerSideProps.js} +9 -9
- package/build/adapter-nextjs/getNewsroomServerSideProps.js.map +1 -0
- package/build/adapter-nextjs/index.d.ts +1 -1
- package/build/adapter-nextjs/index.js +1 -1
- package/build/adapter-nextjs/index.js.map +1 -1
- package/build/adapter-nextjs/processRequest.d.ts +2 -2
- package/build/adapter-nextjs/processRequest.js +19 -14
- package/build/adapter-nextjs/processRequest.js.map +1 -1
- package/build/data-fetching/api/PrezlyApi.d.ts +2 -2
- package/build/data-fetching/api/PrezlyApi.js +11 -11
- package/build/data-fetching/api/PrezlyApi.js.map +1 -1
- package/build/data-fetching/getNewsroomLogoUrl.js +1 -1
- package/build/data-fetching/getNewsroomLogoUrl.js.map +1 -1
- package/build/intl/locale.d.ts +1 -2
- package/build/intl/locale.js +1 -2
- package/build/intl/locale.js.map +1 -1
- package/build/newsroom-context/context.d.ts +7 -9
- package/build/newsroom-context/context.js +17 -25
- package/build/newsroom-context/context.js.map +1 -1
- package/build/newsroom-context/hooks/index.d.ts +2 -2
- package/build/newsroom-context/hooks/index.js +2 -2
- package/build/newsroom-context/hooks/index.js.map +1 -1
- package/build/newsroom-context/hooks/useCurrentCategory.d.ts +1 -0
- package/build/newsroom-context/hooks/useCurrentCategory.js +10 -0
- package/build/newsroom-context/hooks/useCurrentCategory.js.map +1 -0
- package/build/newsroom-context/hooks/useCurrentStory.d.ts +1 -0
- package/build/newsroom-context/hooks/{useSelectedStory.js → useCurrentStory.js} +5 -5
- package/build/newsroom-context/hooks/useCurrentStory.js.map +1 -0
- package/build/newsroom-context/hooks/useGetTranslationUrl.js +12 -12
- package/build/newsroom-context/hooks/useGetTranslationUrl.js.map +1 -1
- package/build/newsroom-context/hooks/useNewsroomContext.d.ts +2 -2
- package/build/newsroom-context/hooks/useNewsroomContext.js.map +1 -1
- package/build/newsroom-context/index.d.ts +1 -1
- package/build/newsroom-context/index.js.map +1 -1
- package/build/types.d.ts +6 -20
- package/package.json +21 -4
- package/src/adapter-nextjs/{getBasePageProps.ts → getNewsroomServerSideProps.ts} +6 -6
- package/src/adapter-nextjs/index.ts +1 -1
- package/src/adapter-nextjs/processRequest.ts +20 -12
- package/src/data-fetching/api/PrezlyApi.ts +12 -13
- package/src/data-fetching/getNewsroomLogoUrl.ts +1 -1
- package/src/intl/locale.ts +1 -4
- package/src/newsroom-context/context.tsx +11 -14
- package/src/newsroom-context/hooks/index.ts +2 -2
- package/src/newsroom-context/hooks/{useSelectedCategory.ts → useCurrentCategory.ts} +2 -2
- package/src/newsroom-context/hooks/{useSelectedStory.ts → useCurrentStory.ts} +2 -2
- package/src/newsroom-context/hooks/useGetTranslationUrl.ts +13 -13
- package/src/newsroom-context/hooks/useNewsroomContext.ts +2 -2
- package/src/newsroom-context/index.ts +1 -1
- package/src/types.ts +9 -32
- package/build/adapter-nextjs/getBasePageProps.d.ts +0 -9
- package/build/adapter-nextjs/getBasePageProps.js.map +0 -1
- package/build/newsroom-context/hooks/useSelectedCategory.d.ts +0 -1
- package/build/newsroom-context/hooks/useSelectedCategory.js +0 -10
- package/build/newsroom-context/hooks/useSelectedCategory.js.map +0 -1
- package/build/newsroom-context/hooks/useSelectedStory.d.ts +0 -1
- package/build/newsroom-context/hooks/useSelectedStory.js.map +0 -1
package/README.md
CHANGED
|
@@ -87,48 +87,24 @@ module.exports = {
|
|
|
87
87
|
|
|
88
88
|
### pages/_app.tsx
|
|
89
89
|
|
|
90
|
-
In order to provide all the necessary data to the entire application,
|
|
90
|
+
In order to provide all the necessary data to the entire application, this library exports the `NewsroomContextProvider` component, which accepts props retrieved by our data-fetching methods (see next section). These props contain data that would be required to display common components like navigation, language picker, boilerplate, etc.
|
|
91
91
|
|
|
92
|
-
```
|
|
93
|
-
import {
|
|
94
|
-
import { AppProps } from 'next/app';
|
|
92
|
+
```tsx
|
|
93
|
+
import { NewsroomContextProvider, PageProps } from '@prezly/theme-kit-nextjs';
|
|
94
|
+
import type { AppProps } from 'next/app';
|
|
95
95
|
|
|
96
96
|
type AnyPageProps = Record<string, any>;
|
|
97
97
|
|
|
98
98
|
function App({ Component, pageProps }: AppProps<AnyPageProps>) {
|
|
99
|
-
const {
|
|
100
|
-
categories,
|
|
101
|
-
contacts,
|
|
102
|
-
newsroom,
|
|
103
|
-
companyInformation,
|
|
104
|
-
languages,
|
|
105
|
-
localeCode,
|
|
106
|
-
themePreset,
|
|
107
|
-
algoliaSettings,
|
|
108
|
-
selectedCategory,
|
|
109
|
-
selectedStory,
|
|
110
|
-
hasError,
|
|
111
|
-
...customPageProps
|
|
112
|
-
} = pageProps as BasePageProps & AnyPageProps;
|
|
99
|
+
const { newsroomContextProps, ...customPageProps } = pageProps as PageProps & AnyPageProps;
|
|
113
100
|
|
|
101
|
+
/* eslint-disable react/jsx-props-no-spreading */
|
|
114
102
|
return (
|
|
115
|
-
<NewsroomContextProvider
|
|
116
|
-
categories={categories}
|
|
117
|
-
contacts={contacts}
|
|
118
|
-
newsroom={newsroom}
|
|
119
|
-
companyInformation={companyInformation}
|
|
120
|
-
languages={languages}
|
|
121
|
-
localeCode={localeCode}
|
|
122
|
-
themePreset={themePreset}
|
|
123
|
-
selectedCategory={selectedCategory}
|
|
124
|
-
selectedStory={selectedStory}
|
|
125
|
-
algoliaSettings={algoliaSettings}
|
|
126
|
-
hasError={hasError}
|
|
127
|
-
>
|
|
128
|
-
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
|
|
103
|
+
<NewsroomContextProvider {...newsroomContextProps}>
|
|
129
104
|
<Component {...customPageProps} />
|
|
130
105
|
</NewsroomContextProvider>
|
|
131
106
|
);
|
|
107
|
+
/* eslint-enable react/jsx-props-no-spreading */
|
|
132
108
|
}
|
|
133
109
|
|
|
134
110
|
export default App;
|
|
@@ -138,64 +114,60 @@ export default App;
|
|
|
138
114
|
|
|
139
115
|
Every page requires a bit of boilerplate code to set up.
|
|
140
116
|
|
|
141
|
-
```
|
|
142
|
-
import {
|
|
143
|
-
import { GetServerSideProps } from 'next';
|
|
117
|
+
```tsx
|
|
118
|
+
import { getNewsroomServerSideProps, processRequest } from '@prezly/theme-kit-nextjs';
|
|
119
|
+
import type { GetServerSideProps } from 'next';
|
|
144
120
|
import type { FunctionComponent } from 'react';
|
|
145
121
|
|
|
146
|
-
interface Props
|
|
147
|
-
|
|
122
|
+
interface Props {
|
|
123
|
+
myProp: string;
|
|
148
124
|
}
|
|
149
125
|
|
|
150
|
-
const Page: FunctionComponent<Props> = () =>
|
|
126
|
+
const Page: FunctionComponent<Props> = ({ myProp }) => <p>{myProp}</p>;
|
|
151
127
|
|
|
152
128
|
export const getServerSideProps: GetServerSideProps<Props> = async (context) => {
|
|
153
|
-
const { api,
|
|
129
|
+
const { api, serverSideProps } = await getNewsroomServerSideProps(context);
|
|
154
130
|
|
|
155
131
|
/* Your logic to get additional props for this page */
|
|
156
132
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
133
|
+
return processRequest(
|
|
134
|
+
context,
|
|
135
|
+
{
|
|
136
|
+
...serverSideProps,
|
|
137
|
+
myProp: 'My Custom Prop',
|
|
138
|
+
},
|
|
139
|
+
'/',
|
|
140
|
+
);
|
|
161
141
|
};
|
|
162
142
|
|
|
163
143
|
export default Page;
|
|
164
144
|
```
|
|
165
145
|
|
|
166
|
-
|
|
167
|
-
#### Here's a breakdown of what's happening:
|
|
168
|
-
|
|
169
|
-
**Prop types**
|
|
170
|
-
```ts
|
|
171
|
-
interface Props extends BasePageProps {
|
|
172
|
-
/* Additional props for this page */
|
|
173
|
-
}
|
|
174
|
-
```
|
|
175
|
-
Every page props should extend `BasePageProps` type, since they are required for `NewsroomContextProvider` added previously.
|
|
176
|
-
These props contain data that would be required to display common components like navigation, language picker, boilerplate, etc.
|
|
177
|
-
|
|
178
146
|
**Page display component**
|
|
179
|
-
```
|
|
180
|
-
const Page: FunctionComponent<Props> = () =>
|
|
147
|
+
```tsx
|
|
148
|
+
const Page: FunctionComponent<Props> = ({ myProp }) => <p>{myProp}</p>;
|
|
181
149
|
```
|
|
182
|
-
Since all of the common data is loaded into the `NewsroomContextProvider`, you don't need to handle any of those in your display components. So the Page component should just handle rendering the provided data.
|
|
150
|
+
Since all of the common data is loaded into the `NewsroomContextProvider`, you don't need to handle any of those in your display components. So the Page component should just handle rendering the provided data. You can still use context hooks to access the newsroom data.
|
|
183
151
|
|
|
184
152
|
**Data fetching**
|
|
185
153
|
```ts
|
|
186
|
-
const { api,
|
|
154
|
+
const { api, serverSideProps } = await getNewsroomServerSideProps(context);
|
|
187
155
|
```
|
|
188
156
|
This function fetches all the required base props and exposes the `PrezlyApi` instance, which you can use to fetch additional content like stories or categories.
|
|
189
157
|
|
|
190
158
|
```ts
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
159
|
+
return processRequest(
|
|
160
|
+
context,
|
|
161
|
+
{
|
|
162
|
+
...serverSideProps,
|
|
163
|
+
myProp: 'My Custom Prop',
|
|
164
|
+
},
|
|
165
|
+
'/',
|
|
166
|
+
);
|
|
195
167
|
```
|
|
196
168
|
This function returns the combined base props and your additional props, with some extra logic in between to handle locale URLs.
|
|
197
169
|
|
|
198
|
-
The third argument is
|
|
170
|
+
The third argument is needed to properly handle locale redirects. It should contain the URL for the current page without locale prefixes (like `/`, `/media`, `/category/${category.slug}`. If omitted, the redirect logic will not be executing.
|
|
199
171
|
|
|
200
172
|
----
|
|
201
173
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { GetServerSidePropsContext } from 'next';
|
|
2
|
+
interface Options {
|
|
3
|
+
loadHomepageContacts?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function getNewsroomServerSideProps(context: GetServerSidePropsContext, options?: Options): Promise<{
|
|
6
|
+
api: import("../data-fetching/api/PrezlyApi").PrezlyApi;
|
|
7
|
+
serverSideProps: import("..").PageProps & import("..").ServerSidePageProps;
|
|
8
|
+
}>;
|
|
9
|
+
export {};
|
|
@@ -36,30 +36,30 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.
|
|
39
|
+
exports.getNewsroomServerSideProps = void 0;
|
|
40
40
|
var data_fetching_1 = require("../data-fetching");
|
|
41
|
-
function
|
|
41
|
+
function getNewsroomServerSideProps(context, options) {
|
|
42
42
|
if (options === void 0) { options = {}; }
|
|
43
43
|
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
-
var request, locale, api,
|
|
44
|
+
var request, locale, api, serverSideProps, _a;
|
|
45
45
|
return __generator(this, function (_b) {
|
|
46
46
|
switch (_b.label) {
|
|
47
47
|
case 0:
|
|
48
48
|
request = context.req, locale = context.locale;
|
|
49
49
|
api = (0, data_fetching_1.getPrezlyApi)(request);
|
|
50
|
-
return [4 /*yield*/, api.
|
|
50
|
+
return [4 /*yield*/, api.getNewsroomServerSideProps(request, locale)];
|
|
51
51
|
case 1:
|
|
52
|
-
|
|
52
|
+
serverSideProps = _b.sent();
|
|
53
53
|
if (!options.loadHomepageContacts) return [3 /*break*/, 3];
|
|
54
|
-
_a =
|
|
54
|
+
_a = serverSideProps.newsroomContextProps;
|
|
55
55
|
return [4 /*yield*/, api.getNewsroomContacts()];
|
|
56
56
|
case 2:
|
|
57
57
|
_a.contacts = _b.sent();
|
|
58
58
|
_b.label = 3;
|
|
59
|
-
case 3: return [2 /*return*/, { api: api,
|
|
59
|
+
case 3: return [2 /*return*/, { api: api, serverSideProps: serverSideProps }];
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
-
exports.
|
|
65
|
-
//# sourceMappingURL=
|
|
64
|
+
exports.getNewsroomServerSideProps = getNewsroomServerSideProps;
|
|
65
|
+
//# sourceMappingURL=getNewsroomServerSideProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getNewsroomServerSideProps.js","sourceRoot":"","sources":["../../src/adapter-nextjs/getNewsroomServerSideProps.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,kDAAgD;AAMhD,SAAsB,0BAA0B,CAC5C,OAAkC,EAClC,OAAqB;IAArB,wBAAA,EAAA,YAAqB;;;;;;oBAER,OAAO,GAAa,OAAO,IAApB,EAAE,MAAM,GAAK,OAAO,OAAZ,CAAa;oBAEnC,GAAG,GAAG,IAAA,4BAAY,EAAC,OAAO,CAAC,CAAC;oBACV,qBAAM,GAAG,CAAC,0BAA0B,CAAC,OAAO,EAAE,MAAM,CAAC,EAAA;;oBAAvE,eAAe,GAAG,SAAqD;yBAEzE,OAAO,CAAC,oBAAoB,EAA5B,wBAA4B;oBAC5B,KAAA,eAAe,CAAC,oBAAoB,CAAA;oBAAY,qBAAM,GAAG,CAAC,mBAAmB,EAAE,EAAA;;oBAA/E,GAAqC,QAAQ,GAAG,SAA+B,CAAC;;wBAGpF,sBAAO,EAAE,GAAG,KAAA,EAAE,eAAe,iBAAA,EAAE,EAAC;;;;CACnC;AAdD,gEAcC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './getNewsroomServerSideProps';
|
|
2
2
|
export * from './processRequest';
|
|
@@ -10,6 +10,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./
|
|
13
|
+
__exportStar(require("./getNewsroomServerSideProps"), exports);
|
|
14
14
|
__exportStar(require("./processRequest"), exports);
|
|
15
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapter-nextjs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapter-nextjs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAA6C;AAC7C,mDAAiC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { GetServerSidePropsContext, GetServerSidePropsResult } from 'next';
|
|
2
|
-
import {
|
|
3
|
-
export declare function processRequest<Props
|
|
2
|
+
import { PageProps, ServerSidePageProps } from '../types';
|
|
3
|
+
export declare function processRequest<Props>(context: GetServerSidePropsContext, props: Props & PageProps & ServerSidePageProps, canonicalUrl?: string): GetServerSidePropsResult<Props>;
|
|
@@ -1,31 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
8
10
|
}
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
11
|
+
return t;
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.processRequest = void 0;
|
|
15
|
+
var data_fetching_1 = require("../data-fetching");
|
|
15
16
|
var intl_1 = require("../intl");
|
|
16
|
-
function processRequest(context,
|
|
17
|
-
var
|
|
18
|
-
|
|
17
|
+
function processRequest(context, props, canonicalUrl) {
|
|
18
|
+
var nextLocale = context.locale, query = context.query;
|
|
19
|
+
var localeResolved = props.localeResolved, pageProps = __rest(props, ["localeResolved"]);
|
|
20
|
+
if (!localeResolved) {
|
|
19
21
|
return { notFound: true };
|
|
20
22
|
}
|
|
21
23
|
if (canonicalUrl) {
|
|
22
|
-
var
|
|
24
|
+
var _a = pageProps.newsroomContextProps, languages = _a.languages, localeCode = _a.localeCode;
|
|
25
|
+
var currentLocale = intl_1.LocaleObject.fromAnyCode(localeCode);
|
|
26
|
+
var shortestLocaleCode = (0, data_fetching_1.getShortestLocaleCode)(languages, currentLocale);
|
|
27
|
+
var redirect = (0, intl_1.getRedirectToCanonicalLocale)(shortestLocaleCode, nextLocale, canonicalUrl, query);
|
|
23
28
|
if (redirect) {
|
|
24
29
|
return { redirect: redirect };
|
|
25
30
|
}
|
|
26
31
|
}
|
|
27
32
|
return {
|
|
28
|
-
props:
|
|
33
|
+
props: pageProps,
|
|
29
34
|
};
|
|
30
35
|
}
|
|
31
36
|
exports.processRequest = processRequest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processRequest.js","sourceRoot":"","sources":["../../src/adapter-nextjs/processRequest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,
|
|
1
|
+
{"version":3,"file":"processRequest.js","sourceRoot":"","sources":["../../src/adapter-nextjs/processRequest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,kDAAyD;AACzD,gCAAqE;AAGrE,SAAgB,cAAc,CAC1B,OAAkC,EAClC,KAA8C,EAC9C,YAAqB;IAEb,IAAQ,UAAU,GAAY,OAAO,OAAnB,EAAE,KAAK,GAAK,OAAO,MAAZ,CAAa;IAEtC,IAAA,cAAc,GAAmB,KAAK,eAAxB,EAAK,SAAS,UAAK,KAAK,EAAxC,kBAAgC,CAAF,CAAW;IAE/C,IAAI,CAAC,cAAc,EAAE;QACjB,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;KAC7B;IAED,IAAI,YAAY,EAAE;QACR,IAAA,KAA4B,SAAS,CAAC,oBAAoB,EAAxD,SAAS,eAAA,EAAE,UAAU,gBAAmC,CAAC;QACjE,IAAM,aAAa,GAAG,mBAAY,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QAC3D,IAAM,kBAAkB,GAAG,IAAA,qCAAqB,EAAC,SAAS,EAAE,aAAa,CAAC,CAAC;QAE3E,IAAM,QAAQ,GAAG,IAAA,mCAA4B,EACzC,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,KAAK,CACR,CAAC;QACF,IAAI,QAAQ,EAAE;YACV,OAAO,EAAE,QAAQ,UAAA,EAAE,CAAC;SACvB;KACJ;IAED,OAAO;QACH,KAAK,EAAE,SAA8B;KACxC,CAAC;AACN,CAAC;AAhCD,wCAgCC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import PrezlySDK, { Category, ExtraStoryFields, Newsroom, NewsroomLanguageSettings, Story } from '@prezly/sdk';
|
|
3
3
|
import type { IncomingMessage } from 'http';
|
|
4
|
-
import {
|
|
4
|
+
import { PageProps, ServerSidePageProps } from '../../types';
|
|
5
5
|
declare type SortOrder = 'desc' | 'asc';
|
|
6
6
|
interface GetStoriesOptions {
|
|
7
7
|
page?: number;
|
|
@@ -38,6 +38,6 @@ export declare class PrezlyApi {
|
|
|
38
38
|
getGalleries({ page, pageSize }: GetGalleriesOptions): Promise<import("@prezly/sdk/dist/Sdk/NewsroomGalleries/types").NewsroomGalleriesListResponse>;
|
|
39
39
|
getGallery(uuid: string): Promise<import("@prezly/sdk").NewsroomGallery>;
|
|
40
40
|
getThemePreset(): Promise<import("@prezly/sdk").NewsroomThemePreset>;
|
|
41
|
-
|
|
41
|
+
getNewsroomServerSideProps(request: IncomingMessage | undefined, nextLocaleIsoCode?: string, story?: Story): Promise<PageProps & ServerSidePageProps>;
|
|
42
42
|
}
|
|
43
43
|
export {};
|
|
@@ -262,9 +262,9 @@ var PrezlyApi = /** @class */ (function () {
|
|
|
262
262
|
});
|
|
263
263
|
});
|
|
264
264
|
};
|
|
265
|
-
PrezlyApi.prototype.
|
|
265
|
+
PrezlyApi.prototype.getNewsroomServerSideProps = function (request, nextLocaleIsoCode, story) {
|
|
266
266
|
return __awaiter(this, void 0, void 0, function () {
|
|
267
|
-
var _a, newsroom, languages, categories, themePreset, currentLanguage, defaultLanguage, localeCode, locale,
|
|
267
|
+
var _a, newsroom, languages, categories, themePreset, currentLanguage, defaultLanguage, localeCode, locale, companyInformation, algoliaSettings;
|
|
268
268
|
return __generator(this, function (_b) {
|
|
269
269
|
switch (_b.label) {
|
|
270
270
|
case 0: return [4 /*yield*/, Promise.all([
|
|
@@ -281,19 +281,19 @@ var PrezlyApi = /** @class */ (function () {
|
|
|
281
281
|
defaultLanguage = (0, languages_1.getDefaultLanguage)(languages);
|
|
282
282
|
localeCode = (currentLanguage || defaultLanguage).code;
|
|
283
283
|
locale = intl_1.LocaleObject.fromAnyCode(localeCode);
|
|
284
|
-
shortestLocaleCode = (0, languages_1.getShortestLocaleCode)(languages, locale);
|
|
285
284
|
companyInformation = (0, languages_1.getCompanyInformation)(languages, locale);
|
|
286
285
|
algoliaSettings = (0, getAlgoliaSettings_1.getAlgoliaSettings)(request);
|
|
287
286
|
return [2 /*return*/, {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
287
|
+
newsroomContextProps: {
|
|
288
|
+
newsroom: newsroom,
|
|
289
|
+
companyInformation: companyInformation,
|
|
290
|
+
categories: categories,
|
|
291
|
+
languages: languages,
|
|
292
|
+
localeCode: localeCode,
|
|
293
|
+
themePreset: themePreset,
|
|
294
|
+
algoliaSettings: algoliaSettings,
|
|
295
|
+
},
|
|
294
296
|
localeResolved: Boolean(currentLanguage),
|
|
295
|
-
themePreset: themePreset,
|
|
296
|
-
algoliaSettings: algoliaSettings,
|
|
297
297
|
}];
|
|
298
298
|
}
|
|
299
299
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrezlyApi.js","sourceRoot":"","sources":["../../../src/data-fetching/api/PrezlyApi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAMqB;AAGrB,mCAA0C;AAE1C,0CAAiD;AACjD,gEAA+D;AAE/D,
|
|
1
|
+
{"version":3,"file":"PrezlyApi.js","sourceRoot":"","sources":["../../../src/data-fetching/api/PrezlyApi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAMqB;AAGrB,mCAA0C;AAE1C,0CAAiD;AACjD,gEAA+D;AAE/D,yCAKqB;AACrB,qCAMmB;AAEnB,IAAM,kBAAkB,GAAc,MAAM,CAAC;AAiB7C;IAKI,mBAAY,WAAmB,EAAE,YAA8B;QAA/D,iBAQC;;QA2HD,kBAAa,GAA8C,UAAC,OAAO;YAC/D,OAAA,KAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;QAAhC,CAAgC,CAAC;QAnIjC,IAAM,OAAO,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,qBAAqB,mCAAI,SAAS,CAAC;QAC/D,IAAI,CAAC,GAAG,GAAG,IAAI,aAAS,CAAC;YACrB,WAAW,aAAA;YACX,OAAO,SAAA;YACP,OAAO,EAAE,EAAE,oBAAoB,EAAE,MAAM,EAAE;SAC5C,CAAC,CAAC;QACH,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;IAED,4BAAQ,GAAR,UAAS,IAAY;QACjB,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,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EAAC;;;;KACL;IACL,gBAAC;AAAD,CAAC,AAjMD,IAiMC;AAjMY,8BAAS"}
|
|
@@ -4,7 +4,7 @@ exports.getNewsroomFaviconUrl = exports.getNewsroomLogoUrl = void 0;
|
|
|
4
4
|
var getAssetsUrl_1 = require("./getAssetsUrl");
|
|
5
5
|
function getNewsroomLogoUrl(newsroom) {
|
|
6
6
|
if (newsroom.newsroom_logo) {
|
|
7
|
-
(0, getAssetsUrl_1.getAssetsUrl)(newsroom.newsroom_logo.uuid);
|
|
7
|
+
return (0, getAssetsUrl_1.getAssetsUrl)(newsroom.newsroom_logo.uuid);
|
|
8
8
|
}
|
|
9
9
|
return '';
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNewsroomLogoUrl.js","sourceRoot":"","sources":["../../src/data-fetching/getNewsroomLogoUrl.ts"],"names":[],"mappings":";;;AAEA,+CAA8C;AAE9C,SAAgB,kBAAkB,CAAC,QAAkB;IACjD,IAAI,QAAQ,CAAC,aAAa,EAAE;QACxB,IAAA,2BAAY,EAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"getNewsroomLogoUrl.js","sourceRoot":"","sources":["../../src/data-fetching/getNewsroomLogoUrl.ts"],"names":[],"mappings":";;;AAEA,+CAA8C;AAE9C,SAAgB,kBAAkB,CAAC,QAAkB;IACjD,IAAI,QAAQ,CAAC,aAAa,EAAE;QACxB,OAAO,IAAA,2BAAY,EAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;KACpD;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AAND,gDAMC;AAED,SAAgB,qBAAqB,CAAC,QAAkB,EAAE,WAAiB;IAAjB,4BAAA,EAAA,iBAAiB;IACvE,IAAI,QAAQ,CAAC,IAAI,EAAE;QACf,OAAO,UAAG,IAAA,2BAAY,EAClB,QAAQ,CAAC,IAAI,CAAC,IAAI,CACrB,uBAAa,WAAW,cAAI,WAAW,qBAAkB,CAAC;KAC9D;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AARD,sDAQC"}
|
package/build/intl/locale.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { Redirect } from 'next';
|
|
3
3
|
import { ParsedUrlQuery } from 'querystring';
|
|
4
|
-
import { BasePageProps } from '../types';
|
|
5
4
|
import { LocaleObject } from './localeObject';
|
|
6
5
|
export declare const DEFAULT_LOCALE = "en";
|
|
7
6
|
export declare const DUMMY_DEFAULT_LOCALE = "qps-ploc";
|
|
8
7
|
export declare function getSupportedLocaleIsoCode(locale: LocaleObject): string;
|
|
9
|
-
export declare function getRedirectToCanonicalLocale(
|
|
8
|
+
export declare function getRedirectToCanonicalLocale(shortestLocaleCode: string | false, nextLocaleIsoCode: string | undefined, redirectPath: string, query?: ParsedUrlQuery): Redirect | undefined;
|
|
10
9
|
export declare function getLocaleDirection(locale: LocaleObject): 'ltr' | 'rtl';
|
package/build/intl/locale.js
CHANGED
|
@@ -67,8 +67,7 @@ function getSupportedLocaleIsoCode(locale) {
|
|
|
67
67
|
return exports.DEFAULT_LOCALE;
|
|
68
68
|
}
|
|
69
69
|
exports.getSupportedLocaleIsoCode = getSupportedLocaleIsoCode;
|
|
70
|
-
function getRedirectToCanonicalLocale(
|
|
71
|
-
var shortestLocaleCode = basePageProps.shortestLocaleCode;
|
|
70
|
+
function getRedirectToCanonicalLocale(shortestLocaleCode, nextLocaleIsoCode, redirectPath, query) {
|
|
72
71
|
var shortestLocaleSlug = shortestLocaleCode
|
|
73
72
|
? localeObject_1.LocaleObject.fromAnyCode(shortestLocaleCode).toUrlSlug()
|
|
74
73
|
: shortestLocaleCode;
|
package/build/intl/locale.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale.js","sourceRoot":"","sources":["../../src/intl/locale.ts"],"names":[],"mappings":";;;AACA,2CAAwD;
|
|
1
|
+
{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anyInformation, NewsroomContact, NewsroomLanguageSettings, NewsroomThemePreset } from '@prezly/sdk';
|
|
2
|
-
import
|
|
2
|
+
import { FunctionComponent } from 'react';
|
|
3
3
|
import type { AlgoliaSettings } from '../data-fetching';
|
|
4
4
|
import { LocaleObject } from '../intl';
|
|
5
|
-
export interface
|
|
5
|
+
export interface NewsroomContextType {
|
|
6
6
|
newsroom: Newsroom;
|
|
7
7
|
companyInformation: NewsroomCompanyInformation;
|
|
8
8
|
categories: Category[];
|
|
9
9
|
contacts?: NewsroomContact[];
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
currentCategory?: Category;
|
|
11
|
+
currentStory?: ExtendedStory;
|
|
12
12
|
languages: NewsroomLanguageSettings[];
|
|
13
13
|
locale: LocaleObject;
|
|
14
|
-
hasError?: boolean;
|
|
15
14
|
themePreset: NewsroomThemePreset;
|
|
16
15
|
algoliaSettings: AlgoliaSettings;
|
|
17
16
|
}
|
|
18
|
-
interface
|
|
17
|
+
export interface NewsroomContextProps extends Omit<NewsroomContextType, 'locale'> {
|
|
19
18
|
localeCode: string;
|
|
20
19
|
}
|
|
21
|
-
export declare const NewsroomContext:
|
|
22
|
-
export declare const NewsroomContextProvider: FunctionComponent<
|
|
23
|
-
export {};
|
|
20
|
+
export declare const NewsroomContext: import("react").Context<NewsroomContextType | undefined>;
|
|
21
|
+
export declare const NewsroomContextProvider: FunctionComponent<NewsroomContextProps>;
|
|
@@ -1,44 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
20
12
|
};
|
|
21
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
14
|
exports.NewsroomContextProvider = exports.NewsroomContext = void 0;
|
|
23
|
-
var
|
|
15
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
var react_1 = require("react");
|
|
24
17
|
var intl_1 = require("../intl");
|
|
25
18
|
exports.NewsroomContext = (0, react_1.createContext)(undefined);
|
|
26
19
|
var NewsroomContextProvider = function (_a) {
|
|
27
|
-
var categories = _a.categories, contacts = _a.contacts, newsroom = _a.newsroom,
|
|
20
|
+
var categories = _a.categories, contacts = _a.contacts, newsroom = _a.newsroom, currentCategory = _a.currentCategory, currentStory = _a.currentStory, companyInformation = _a.companyInformation, languages = _a.languages, localeCode = _a.localeCode, themePreset = _a.themePreset, algoliaSettings = _a.algoliaSettings, children = _a.children;
|
|
28
21
|
var locale = (0, react_1.useMemo)(function () { return intl_1.LocaleObject.fromAnyCode(localeCode || intl_1.DEFAULT_LOCALE); }, [localeCode]);
|
|
29
|
-
return (
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(exports.NewsroomContext.Provider, __assign({ value: {
|
|
30
23
|
categories: categories,
|
|
31
24
|
contacts: contacts,
|
|
32
25
|
newsroom: newsroom,
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
currentCategory: currentCategory,
|
|
27
|
+
currentStory: currentStory,
|
|
35
28
|
companyInformation: companyInformation,
|
|
36
29
|
languages: languages,
|
|
37
30
|
locale: locale,
|
|
38
|
-
hasError: hasError,
|
|
39
31
|
themePreset: themePreset,
|
|
40
32
|
algoliaSettings: algoliaSettings,
|
|
41
|
-
} }, children));
|
|
33
|
+
} }, { children: children }), void 0));
|
|
42
34
|
};
|
|
43
35
|
exports.NewsroomContextProvider = NewsroomContextProvider;
|
|
44
36
|
//# sourceMappingURL=context.js.map
|
|
@@ -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":";;;;;;;;;;;;;;;AASA,+BAAkE;AAGlE,gCAAuD;AAmB1C,QAAA,eAAe,GAAG,IAAA,qBAAa,EAAkC,SAAS,CAAC,CAAC;AAElF,IAAM,uBAAuB,GAA4C,UAAC,EAYhF;QAXG,UAAU,gBAAA,EACV,QAAQ,cAAA,EACR,QAAQ,cAAA,EACR,eAAe,qBAAA,EACf,YAAY,kBAAA,EACZ,kBAAkB,wBAAA,EAClB,SAAS,eAAA,EACT,UAAU,gBAAA,EACV,WAAW,iBAAA,EACX,eAAe,qBAAA,EACf,QAAQ,cAAA;IAER,IAAM,MAAM,GAAG,IAAA,eAAO,EAClB,cAAM,OAAA,mBAAY,CAAC,WAAW,CAAC,UAAU,IAAI,qBAAc,CAAC,EAAtD,CAAsD,EAC5D,CAAC,UAAU,CAAC,CACf,CAAC;IAEF,OAAO,CACH,uBAAC,uBAAe,CAAC,QAAQ,aACrB,KAAK,EAAE;YACH,UAAU,YAAA;YACV,QAAQ,UAAA;YACR,QAAQ,UAAA;YACR,eAAe,iBAAA;YACf,YAAY,cAAA;YACZ,kBAAkB,oBAAA;YAClB,SAAS,WAAA;YACT,MAAM,QAAA;YACN,WAAW,aAAA;YACX,eAAe,iBAAA;SAClB,gBAEA,QAAQ,YACc,CAC9B,CAAC;AACN,CAAC,CAAC;AApCW,QAAA,uBAAuB,2BAoClC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export * from './useAlgoliaSettings';
|
|
2
2
|
export * from './useCategories';
|
|
3
3
|
export * from './useCompanyInformation';
|
|
4
|
+
export * from './useCurrentCategory';
|
|
4
5
|
export * from './useCurrentLocale';
|
|
6
|
+
export * from './useCurrentStory';
|
|
5
7
|
export * from './useGetLinkLocaleSlug';
|
|
6
8
|
export * from './useGetTranslationUrl';
|
|
7
9
|
export * from './useLanguages';
|
|
8
10
|
export * from './useNewsroom';
|
|
9
11
|
export * from './useNewsroomContext';
|
|
10
|
-
export * from './useSelectedCategory';
|
|
11
|
-
export * from './useSelectedStory';
|
|
@@ -13,12 +13,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
__exportStar(require("./useAlgoliaSettings"), exports);
|
|
14
14
|
__exportStar(require("./useCategories"), exports);
|
|
15
15
|
__exportStar(require("./useCompanyInformation"), exports);
|
|
16
|
+
__exportStar(require("./useCurrentCategory"), exports);
|
|
16
17
|
__exportStar(require("./useCurrentLocale"), exports);
|
|
18
|
+
__exportStar(require("./useCurrentStory"), exports);
|
|
17
19
|
__exportStar(require("./useGetLinkLocaleSlug"), exports);
|
|
18
20
|
__exportStar(require("./useGetTranslationUrl"), exports);
|
|
19
21
|
__exportStar(require("./useLanguages"), exports);
|
|
20
22
|
__exportStar(require("./useNewsroom"), exports);
|
|
21
23
|
__exportStar(require("./useNewsroomContext"), exports);
|
|
22
|
-
__exportStar(require("./useSelectedCategory"), exports);
|
|
23
|
-
__exportStar(require("./useSelectedStory"), exports);
|
|
24
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAqC;AACrC,kDAAgC;AAChC,0DAAwC;AACxC,qDAAmC;AACnC,yDAAuC;AACvC,yDAAuC;AACvC,iDAA+B;AAC/B,gDAA8B;AAC9B,uDAAqC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAqC;AACrC,kDAAgC;AAChC,0DAAwC;AACxC,uDAAqC;AACrC,qDAAmC;AACnC,oDAAkC;AAClC,yDAAuC;AACvC,yDAAuC;AACvC,iDAA+B;AAC/B,gDAA8B;AAC9B,uDAAqC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useCurrentCategory: () => import("@prezly/sdk").Category | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCurrentCategory = void 0;
|
|
4
|
+
var useNewsroomContext_1 = require("./useNewsroomContext");
|
|
5
|
+
var useCurrentCategory = function () {
|
|
6
|
+
var context = (0, useNewsroomContext_1.useNewsroomContext)();
|
|
7
|
+
return context.currentCategory;
|
|
8
|
+
};
|
|
9
|
+
exports.useCurrentCategory = useCurrentCategory;
|
|
10
|
+
//# sourceMappingURL=useCurrentCategory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCurrentCategory.js","sourceRoot":"","sources":["../../../src/newsroom-context/hooks/useCurrentCategory.ts"],"names":[],"mappings":";;;AAAA,2DAA0D;AAEnD,IAAM,kBAAkB,GAAG;IAC9B,IAAM,OAAO,GAAG,IAAA,uCAAkB,GAAE,CAAC;IAErC,OAAO,OAAO,CAAC,eAAe,CAAC;AACnC,CAAC,CAAC;AAJW,QAAA,kBAAkB,sBAI7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useCurrentStory: () => import("@prezly/sdk").ExtendedStory | undefined;
|