@prezly/theme-kit-nextjs 1.1.0 → 1.1.4
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 +195 -3
- package/build/adapter-nextjs/getBasePageProps.js +59 -9
- package/build/adapter-nextjs/getBasePageProps.js.map +1 -1
- package/build/adapter-nextjs/processRequest.js +16 -8
- package/build/adapter-nextjs/processRequest.js.map +1 -1
- package/build/data-fetching/api/PrezlyApi.js +286 -127
- package/build/data-fetching/api/PrezlyApi.js.map +1 -1
- package/build/data-fetching/api/getPrezlyApi.js +4 -4
- package/build/data-fetching/api/getPrezlyApi.js.map +1 -1
- package/build/data-fetching/api/languages.js +62 -32
- package/build/data-fetching/api/languages.js.map +1 -1
- package/build/data-fetching/api/queries.js +44 -18
- package/build/data-fetching/api/queries.js.map +1 -1
- package/build/data-fetching/getAssetsUrl.js +2 -2
- package/build/data-fetching/getAssetsUrl.js.map +1 -1
- package/build/data-fetching/getLocalizedCategoryData.js +23 -12
- package/build/data-fetching/getLocalizedCategoryData.js.map +1 -1
- package/build/data-fetching/getNewsroomLogoUrl.js +4 -3
- package/build/data-fetching/getNewsroomLogoUrl.js.map +1 -1
- package/build/data-fetching/getPrivacyPortalUrl.js +2 -2
- package/build/data-fetching/getPrivacyPortalUrl.js.map +1 -1
- package/build/data-fetching/{getStoryPublicationDate.jsx → getStoryPublicationDate.js} +2 -2
- package/build/data-fetching/getStoryPublicationDate.js.map +1 -0
- package/build/data-fetching/getUploadcareGroupUrl.js +2 -2
- package/build/data-fetching/getUploadcareGroupUrl.js.map +1 -1
- package/build/data-fetching/lib/getAlgoliaSettings.js +6 -6
- package/build/data-fetching/lib/getAlgoliaSettings.js.map +1 -1
- package/build/data-fetching/lib/getEnvVariables.js +24 -13
- package/build/data-fetching/lib/getEnvVariables.js.map +1 -1
- package/build/intl/lang.js +6 -3
- package/build/intl/lang.js.map +1 -1
- package/build/intl/locale.js +14 -14
- package/build/intl/locale.js.map +1 -1
- package/build/intl/localeConfig.js +28 -7
- package/build/intl/localeConfig.js.map +1 -1
- package/build/intl/localeObject.js +41 -29
- package/build/intl/localeObject.js.map +1 -1
- package/build/newsroom-context/context.d.ts +4 -7
- package/build/newsroom-context/context.js +44 -0
- package/build/newsroom-context/context.js.map +1 -0
- package/build/newsroom-context/hooks/useAlgoliaSettings.js +3 -3
- package/build/newsroom-context/hooks/useAlgoliaSettings.js.map +1 -1
- package/build/newsroom-context/hooks/useCategories.js +3 -3
- package/build/newsroom-context/hooks/useCategories.js.map +1 -1
- package/build/newsroom-context/hooks/useCompanyInformation.js +3 -3
- package/build/newsroom-context/hooks/useCompanyInformation.js.map +1 -1
- package/build/newsroom-context/hooks/useCurrentLocale.js +3 -3
- package/build/newsroom-context/hooks/useCurrentLocale.js.map +1 -1
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js +9 -9
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js.map +1 -1
- package/build/newsroom-context/hooks/useGetTranslationUrl.js +17 -12
- package/build/newsroom-context/hooks/useGetTranslationUrl.js.map +1 -1
- package/build/newsroom-context/hooks/useLanguages.js +3 -3
- package/build/newsroom-context/hooks/useLanguages.js.map +1 -1
- package/build/newsroom-context/hooks/useNewsroom.js +3 -3
- package/build/newsroom-context/hooks/useNewsroom.js.map +1 -1
- package/build/newsroom-context/hooks/useNewsroomContext.js +4 -4
- package/build/newsroom-context/hooks/useNewsroomContext.js.map +1 -1
- package/build/newsroom-context/hooks/useSelectedCategory.js +3 -3
- package/build/newsroom-context/hooks/useSelectedCategory.js.map +1 -1
- package/build/newsroom-context/hooks/useSelectedStory.d.ts +1 -1
- package/build/newsroom-context/hooks/useSelectedStory.js +3 -3
- package/build/newsroom-context/hooks/useSelectedStory.js.map +1 -1
- package/build/types.d.ts +2 -2
- package/package.json +1 -1
- package/src/data-fetching/api/queries.ts +2 -2
- package/src/newsroom-context/context.tsx +8 -8
- package/src/newsroom-context/hooks/useGetTranslationUrl.ts +2 -2
- package/src/types.ts +2 -1
- package/build/data-fetching/getStoryPublicationDate.jsx.map +0 -1
- package/build/newsroom-context/context.jsx +0 -26
- package/build/newsroom-context/context.jsx.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# NextJS Prezly Theme Kit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
This library is a collection of data-fetching functions, hooks and utility functions to abstract some of the under-the-hood logic used by Prezly newsrooms and help developers create themes with [Next.JS] much faster with little boilerplate required.
|
|
7
|
+
|
|
8
|
+
The package is built with [Typescript] on top of [Prezly SDK].
|
|
4
9
|
|
|
5
10
|
## Adding the library to your NextJS theme
|
|
6
11
|
|
|
@@ -12,8 +17,8 @@ npm install --save @prezly/theme-kit-nextjs
|
|
|
12
17
|
|
|
13
18
|
#### peerDependencies
|
|
14
19
|
|
|
15
|
-
This library is intended to be used with
|
|
16
|
-
If you're starting from scratch, use [
|
|
20
|
+
This library is intended to be used with [Next.JS] applications, so it requires `next`, `react` and `react-dom` to work. These should already be installed if you have an existing NextJS app.
|
|
21
|
+
If you're starting from scratch, use [create-next-app] to quick-start the project.
|
|
17
22
|
|
|
18
23
|
To keep things fresh, we require at least NextJS 12 and React 17.
|
|
19
24
|
|
|
@@ -23,6 +28,193 @@ npm install --save next react react-dom
|
|
|
23
28
|
npm install --save-dev @types/react @types/react-dom
|
|
24
29
|
```
|
|
25
30
|
|
|
31
|
+
### .env
|
|
32
|
+
|
|
33
|
+
Prezly themes use two ways of getting base environment variables:
|
|
34
|
+
- Getting variables straight from `.env` file
|
|
35
|
+
- Extracting variables from HTTP headers (when hosted on the Prezly infrastructure)
|
|
36
|
+
|
|
37
|
+
For local development, and for self-hosted themes, you can only use the former option. Add these two variables to your `.env` file:
|
|
38
|
+
```
|
|
39
|
+
PREZLY_ACCESS_TOKEN=your access token
|
|
40
|
+
PREZLY_NEWSROOM_UUID=your newsroom UUID
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
If you don't have these credentials, you can use one of our [testing newsrooms credentials](https://github.com/prezly/theme-nextjs-starter#testingtoken).
|
|
44
|
+
|
|
45
|
+
### next.config.js
|
|
46
|
+
|
|
47
|
+
In a base setup, you don't have to make any changes to your config.
|
|
48
|
+
Depending on your use-case, you might need to make some additions to your base config.
|
|
49
|
+
|
|
50
|
+
#### Using next/image to display images served from Prezly
|
|
51
|
+
|
|
52
|
+
We provide `@prezly/uploadcare-image` package to conviniently display images inside Prezly content, and this is the recommended way to display images in your theme.
|
|
53
|
+
However, if you need to use the default `next/image` component, you will need to add our CDN url to image domains settings:
|
|
54
|
+
```js
|
|
55
|
+
module.exports = {
|
|
56
|
+
/* ...your next config... */
|
|
57
|
+
images: {
|
|
58
|
+
domains: ['cdn.uc.assets.prezly.com'],
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
#### Multi-language support
|
|
64
|
+
|
|
65
|
+
If you want to support multi-language in your theme, you'll need to make additional changes to the file:
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
const { DUMMY_DEFAULT_LOCALE } = require('@prezly/theme-kit-nextjs');
|
|
69
|
+
const locales = require('@prezly/theme-kit-nextjs/build/intl/localeConfig');
|
|
70
|
+
|
|
71
|
+
module.exports = {
|
|
72
|
+
/* ...your next config... */
|
|
73
|
+
|
|
74
|
+
i18n: {
|
|
75
|
+
// These are all the locales you want to support in
|
|
76
|
+
// your application
|
|
77
|
+
locales: [...locales, DUMMY_DEFAULT_LOCALE],
|
|
78
|
+
// This is the default locale you want to be used when visiting
|
|
79
|
+
// a non-locale prefixed path e.g. `/media`
|
|
80
|
+
// We use Pseudo locale used for localization testing, to reliably determine if we need to fallback to the default newsroom language
|
|
81
|
+
defaultLocale: DUMMY_DEFAULT_LOCALE,
|
|
82
|
+
// Default locale detection is disabled, since the locales would be determined by Prezly API
|
|
83
|
+
localeDetection: false,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### pages/_app.tsx
|
|
89
|
+
|
|
90
|
+
In order to provide all the necessary data to the entire application, we provde the `NewsroomContextProvider` component, which accepts props provided by our data-fetching methods (which you'll need to call in each page's `getServerSideProps` method).
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
import { BasePageProps, NewsroomContextProvider } from '@prezly/theme-kit-nextjs';
|
|
94
|
+
import { AppProps } from 'next/app';
|
|
95
|
+
|
|
96
|
+
type AnyPageProps = Record<string, any>;
|
|
97
|
+
|
|
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;
|
|
113
|
+
|
|
114
|
+
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 */}
|
|
129
|
+
<Component {...customPageProps} />
|
|
130
|
+
</NewsroomContextProvider>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export default App;
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Page files (Server-side rendering)
|
|
138
|
+
|
|
139
|
+
Every page requires a bit of boilerplate code to set up.
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
import { BasePageProps, getBasePageProps, processRequest } from '@prezly/theme-kit-nextjs';
|
|
143
|
+
import { GetServerSideProps } from 'next';
|
|
144
|
+
import type { FunctionComponent } from 'react';
|
|
145
|
+
|
|
146
|
+
interface Props extends BasePageProps {
|
|
147
|
+
/* Additional props for this page */
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const Page: FunctionComponent<Props> = () => <>{/* Your display components */}</>;
|
|
151
|
+
|
|
152
|
+
export const getServerSideProps: GetServerSideProps<Props> = async (context) => {
|
|
153
|
+
const { api, basePageProps } = await getBasePageProps(context);
|
|
154
|
+
|
|
155
|
+
/* Your logic to get additional props for this page */
|
|
156
|
+
|
|
157
|
+
// '/' is the canonical URL of your page without locale prefix
|
|
158
|
+
return processRequest(context, basePageProps, '/', {
|
|
159
|
+
/* Additional props for this page */
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export default Page;
|
|
164
|
+
```
|
|
165
|
+
|
|
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
|
+
**Page display component**
|
|
179
|
+
```ts
|
|
180
|
+
const Page: FunctionComponent<Props> = () => <>{/* Your display components */}</>;
|
|
181
|
+
```
|
|
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.
|
|
183
|
+
|
|
184
|
+
**Data fetching**
|
|
185
|
+
```ts
|
|
186
|
+
const { api, basePageProps } = await getBasePageProps(context);
|
|
187
|
+
```
|
|
188
|
+
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
|
+
|
|
190
|
+
```ts
|
|
191
|
+
// '/' is the canonical URL of your page without locale prefix
|
|
192
|
+
return processRequest(context, basePageProps, '/', {
|
|
193
|
+
/* Additional props for this page */
|
|
194
|
+
});
|
|
195
|
+
```
|
|
196
|
+
This function returns the combined base props and your additional props, with some extra logic in between to handle locale URLs.
|
|
197
|
+
|
|
198
|
+
The third argument is required to properly handle locale redirects. It should contain the URL for the current page without locale prefixes (like `/`, `/media`, `/category/${category.slug}`.
|
|
199
|
+
|
|
200
|
+
----
|
|
201
|
+
|
|
202
|
+
## What's next
|
|
203
|
+
|
|
204
|
+
This kit is just a collection of building blocks, so it doesn't really force any page structure or guidelines on how to render the content.
|
|
205
|
+
You can learn more on how this kit can be used by checking the code of Prezly's themes:
|
|
206
|
+
- [Theme Starter](https://github.com/prezly/theme-nextjs-starter) - this is a bare-bones application created to demonstrate how to display the fetched content and recommended page structure
|
|
207
|
+
- [Bea Theme](https://github.com/prezly/theme-nextjs-bea) - this is our new fully-fledged theme available to all Prezly customers. It has lots of stuff on top, both in styling and in data logic.
|
|
208
|
+
|
|
209
|
+
You can also learn more about Prezly API by checking out typings in [Prezly SDK] package, and referring to the [Prezly API Docs]
|
|
210
|
+
|
|
26
211
|
----
|
|
27
212
|
|
|
28
213
|
Brought to you by [Prezly](https://www.prezly.com/?utm_source=github&utm_campaign=@prezly/theme-kit-nextjs).
|
|
214
|
+
|
|
215
|
+
[create-next-app]: https://nextjs.org/docs/api-reference/create-next-app
|
|
216
|
+
[Next.JS]: https://nextjs.org
|
|
217
|
+
[Prezly SDK]: https://www.npmjs.com/package/@prezly/sdk
|
|
218
|
+
[Prezly API Docs]: https://developers.prezly.com/docs/api
|
|
219
|
+
[Typescript]: https://www.typescriptlang.org
|
|
220
|
+
[Prezly Content React Renderer]: https://www.npmjs.com/package/@prezly/content-renderer-react-js
|
|
@@ -1,15 +1,65 @@
|
|
|
1
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
|
+
};
|
|
2
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
39
|
exports.getBasePageProps = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
40
|
+
var data_fetching_1 = require("../data-fetching");
|
|
41
|
+
function getBasePageProps(context, options) {
|
|
42
|
+
if (options === void 0) { options = {}; }
|
|
43
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
+
var request, locale, api, basePageProps, _a;
|
|
45
|
+
return __generator(this, function (_b) {
|
|
46
|
+
switch (_b.label) {
|
|
47
|
+
case 0:
|
|
48
|
+
request = context.req, locale = context.locale;
|
|
49
|
+
api = (0, data_fetching_1.getPrezlyApi)(request);
|
|
50
|
+
return [4 /*yield*/, api.getBasePageProps(request, locale)];
|
|
51
|
+
case 1:
|
|
52
|
+
basePageProps = _b.sent();
|
|
53
|
+
if (!options.loadHomepageContacts) return [3 /*break*/, 3];
|
|
54
|
+
_a = basePageProps;
|
|
55
|
+
return [4 /*yield*/, api.getNewsroomContacts()];
|
|
56
|
+
case 2:
|
|
57
|
+
_a.contacts = _b.sent();
|
|
58
|
+
_b.label = 3;
|
|
59
|
+
case 3: return [2 /*return*/, { api: api, basePageProps: basePageProps }];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
13
63
|
}
|
|
14
64
|
exports.getBasePageProps = getBasePageProps;
|
|
15
65
|
//# sourceMappingURL=getBasePageProps.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBasePageProps.js","sourceRoot":"","sources":["../../src/adapter-nextjs/getBasePageProps.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getBasePageProps.js","sourceRoot":"","sources":["../../src/adapter-nextjs/getBasePageProps.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,kDAAgD;AAMhD,SAAsB,gBAAgB,CAClC,OAAkC,EAClC,OAAkC;IAAlC,wBAAA,EAAA,YAAkC;;;;;;oBAErB,OAAO,GAAa,OAAO,IAApB,EAAE,MAAM,GAAK,OAAO,OAAZ,CAAa;oBAEnC,GAAG,GAAG,IAAA,4BAAY,EAAC,OAAO,CAAC,CAAC;oBACZ,qBAAM,GAAG,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,EAAA;;oBAA3D,aAAa,GAAG,SAA2C;yBAE7D,OAAO,CAAC,oBAAoB,EAA5B,wBAA4B;oBAC5B,KAAA,aAAa,CAAA;oBAAY,qBAAM,GAAG,CAAC,mBAAmB,EAAE,EAAA;;oBAAxD,GAAc,QAAQ,GAAG,SAA+B,CAAC;;wBAG7D,sBAAO,EAAE,GAAG,KAAA,EAAE,aAAa,eAAA,EAAE,EAAC;;;;CACjC;AAdD,4CAcC"}
|
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.processRequest = void 0;
|
|
4
|
-
|
|
15
|
+
var intl_1 = require("../intl");
|
|
5
16
|
function processRequest(context, basePageProps, canonicalUrl, customProps) {
|
|
6
|
-
|
|
17
|
+
var locale = context.locale, query = context.query;
|
|
7
18
|
if (!basePageProps.localeResolved) {
|
|
8
19
|
return { notFound: true };
|
|
9
20
|
}
|
|
10
21
|
if (canonicalUrl) {
|
|
11
|
-
|
|
22
|
+
var redirect = (0, intl_1.getRedirectToCanonicalLocale)(basePageProps, locale, canonicalUrl, query);
|
|
12
23
|
if (redirect) {
|
|
13
|
-
return { redirect };
|
|
24
|
+
return { redirect: redirect };
|
|
14
25
|
}
|
|
15
26
|
}
|
|
16
27
|
return {
|
|
17
|
-
props: {
|
|
18
|
-
...basePageProps,
|
|
19
|
-
...customProps,
|
|
20
|
-
},
|
|
28
|
+
props: __assign(__assign({}, basePageProps), customProps),
|
|
21
29
|
};
|
|
22
30
|
}
|
|
23
31
|
exports.processRequest = processRequest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processRequest.js","sourceRoot":"","sources":["../../src/adapter-nextjs/processRequest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"processRequest.js","sourceRoot":"","sources":["../../src/adapter-nextjs/processRequest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,gCAAuD;AAGvD,SAAgB,cAAc,CAC1B,OAAkC,EAClC,aAA4B,EAC5B,YAAqB,EACrB,WAA8C;IAEtC,IAAA,MAAM,GAAY,OAAO,OAAnB,EAAE,KAAK,GAAK,OAAO,MAAZ,CAAa;IAElC,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE;QAC/B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;KAC7B;IAED,IAAI,YAAY,EAAE;QACd,IAAM,QAAQ,GAAG,IAAA,mCAA4B,EAAC,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;QAC1F,IAAI,QAAQ,EAAE;YACV,OAAO,EAAE,QAAQ,UAAA,EAAE,CAAC;SACvB;KACJ;IAED,OAAO;QACH,KAAK,EAAE,sBACA,aAAa,GACb,WAAW,CACR;KACb,CAAC;AACN,CAAC;AAzBD,wCAyBC"}
|