@prezly/theme-kit-nextjs 1.1.2 → 1.1.5-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 +167 -3
- 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/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 +8 -13
- package/build/newsroom-context/context.js +18 -26
- 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/intl/locale.ts +1 -4
- package/src/newsroom-context/context.tsx +17 -20
- 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 +14 -14
- package/src/newsroom-context/hooks/useNewsroomContext.ts +2 -2
- package/src/newsroom-context/index.ts +1 -1
- package/src/types.ts +9 -31
- 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
|
@@ -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,165 @@ 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, 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
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
import { NewsroomContextProvider, PageProps } from '@prezly/theme-kit-nextjs';
|
|
94
|
+
import type { AppProps } from 'next/app';
|
|
95
|
+
|
|
96
|
+
type AnyPageProps = Record<string, any>;
|
|
97
|
+
|
|
98
|
+
function App({ Component, pageProps }: AppProps<AnyPageProps>) {
|
|
99
|
+
const { newsroomContextProps, ...customPageProps } = pageProps as PageProps & AnyPageProps;
|
|
100
|
+
|
|
101
|
+
/* eslint-disable react/jsx-props-no-spreading */
|
|
102
|
+
return (
|
|
103
|
+
<NewsroomContextProvider {...newsroomContextProps}>
|
|
104
|
+
<Component {...customPageProps} />
|
|
105
|
+
</NewsroomContextProvider>
|
|
106
|
+
);
|
|
107
|
+
/* eslint-enable react/jsx-props-no-spreading */
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export default App;
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Page files (Server-side rendering)
|
|
114
|
+
|
|
115
|
+
Every page requires a bit of boilerplate code to set up.
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
import { getNewsroomServerSideProps, processRequest } from '@prezly/theme-kit-nextjs';
|
|
119
|
+
import type { GetServerSideProps } from 'next';
|
|
120
|
+
import type { FunctionComponent } from 'react';
|
|
121
|
+
|
|
122
|
+
interface Props {
|
|
123
|
+
myProp: string;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const Page: FunctionComponent<Props> = ({ myProp }) => <p>{myProp}</p>;
|
|
127
|
+
|
|
128
|
+
export const getServerSideProps: GetServerSideProps<Props> = async (context) => {
|
|
129
|
+
const { api, serverSideProps } = await getNewsroomServerSideProps(context);
|
|
130
|
+
|
|
131
|
+
/* Your logic to get additional props for this page */
|
|
132
|
+
|
|
133
|
+
return processRequest(
|
|
134
|
+
context,
|
|
135
|
+
{
|
|
136
|
+
...serverSideProps,
|
|
137
|
+
myProp: 'My Custom Prop',
|
|
138
|
+
},
|
|
139
|
+
'/',
|
|
140
|
+
);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export default Page;
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Page display component**
|
|
147
|
+
```tsx
|
|
148
|
+
const Page: FunctionComponent<Props> = ({ myProp }) => <p>{myProp}</p>;
|
|
149
|
+
```
|
|
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.
|
|
151
|
+
|
|
152
|
+
**Data fetching**
|
|
153
|
+
```ts
|
|
154
|
+
const { api, serverSideProps } = await getNewsroomServerSideProps(context);
|
|
155
|
+
```
|
|
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.
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
return processRequest(
|
|
160
|
+
context,
|
|
161
|
+
{
|
|
162
|
+
...serverSideProps,
|
|
163
|
+
myProp: 'My Custom Prop',
|
|
164
|
+
},
|
|
165
|
+
'/',
|
|
166
|
+
);
|
|
167
|
+
```
|
|
168
|
+
This function returns the combined base props and your additional props, with some extra logic in between to handle locale URLs.
|
|
169
|
+
|
|
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.
|
|
171
|
+
|
|
172
|
+
----
|
|
173
|
+
|
|
174
|
+
## What's next
|
|
175
|
+
|
|
176
|
+
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.
|
|
177
|
+
You can learn more on how this kit can be used by checking the code of Prezly's themes:
|
|
178
|
+
- [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
|
|
179
|
+
- [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.
|
|
180
|
+
|
|
181
|
+
You can also learn more about Prezly API by checking out typings in [Prezly SDK] package, and referring to the [Prezly API Docs]
|
|
182
|
+
|
|
26
183
|
----
|
|
27
184
|
|
|
28
185
|
Brought to you by [Prezly](https://www.prezly.com/?utm_source=github&utm_campaign=@prezly/theme-kit-nextjs).
|
|
186
|
+
|
|
187
|
+
[create-next-app]: https://nextjs.org/docs/api-reference/create-next-app
|
|
188
|
+
[Next.JS]: https://nextjs.org
|
|
189
|
+
[Prezly SDK]: https://www.npmjs.com/package/@prezly/sdk
|
|
190
|
+
[Prezly API Docs]: https://developers.prezly.com/docs/api
|
|
191
|
+
[Typescript]: https://www.typescriptlang.org
|
|
192
|
+
[Prezly Content React Renderer]: https://www.npmjs.com/package/@prezly/content-renderer-react-js
|
|
@@ -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,OA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G,IAAA,iCAAqB,EAAC,SAAS,EAAE,MAAM,CAAC,CAAC;wBAE9D,eAAe,GAAG,IAAA,uCAAkB,EAAC,OAAO,CAAC,CAAC;wBAEpD,sBAAO;gCACH,oBAAoB,EAAE;oCAClB,QAAQ,UAAA;oCACR,kBAAkB,oBAAA;oCAClB,UAAU,YAAA;oCACV,SAAS,WAAA;oCACT,UAAU,YAAA;oCACV,WAAW,aAAA;oCACX,eAAe,iBAAA;iCAClB;gCACD,cAAc,EAAE,OAAO,CAAC,eAAe,CAAC;6BAC3C,EAAC;;;;KACL;IACL,gBAAC;AAAD,CAAC,AAjMD,IAiMC;AAjMY,8BAAS"}
|
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
|
+
{"version":3,"file":"locale.js","sourceRoot":"","sources":["../../src/intl/locale.ts"],"names":[],"mappings":";;;AACA,2CAAwD;AAExD,+CAA8C;AAEjC,QAAA,cAAc,GAAG,IAAI,CAAC;AACtB,QAAA,oBAAoB,GAAG,UAAU,CAAC;AAE/C,IAAM,iBAAiB,GAAG;IACtB,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,OAAO;IACP,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,OAAO;IACP,OAAO;CACV,CAAC;AAEF,SAAgB,yBAAyB,CAAC,MAAoB;IAC1D,IAAM,aAAa,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;IAE5C,IAAM,iBAAiB,GACnB,aAAa,CAAC,MAAM,IAAI,CAAC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B,kBAAkB,CAAC,MAAoB;IACnD,IAAM,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,EAAE,CAAC;IAE3D,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE;QAClD,OAAO,KAAK,CAAC;KAChB;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AARD,gDAQC"}
|
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
import type { Category, Newsroom, NewsroomCompanyInformation, NewsroomContact, NewsroomLanguageSettings, NewsroomThemePreset
|
|
2
|
-
import
|
|
1
|
+
import type { Category, ExtendedStory, Newsroom, NewsroomCompanyInformation, NewsroomContact, NewsroomLanguageSettings, NewsroomThemePreset } from '@prezly/sdk';
|
|
2
|
+
import { FunctionComponent } from 'react';
|
|
3
3
|
import type { AlgoliaSettings } from '../data-fetching';
|
|
4
4
|
import { LocaleObject } from '../intl';
|
|
5
|
-
|
|
6
|
-
export interface INewsroomContext {
|
|
5
|
+
export interface NewsroomContextType {
|
|
7
6
|
newsroom: Newsroom;
|
|
8
7
|
companyInformation: NewsroomCompanyInformation;
|
|
9
8
|
categories: Category[];
|
|
10
9
|
contacts?: NewsroomContact[];
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
currentCategory?: Category;
|
|
11
|
+
currentStory?: ExtendedStory;
|
|
13
12
|
languages: NewsroomLanguageSettings[];
|
|
14
13
|
locale: LocaleObject;
|
|
15
|
-
hasError?: boolean;
|
|
16
14
|
themePreset: NewsroomThemePreset;
|
|
17
15
|
algoliaSettings: AlgoliaSettings;
|
|
18
16
|
}
|
|
19
|
-
interface
|
|
20
|
-
isTrackingEnabled?: boolean;
|
|
17
|
+
export interface NewsroomContextProps extends Omit<NewsroomContextType, 'locale'> {
|
|
21
18
|
localeCode: string;
|
|
22
|
-
translations?: Translations;
|
|
23
19
|
}
|
|
24
|
-
export declare const NewsroomContext:
|
|
25
|
-
export declare const NewsroomContextProvider: FunctionComponent<
|
|
26
|
-
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,
|
|
28
|
-
var locale = (0, react_1.useMemo)(function () { return intl_1.LocaleObject.fromAnyCode(localeCode ||
|
|
29
|
-
return (
|
|
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;
|
|
21
|
+
var locale = (0, react_1.useMemo)(function () { return intl_1.LocaleObject.fromAnyCode(localeCode || intl_1.DEFAULT_LOCALE); }, [localeCode]);
|
|
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"}
|