@prezly/theme-kit-nextjs 1.6.3 → 1.6.4-2
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 +30 -0
- package/build/adapter-nextjs/getNewsroomServerSideProps.js +9 -63
- package/build/adapter-nextjs/getNewsroomServerSideProps.js.map +1 -1
- package/build/adapter-nextjs/index.js +2 -14
- package/build/adapter-nextjs/index.js.map +1 -1
- package/build/adapter-nextjs/processRequest.js +10 -25
- package/build/adapter-nextjs/processRequest.js.map +1 -1
- package/build/components-nextjs/PageSeo/PageSeo.d.ts +12 -0
- package/build/components-nextjs/PageSeo/PageSeo.js +74 -0
- package/build/components-nextjs/PageSeo/PageSeo.js.map +1 -0
- package/build/components-nextjs/PageSeo/index.d.ts +2 -0
- package/build/components-nextjs/PageSeo/index.js +3 -0
- package/build/components-nextjs/PageSeo/index.js.map +1 -0
- package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.d.ts +1 -0
- package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js +7 -0
- package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js.map +1 -0
- package/build/components-nextjs/PageSeo/lib/types.d.ts +4 -0
- package/build/components-nextjs/PageSeo/lib/types.js +2 -0
- package/build/components-nextjs/PageSeo/lib/types.js.map +1 -0
- package/build/components-nextjs/Sitemap/SitemapBuilder.d.ts +11 -0
- package/build/components-nextjs/Sitemap/SitemapBuilder.js +47 -0
- package/build/components-nextjs/Sitemap/SitemapBuilder.js.map +1 -0
- package/build/components-nextjs/Sitemap/createPaths.d.ts +2 -0
- package/build/components-nextjs/Sitemap/createPaths.js +15 -0
- package/build/components-nextjs/Sitemap/createPaths.js.map +1 -0
- package/build/components-nextjs/Sitemap/getInitialProps.d.ts +2 -0
- package/build/components-nextjs/Sitemap/getInitialProps.js +26 -0
- package/build/components-nextjs/Sitemap/getInitialProps.js.map +1 -0
- package/build/components-nextjs/Sitemap/index.d.ts +4 -0
- package/build/components-nextjs/Sitemap/index.js +5 -0
- package/build/components-nextjs/Sitemap/index.js.map +1 -0
- package/build/components-nextjs/Sitemap/types.d.ts +5 -0
- package/build/components-nextjs/Sitemap/types.js +2 -0
- package/build/components-nextjs/Sitemap/types.js.map +1 -0
- package/build/components-nextjs/StorySeo/StorySeo.d.ts +11 -0
- package/build/components-nextjs/StorySeo/StorySeo.js +39 -0
- package/build/components-nextjs/StorySeo/StorySeo.js.map +1 -0
- package/build/components-nextjs/StorySeo/index.d.ts +1 -0
- package/build/components-nextjs/StorySeo/index.js +2 -0
- package/build/components-nextjs/StorySeo/index.js.map +1 -0
- package/build/components-nextjs/index.d.ts +3 -0
- package/build/components-nextjs/index.js +4 -0
- package/build/components-nextjs/index.js.map +1 -0
- package/build/data-fetching/api/PrezlyApi.js +132 -297
- package/build/data-fetching/api/PrezlyApi.js.map +1 -1
- package/build/data-fetching/api/getPrezlyApi.js +5 -9
- package/build/data-fetching/api/getPrezlyApi.js.map +1 -1
- package/build/data-fetching/api/index.js +2 -14
- package/build/data-fetching/api/index.js.map +1 -1
- package/build/data-fetching/api/languages.js +43 -85
- package/build/data-fetching/api/languages.js.map +1 -1
- package/build/data-fetching/api/queries.js +13 -45
- package/build/data-fetching/api/queries.js.map +1 -1
- package/build/data-fetching/constants.js +2 -5
- package/build/data-fetching/constants.js.map +1 -1
- package/build/data-fetching/getAssetsUrl.js +3 -7
- package/build/data-fetching/getAssetsUrl.js.map +1 -1
- package/build/data-fetching/getLocalizedCategoryData.js +15 -32
- package/build/data-fetching/getLocalizedCategoryData.js.map +1 -1
- package/build/data-fetching/getNewsroomLogoUrl.js +6 -12
- package/build/data-fetching/getNewsroomLogoUrl.js.map +1 -1
- package/build/data-fetching/getPrivacyPortalUrl.js +3 -7
- package/build/data-fetching/getPrivacyPortalUrl.js.map +1 -1
- package/build/data-fetching/getStoryPublicationDate.js +2 -6
- package/build/data-fetching/getStoryPublicationDate.js.map +1 -1
- package/build/data-fetching/getUploadcareGroupUrl.js +3 -7
- package/build/data-fetching/getUploadcareGroupUrl.js.map +1 -1
- package/build/data-fetching/index.js +10 -22
- package/build/data-fetching/index.js.map +1 -1
- package/build/data-fetching/lib/getAlgoliaSettings.js +6 -10
- package/build/data-fetching/lib/getAlgoliaSettings.js.map +1 -1
- package/build/data-fetching/lib/getEnvVariables.js +11 -29
- package/build/data-fetching/lib/getEnvVariables.js.map +1 -1
- package/build/data-fetching/lib/index.js +1 -5
- package/build/data-fetching/lib/index.js.map +1 -1
- package/build/data-fetching/types.js +1 -2
- package/build/index.d.ts +2 -0
- package/build/index.js +7 -17
- package/build/index.js.map +1 -1
- package/build/infinite-loading/apiHandlers/fetchGalleries.d.ts +2 -0
- package/build/infinite-loading/apiHandlers/fetchGalleries.js +19 -0
- package/build/infinite-loading/apiHandlers/fetchGalleries.js.map +1 -0
- package/build/infinite-loading/apiHandlers/fetchStories.d.ts +2 -0
- package/build/infinite-loading/apiHandlers/fetchStories.js +21 -0
- package/build/infinite-loading/apiHandlers/fetchStories.js.map +1 -0
- package/build/infinite-loading/apiHandlers/index.d.ts +2 -0
- package/build/infinite-loading/apiHandlers/index.js +3 -0
- package/build/infinite-loading/apiHandlers/index.js.map +1 -0
- package/build/infinite-loading/index.d.ts +5 -0
- package/build/infinite-loading/index.js +6 -0
- package/build/infinite-loading/index.js.map +1 -0
- package/build/infinite-loading/types.d.ts +5 -0
- package/build/infinite-loading/types.js +2 -0
- package/build/infinite-loading/types.js.map +1 -0
- package/build/infinite-loading/useInfiniteGalleriesLoading.d.ts +13 -0
- package/build/infinite-loading/useInfiniteGalleriesLoading.js +40 -0
- package/build/infinite-loading/useInfiniteGalleriesLoading.js.map +1 -0
- package/build/infinite-loading/useInfiniteLoading.d.ts +16 -0
- package/build/infinite-loading/useInfiniteLoading.js +39 -0
- package/build/infinite-loading/useInfiniteLoading.js.map +1 -0
- package/build/infinite-loading/useInfiniteStoriesLoading.d.ts +13 -0
- package/build/infinite-loading/useInfiniteStoriesLoading.js +53 -0
- package/build/infinite-loading/useInfiniteStoriesLoading.js.map +1 -0
- package/build/intl/index.d.ts +2 -1
- package/build/intl/index.js +5 -21
- package/build/intl/index.js.map +1 -1
- package/build/intl/lang.js +4 -11
- package/build/intl/lang.js.map +1 -1
- package/build/intl/locale.js +21 -27
- package/build/intl/locale.js.map +1 -1
- package/build/intl/localeConfig.d.ts +1 -2
- package/build/intl/localeConfig.js +8 -30
- package/build/intl/localeConfig.js.map +1 -1
- package/build/intl/localeList.d.ts +4 -56
- package/build/intl/localeList.js +1 -2
- package/build/intl/localeList.js.map +1 -1
- package/build/intl/localeObject.js +30 -49
- package/build/intl/localeObject.js.map +1 -1
- package/build/newsroom-context/context.js +18 -34
- package/build/newsroom-context/context.js.map +1 -1
- package/build/newsroom-context/hooks/index.js +11 -23
- package/build/newsroom-context/hooks/index.js.map +1 -1
- package/build/newsroom-context/hooks/useAlgoliaSettings.js +3 -7
- package/build/newsroom-context/hooks/useAlgoliaSettings.js.map +1 -1
- package/build/newsroom-context/hooks/useCategories.js +3 -7
- package/build/newsroom-context/hooks/useCategories.js.map +1 -1
- package/build/newsroom-context/hooks/useCompanyInformation.js +3 -7
- package/build/newsroom-context/hooks/useCompanyInformation.js.map +1 -1
- package/build/newsroom-context/hooks/useCurrentCategory.js +3 -7
- package/build/newsroom-context/hooks/useCurrentCategory.js.map +1 -1
- package/build/newsroom-context/hooks/useCurrentLocale.js +3 -7
- package/build/newsroom-context/hooks/useCurrentLocale.js.map +1 -1
- package/build/newsroom-context/hooks/useCurrentStory.js +3 -7
- package/build/newsroom-context/hooks/useCurrentStory.js.map +1 -1
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js +11 -15
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js.map +1 -1
- package/build/newsroom-context/hooks/useGetTranslationUrl.js +15 -24
- package/build/newsroom-context/hooks/useGetTranslationUrl.js.map +1 -1
- package/build/newsroom-context/hooks/useLanguages.js +3 -7
- package/build/newsroom-context/hooks/useLanguages.js.map +1 -1
- package/build/newsroom-context/hooks/useNewsroom.js +3 -7
- package/build/newsroom-context/hooks/useNewsroom.js.map +1 -1
- package/build/newsroom-context/hooks/useNewsroomContext.js +4 -8
- package/build/newsroom-context/hooks/useNewsroomContext.js.map +1 -1
- package/build/newsroom-context/index.js +2 -17
- package/build/newsroom-context/index.js.map +1 -1
- package/build/types.js +1 -2
- package/package.json +6 -3
- package/src/components-nextjs/PageSeo/PageSeo.tsx +123 -0
- package/src/components-nextjs/PageSeo/index.ts +2 -0
- package/src/components-nextjs/PageSeo/lib/getAbsoluteUrl.ts +7 -0
- package/src/components-nextjs/PageSeo/lib/types.ts +4 -0
- package/src/components-nextjs/Sitemap/SitemapBuilder.ts +56 -0
- package/src/components-nextjs/Sitemap/createPaths.ts +21 -0
- package/src/components-nextjs/Sitemap/getInitialProps.ts +37 -0
- package/src/components-nextjs/Sitemap/index.ts +5 -0
- package/src/components-nextjs/Sitemap/types.ts +5 -0
- package/src/components-nextjs/StorySeo/StorySeo.tsx +68 -0
- package/src/components-nextjs/StorySeo/index.ts +1 -0
- package/src/components-nextjs/index.ts +3 -0
- package/src/index.ts +2 -0
- package/src/infinite-loading/apiHandlers/fetchGalleries.ts +24 -0
- package/src/infinite-loading/apiHandlers/fetchStories.ts +26 -0
- package/src/infinite-loading/apiHandlers/index.ts +2 -0
- package/src/infinite-loading/index.ts +5 -0
- package/src/infinite-loading/types.ts +5 -0
- package/src/infinite-loading/useInfiniteGalleriesLoading.ts +53 -0
- package/src/infinite-loading/useInfiniteLoading.ts +66 -0
- package/src/infinite-loading/useInfiniteStoriesLoading.ts +81 -0
- package/src/intl/index.ts +2 -1
- package/src/intl/{localeConfig.js → localeConfig.ts} +3 -3
- package/src/intl/{localeList.js → localeList.ts} +1 -1
- package/src/intl/localeObject.ts +1 -1
package/README.md
CHANGED
|
@@ -173,6 +173,36 @@ This function returns the combined base props and your additional props, with so
|
|
|
173
173
|
|
|
174
174
|
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.
|
|
175
175
|
|
|
176
|
+
### SEO Helper components
|
|
177
|
+
|
|
178
|
+
This library provides two components: [PageSeo](./tree/main/src/components-nextjs/PageSeo) and [StorySeo](./tree/main/src/components-nextjs/StorySeo), both based on the [next-seo](https://github.com/garmeeh/next-seo) library. They consume information from the `NewsroomContext` and provide all the necessary tags for your pages, with correct social preview, as well as JsonLD and OpenGraph data for your stories. You can also override the parameters for `PageSeo` component, these will be passed straight to `NextSeo` component. See the JSDoc comments on the exported components to get instructions on their usage.
|
|
179
|
+
|
|
180
|
+
### Auto-generated Sitemap
|
|
181
|
+
|
|
182
|
+
This kit can also help you with building your Sitemap automatically. Here's what you need to get started:
|
|
183
|
+
|
|
184
|
+
1. Create a sitemap page file: `/pages/sitemap.xml.ts`
|
|
185
|
+
2. Use this code to display the default Sitemap built with your Newsroom stories:
|
|
186
|
+
```ts
|
|
187
|
+
import type { NextPage } from 'next';
|
|
188
|
+
import { getSitemapInitialProps } from '@prezly/theme-kit-nextjs';
|
|
189
|
+
|
|
190
|
+
const Sitemap: NextPage = () => null;
|
|
191
|
+
|
|
192
|
+
Sitemap.getInitialProps = getSitemapInitialProps;
|
|
193
|
+
|
|
194
|
+
export default Sitemap;
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
You can also add additional paths to the sitemap by passing them as a second argument to `getSitemapInitialProps`, like so:
|
|
198
|
+
```ts
|
|
199
|
+
const additionalPaths = ['/my-custom-path'];
|
|
200
|
+
|
|
201
|
+
Sitemap.getInitialProps = (ctx: NextPageContext) => getSitemapInitialProps(ctx, additionalPaths);
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
If you need a more customized approach, you can build your own Sitemap by extending the `SitemapBuilder` class exported from the library, as well as referring to the code in the [Sitemap](./tree/main/src/components-nextjs/Sitemap) component directory.
|
|
205
|
+
|
|
176
206
|
----
|
|
177
207
|
|
|
178
208
|
## What's next
|
|
@@ -1,69 +1,15 @@
|
|
|
1
|
-
|
|
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
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.getNewsroomServerSideProps = void 0;
|
|
40
|
-
var data_fetching_1 = require("../data-fetching");
|
|
1
|
+
import { getPrezlyApi } from '../data-fetching';
|
|
41
2
|
/**
|
|
42
3
|
* Use this function in your `getServerSideProps` page methods to retrieve the data necessary for the NewsroomContextProvider and `processRequest` function.
|
|
43
4
|
* See README for usage examples.
|
|
44
5
|
*/
|
|
45
|
-
function getNewsroomServerSideProps(context, options) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
api = (0, data_fetching_1.getPrezlyApi)(request);
|
|
54
|
-
return [4 /*yield*/, api.getNewsroomServerSideProps(request, locale, options.story)];
|
|
55
|
-
case 1:
|
|
56
|
-
serverSideProps = _b.sent();
|
|
57
|
-
if (!options.loadHomepageContacts) return [3 /*break*/, 3];
|
|
58
|
-
_a = serverSideProps.newsroomContextProps;
|
|
59
|
-
return [4 /*yield*/, api.getNewsroomContacts()];
|
|
60
|
-
case 2:
|
|
61
|
-
_a.contacts = _b.sent();
|
|
62
|
-
_b.label = 3;
|
|
63
|
-
case 3: return [2 /*return*/, { api: api, serverSideProps: serverSideProps }];
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
});
|
|
6
|
+
export async function getNewsroomServerSideProps(context, options = {}) {
|
|
7
|
+
const { req: request, locale } = context;
|
|
8
|
+
const api = getPrezlyApi(request);
|
|
9
|
+
const serverSideProps = await api.getNewsroomServerSideProps(request, locale, options.story);
|
|
10
|
+
if (options.loadHomepageContacts) {
|
|
11
|
+
serverSideProps.newsroomContextProps.contacts = await api.getNewsroomContacts();
|
|
12
|
+
}
|
|
13
|
+
return { api, serverSideProps };
|
|
67
14
|
}
|
|
68
|
-
exports.getNewsroomServerSideProps = getNewsroomServerSideProps;
|
|
69
15
|
//# sourceMappingURL=getNewsroomServerSideProps.js.map
|
|
@@ -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":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAOhD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC5C,OAAkC,EAClC,UAAmB,EAAE;IAErB,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAEzC,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IAClC,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"}
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./getNewsroomServerSideProps"), exports);
|
|
14
|
-
__exportStar(require("./processRequest"), exports);
|
|
1
|
+
export * from './getNewsroomServerSideProps';
|
|
2
|
+
export * from './processRequest';
|
|
15
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapter-nextjs/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapter-nextjs/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC"}
|
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.processRequest = void 0;
|
|
15
|
-
var data_fetching_1 = require("../data-fetching");
|
|
16
|
-
var intl_1 = require("../intl");
|
|
1
|
+
import { getShortestLocaleCode } from '../data-fetching';
|
|
2
|
+
import { getRedirectToCanonicalLocale, LocaleObject } from '../intl';
|
|
17
3
|
/**
|
|
18
4
|
* This function combines the props returned from `getNewsroomServerSideProps` and your optional custom props for the page.
|
|
19
5
|
* It also handles locale redirects, if `canonicalUrl` parameter is provided.
|
|
@@ -23,26 +9,25 @@ var intl_1 = require("../intl");
|
|
|
23
9
|
* @param props Object containing the return of `getNewsroomServerSideProps` and your optional custom props.
|
|
24
10
|
* @param canonicalUrl Optional: a canonical URL for the current page without locale part. If provided, locale redirects will be handled by the function.
|
|
25
11
|
*/
|
|
26
|
-
function processRequest(context, props, canonicalUrl) {
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
export function processRequest(context, props, canonicalUrl) {
|
|
13
|
+
const { locale: nextLocale, query } = context;
|
|
14
|
+
const { localeResolved, ...pageProps } = props;
|
|
29
15
|
// If no locale was provided by Next, it most likely means that the theme is not supporting multi-language.
|
|
30
16
|
// In that case we won't show 404 page.
|
|
31
17
|
if (!localeResolved && nextLocale) {
|
|
32
18
|
return { notFound: true };
|
|
33
19
|
}
|
|
34
20
|
if (canonicalUrl) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
21
|
+
const { languages, localeCode } = pageProps.newsroomContextProps;
|
|
22
|
+
const currentLocale = LocaleObject.fromAnyCode(localeCode);
|
|
23
|
+
const shortestLocaleCode = getShortestLocaleCode(languages, currentLocale);
|
|
24
|
+
const redirect = getRedirectToCanonicalLocale(shortestLocaleCode, nextLocale, canonicalUrl, query);
|
|
39
25
|
if (redirect) {
|
|
40
|
-
return { redirect
|
|
26
|
+
return { redirect };
|
|
41
27
|
}
|
|
42
28
|
}
|
|
43
29
|
return {
|
|
44
30
|
props: pageProps,
|
|
45
31
|
};
|
|
46
32
|
}
|
|
47
|
-
exports.processRequest = processRequest;
|
|
48
33
|
//# sourceMappingURL=processRequest.js.map
|
|
@@ -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,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,4BAA4B,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGrE;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAC1B,OAAkC,EAClC,KAA8C,EAC9C,YAAqB;IAErB,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,YAAY,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QAC3D,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;QAE3E,MAAM,QAAQ,GAAG,4BAA4B,CACzC,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"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { NextSeoProps } from 'next-seo';
|
|
3
|
+
declare type Props = NextSeoProps & {
|
|
4
|
+
imageUrl?: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* This component provides base page attributes for every Newsroom page.
|
|
8
|
+
* It depends on information from NewsroomContext, so the component should be placed inside the `NewsroomContextProvider`.
|
|
9
|
+
* You can pass additional props expected by NextSeo component to override any info that is provided by the NewsroomContext.
|
|
10
|
+
*/
|
|
11
|
+
export declare function PageSeo({ title, description, imageUrl, canonical, openGraph, twitter, ...nextSeoProps }: Props): JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { NextSeo } from 'next-seo';
|
|
3
|
+
import { useRouter } from 'next/router';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import { stripHtml } from 'string-strip-html';
|
|
6
|
+
import { getNewsroomLogoUrl, getUsedLanguages } from '../../data-fetching';
|
|
7
|
+
import { LocaleObject } from '../../intl';
|
|
8
|
+
import { useCompanyInformation, useCurrentLocale, useCurrentStory, useGetLinkLocaleSlug, useGetTranslationUrl, useLanguages, useNewsroom, } from '../../newsroom-context';
|
|
9
|
+
import { getAbsoluteUrl } from './lib/getAbsoluteUrl';
|
|
10
|
+
/**
|
|
11
|
+
* This component provides base page attributes for every Newsroom page.
|
|
12
|
+
* It depends on information from NewsroomContext, so the component should be placed inside the `NewsroomContextProvider`.
|
|
13
|
+
* You can pass additional props expected by NextSeo component to override any info that is provided by the NewsroomContext.
|
|
14
|
+
*/
|
|
15
|
+
export function PageSeo({ title, description, imageUrl, canonical, openGraph, twitter, ...nextSeoProps }) {
|
|
16
|
+
const companyInformation = useCompanyInformation();
|
|
17
|
+
const newsroom = useNewsroom();
|
|
18
|
+
const currentLocale = useCurrentLocale();
|
|
19
|
+
const languages = useLanguages();
|
|
20
|
+
const getTranslationUrl = useGetTranslationUrl();
|
|
21
|
+
const getLinkLocaleSlug = useGetLinkLocaleSlug();
|
|
22
|
+
const currentStory = useCurrentStory();
|
|
23
|
+
const { asPath } = useRouter();
|
|
24
|
+
const pageTitle = title || companyInformation.name;
|
|
25
|
+
const pageDescription = description || stripHtml(companyInformation.about).result;
|
|
26
|
+
const canonicalUrl = canonical || getAbsoluteUrl(asPath, newsroom.url, getLinkLocaleSlug(currentLocale));
|
|
27
|
+
const siteName = companyInformation.name;
|
|
28
|
+
const logoUrl = imageUrl || getNewsroomLogoUrl(newsroom);
|
|
29
|
+
const alternateLanguageLinks = useMemo(() => {
|
|
30
|
+
if (!languages.length) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
const alternateLanguages = getUsedLanguages(languages).filter((language) => language.code !== currentLocale.toUnderscoreCode());
|
|
34
|
+
return alternateLanguages
|
|
35
|
+
.map((language) => {
|
|
36
|
+
const locale = LocaleObject.fromAnyCode(language.code);
|
|
37
|
+
const translationLink = getTranslationUrl(locale, true);
|
|
38
|
+
if (!translationLink) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
hrefLang: locale.toHyphenCode(),
|
|
43
|
+
href: getAbsoluteUrl(translationLink, newsroom.url, currentStory && translationLink !== '/' ? false : getLinkLocaleSlug(locale)),
|
|
44
|
+
};
|
|
45
|
+
})
|
|
46
|
+
.filter(Boolean);
|
|
47
|
+
}, [
|
|
48
|
+
currentLocale,
|
|
49
|
+
getLinkLocaleSlug,
|
|
50
|
+
getTranslationUrl,
|
|
51
|
+
languages,
|
|
52
|
+
newsroom.url,
|
|
53
|
+
currentStory,
|
|
54
|
+
]);
|
|
55
|
+
return (_jsx(NextSeo, { title: pageTitle, description: pageDescription, canonical: canonicalUrl, openGraph: {
|
|
56
|
+
url: canonicalUrl,
|
|
57
|
+
title: pageTitle,
|
|
58
|
+
description: pageDescription,
|
|
59
|
+
locale: currentLocale.toUnderscoreCode(),
|
|
60
|
+
images: [
|
|
61
|
+
{
|
|
62
|
+
url: logoUrl,
|
|
63
|
+
alt: pageTitle,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
site_name: siteName,
|
|
67
|
+
...openGraph,
|
|
68
|
+
}, twitter: {
|
|
69
|
+
site: siteName,
|
|
70
|
+
cardType: 'summary',
|
|
71
|
+
...twitter,
|
|
72
|
+
}, additionalMetaTags: [{ name: 'twitter:image', content: logoUrl }], languageAlternates: alternateLanguageLinks, ...nextSeoProps }, void 0));
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=PageSeo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageSeo.js","sourceRoot":"","sources":["../../../src/components-nextjs/PageSeo/PageSeo.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EACH,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,WAAW,GACd,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAOtD;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,EACpB,KAAK,EACL,WAAW,EACX,QAAQ,EACR,SAAS,EACT,SAAS,EACT,OAAO,EACP,GAAG,YAAY,EACX;IACJ,MAAM,kBAAkB,GAAG,qBAAqB,EAAE,CAAC;IACnD,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;IACzC,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,MAAM,iBAAiB,GAAG,oBAAoB,EAAE,CAAC;IACjD,MAAM,iBAAiB,GAAG,oBAAoB,EAAE,CAAC;IACjD,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;IACvC,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,CAAC;IAE/B,MAAM,SAAS,GAAG,KAAK,IAAI,kBAAkB,CAAC,IAAI,CAAC;IACnD,MAAM,eAAe,GAAG,WAAW,IAAI,SAAS,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC;IAClF,MAAM,YAAY,GACd,SAAS,IAAI,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC,CAAC;IACxF,MAAM,QAAQ,GAAG,kBAAkB,CAAC,IAAI,CAAC;IACzC,MAAM,OAAO,GAAG,QAAQ,IAAI,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAEzD,MAAM,sBAAsB,GAA4B,OAAO,CAAC,GAAG,EAAE;QACjE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE;YACnB,OAAO,EAAE,CAAC;SACb;QAED,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC,MAAM,CACzD,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,aAAa,CAAC,gBAAgB,EAAE,CACnE,CAAC;QAEF,OAAO,kBAAkB;aACpB,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YACd,MAAM,MAAM,GAAG,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YAEvD,MAAM,eAAe,GAAG,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAExD,IAAI,CAAC,eAAe,EAAE;gBAClB,OAAO,SAAS,CAAC;aACpB;YAED,OAAO;gBACH,QAAQ,EAAE,MAAM,CAAC,YAAY,EAAE;gBAC/B,IAAI,EAAE,cAAc,CAChB,eAAe,EACf,QAAQ,CAAC,GAAG,EACZ,YAAY,IAAI,eAAe,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAC9E;aACJ,CAAC;QACN,CAAC,CAAC;aACD,MAAM,CAAwB,OAAc,CAAC,CAAC;IACvD,CAAC,EAAE;QACC,aAAa;QACb,iBAAiB;QACjB,iBAAiB;QACjB,SAAS;QACT,QAAQ,CAAC,GAAG;QACZ,YAAY;KACf,CAAC,CAAC;IAEH,OAAO,CACH,KAAC,OAAO,IACJ,KAAK,EAAE,SAAS,EAChB,WAAW,EAAE,eAAe,EAC5B,SAAS,EAAE,YAAY,EACvB,SAAS,EAAE;YACP,GAAG,EAAE,YAAY;YACjB,KAAK,EAAE,SAAS;YAChB,WAAW,EAAE,eAAe;YAC5B,MAAM,EAAE,aAAa,CAAC,gBAAgB,EAAE;YACxC,MAAM,EAAE;gBACJ;oBACI,GAAG,EAAE,OAAO;oBACZ,GAAG,EAAE,SAAS;iBACjB;aACJ;YACD,SAAS,EAAE,QAAQ;YACnB,GAAG,SAAS;SACf,EACD,OAAO,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,SAAS;YACnB,GAAG,OAAO;SACb,EACD,kBAAkB,EAAE,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EACjE,kBAAkB,EAAE,sBAAsB,KACtC,YAAY,WAClB,CACL,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components-nextjs/PageSeo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getAbsoluteUrl(path: string, origin: string, localeCode?: string | false): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Returns absolute URL based on the path and without any query parameters
|
|
2
|
+
export function getAbsoluteUrl(path, origin, localeCode) {
|
|
3
|
+
const url = new URL(`${localeCode ? `/${localeCode}` : ''}${path || '/'}`, origin);
|
|
4
|
+
url.search = '';
|
|
5
|
+
return url.toString();
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=getAbsoluteUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAbsoluteUrl.js","sourceRoot":"","sources":["../../../../src/components-nextjs/PageSeo/lib/getAbsoluteUrl.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,MAAc,EAAE,UAA2B;IACpF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,IAAI,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC;IACnF,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC;IAEhB,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components-nextjs/PageSeo/lib/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SitemapUrl } from './types';
|
|
2
|
+
export declare class SitemapBuilder {
|
|
3
|
+
private baseUrl;
|
|
4
|
+
private urls;
|
|
5
|
+
constructor(baseUrl: string);
|
|
6
|
+
addUrl(location: string): void;
|
|
7
|
+
private static guessFrequency;
|
|
8
|
+
private static guessPriority;
|
|
9
|
+
static serializeLocation(url: SitemapUrl): string;
|
|
10
|
+
serialize(): string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export class SitemapBuilder {
|
|
2
|
+
baseUrl;
|
|
3
|
+
urls = [];
|
|
4
|
+
constructor(baseUrl) {
|
|
5
|
+
this.baseUrl = baseUrl;
|
|
6
|
+
}
|
|
7
|
+
addUrl(location) {
|
|
8
|
+
this.urls.push({
|
|
9
|
+
location: this.baseUrl + location,
|
|
10
|
+
changeFrequency: SitemapBuilder.guessFrequency(location),
|
|
11
|
+
priority: SitemapBuilder.guessPriority(location),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
static guessFrequency(location) {
|
|
15
|
+
if (location === '/')
|
|
16
|
+
return 'daily';
|
|
17
|
+
return 'weekly';
|
|
18
|
+
}
|
|
19
|
+
static guessPriority(location) {
|
|
20
|
+
if (location === '/')
|
|
21
|
+
return '0.9';
|
|
22
|
+
if (location.startsWith('/category/')) {
|
|
23
|
+
return '0.8';
|
|
24
|
+
}
|
|
25
|
+
return '0.7';
|
|
26
|
+
}
|
|
27
|
+
static serializeLocation(url) {
|
|
28
|
+
return [
|
|
29
|
+
'<url>',
|
|
30
|
+
url.location && `\t<loc>${url.location}</loc>`,
|
|
31
|
+
url.changeFrequency && `\t<changefreq>${url.changeFrequency}</changefreq>`,
|
|
32
|
+
url.priority && `\t<priority>${url.priority}</priority>`,
|
|
33
|
+
'</url>',
|
|
34
|
+
]
|
|
35
|
+
.filter(Boolean)
|
|
36
|
+
.join('\n');
|
|
37
|
+
}
|
|
38
|
+
serialize() {
|
|
39
|
+
return [
|
|
40
|
+
'<?xml version="1.0" encoding="UTF-8" ?>',
|
|
41
|
+
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">',
|
|
42
|
+
this.urls.map(SitemapBuilder.serializeLocation).join('\n'),
|
|
43
|
+
'</urlset>',
|
|
44
|
+
].join('\n');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=SitemapBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SitemapBuilder.js","sourceRoot":"","sources":["../../../src/components-nextjs/Sitemap/SitemapBuilder.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,cAAc;IACf,OAAO,CAAS;IAEhB,IAAI,GAAiB,EAAE,CAAC;IAEhC,YAAY,OAAe;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAEM,MAAM,CAAC,QAAgB;QAC1B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;YACX,QAAQ,EAAE,IAAI,CAAC,OAAO,GAAG,QAAQ;YACjC,eAAe,EAAE,cAAc,CAAC,cAAc,CAAC,QAAQ,CAAC;YACxD,QAAQ,EAAE,cAAc,CAAC,aAAa,CAAC,QAAQ,CAAC;SACnD,CAAC,CAAC;IACP,CAAC;IAEO,MAAM,CAAC,cAAc,CAAC,QAAgB;QAC1C,IAAI,QAAQ,KAAK,GAAG;YAAE,OAAO,OAAO,CAAC;QAErC,OAAO,QAAQ,CAAC;IACpB,CAAC;IAEO,MAAM,CAAC,aAAa,CAAC,QAAgB;QACzC,IAAI,QAAQ,KAAK,GAAG;YAAE,OAAO,KAAK,CAAC;QAEnC,IAAI,QAAQ,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE;YACnC,OAAO,KAAK,CAAC;SAChB;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,MAAM,CAAC,iBAAiB,CAAC,GAAe;QACpC,OAAO;YACH,OAAO;YACP,GAAG,CAAC,QAAQ,IAAI,UAAU,GAAG,CAAC,QAAQ,QAAQ;YAC9C,GAAG,CAAC,eAAe,IAAI,iBAAiB,GAAG,CAAC,eAAe,eAAe;YAC1E,GAAG,CAAC,QAAQ,IAAI,eAAe,GAAG,CAAC,QAAQ,aAAa;YACxD,QAAQ;SACX;aACI,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;IAED,SAAS;QACL,OAAO;YACH,yCAAyC;YACzC,wLAAwL;YACxL,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;YAC1D,WAAW;SACd,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;CACJ"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function createPaths(stories, categories) {
|
|
2
|
+
const storiesUrls = stories.map(({ slug }) => `/${slug}`);
|
|
3
|
+
const categoriesUrls = categories
|
|
4
|
+
.map((category) => {
|
|
5
|
+
const translations = Object.values(category.i18n);
|
|
6
|
+
const allSlugs = translations
|
|
7
|
+
.map(({ slug }) => slug || '')
|
|
8
|
+
.filter(Boolean)
|
|
9
|
+
.reduce((slugs, slug) => (slugs.includes(slug) ? [...slugs] : [...slugs, slug]), []);
|
|
10
|
+
return allSlugs.map((slug) => `/category/${slug}`);
|
|
11
|
+
})
|
|
12
|
+
.flat();
|
|
13
|
+
return [...storiesUrls, ...categoriesUrls];
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=createPaths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPaths.js","sourceRoot":"","sources":["../../../src/components-nextjs/Sitemap/createPaths.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,WAAW,CAAC,OAAgB,EAAE,UAAsB;IAChE,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"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getPrezlyApi } from '../../data-fetching';
|
|
2
|
+
import { createPaths } from './createPaths';
|
|
3
|
+
import { SitemapBuilder } from './SitemapBuilder';
|
|
4
|
+
export async function getInitialProps(ctx, additionalPaths) {
|
|
5
|
+
const { res, req } = ctx;
|
|
6
|
+
if (!req || !res) {
|
|
7
|
+
// client side
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
const baseUrl = req.headers.host || '/';
|
|
11
|
+
const api = getPrezlyApi(req);
|
|
12
|
+
const stories = await api.getAllStories();
|
|
13
|
+
const categories = await api.getCategories();
|
|
14
|
+
const paths = createPaths(stories, categories);
|
|
15
|
+
const sitemapBuilder = new SitemapBuilder(baseUrl);
|
|
16
|
+
sitemapBuilder.addUrl('/');
|
|
17
|
+
paths.forEach((path) => sitemapBuilder.addUrl(path));
|
|
18
|
+
if (additionalPaths) {
|
|
19
|
+
additionalPaths.forEach((path) => sitemapBuilder.addUrl(path));
|
|
20
|
+
}
|
|
21
|
+
res.setHeader('Content-Type', 'text/xml');
|
|
22
|
+
res.write(sitemapBuilder.serialize());
|
|
23
|
+
res.end();
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=getInitialProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getInitialProps.js","sourceRoot":"","sources":["../../../src/components-nextjs/Sitemap/getInitialProps.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,GAAoB,EAAE,eAA0B;IAClF,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IAEzB,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE;QACd,cAAc;QACd,OAAO,IAAI,CAAC;KACf;IAED,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,GAAG,CAAC;IAExC,MAAM,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IAC9B,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,aAAa,EAAE,CAAC;IAC1C,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,aAAa,EAAE,CAAC;IAE7C,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC/C,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;IAEnD,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3B,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAErD,IAAI,eAAe,EAAE;QACjB,eAAe,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;KAClE;IAED,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;IAC1C,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC,CAAC;IACtC,GAAG,CAAC,GAAG,EAAE,CAAC;IAEV,OAAO,IAAI,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components-nextjs/Sitemap/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE9E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components-nextjs/Sitemap/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ExtendedStory } from '@prezly/sdk';
|
|
3
|
+
declare type Props = {
|
|
4
|
+
story: ExtendedStory;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* This components provides additional page attributes for the Story page.
|
|
8
|
+
* It works in conjunction with `PageSeo` component, overidding some of its attributes.
|
|
9
|
+
*/
|
|
10
|
+
export declare function StorySeo({ story }: Props): JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ArticleJsonLd, NextSeo } from 'next-seo';
|
|
3
|
+
/**
|
|
4
|
+
* This components provides additional page attributes for the Story page.
|
|
5
|
+
* It works in conjunction with `PageSeo` component, overidding some of its attributes.
|
|
6
|
+
*/
|
|
7
|
+
export function StorySeo({ story }) {
|
|
8
|
+
const { title, subtitle, published_at, updated_at, author, oembed, newsroom, summary } = story;
|
|
9
|
+
const authorName = author?.display_name || author?.email || 'Unknown';
|
|
10
|
+
const description = subtitle || summary;
|
|
11
|
+
return (_jsxs(_Fragment, { children: [_jsx(NextSeo, { title: title, description: description, canonical: oembed.url, openGraph: {
|
|
12
|
+
title,
|
|
13
|
+
description,
|
|
14
|
+
url: oembed.url,
|
|
15
|
+
site_name: newsroom.display_name,
|
|
16
|
+
type: 'article',
|
|
17
|
+
article: {
|
|
18
|
+
publishedTime: published_at || undefined,
|
|
19
|
+
modifiedTime: updated_at,
|
|
20
|
+
authors: [authorName],
|
|
21
|
+
},
|
|
22
|
+
...(oembed.thumbnail_url && {
|
|
23
|
+
images: [
|
|
24
|
+
{
|
|
25
|
+
url: oembed.thumbnail_url,
|
|
26
|
+
alt: oembed.title,
|
|
27
|
+
width: oembed.thumbnail_width,
|
|
28
|
+
height: oembed.thumbnail_height,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
}),
|
|
32
|
+
}, additionalMetaTags: oembed.thumbnail_url
|
|
33
|
+
? [
|
|
34
|
+
{ name: 'twitter:card', content: 'summary_large_image' },
|
|
35
|
+
{ name: 'twitter:image', content: oembed.thumbnail_url },
|
|
36
|
+
]
|
|
37
|
+
: undefined }, void 0), _jsx(ArticleJsonLd, { url: oembed.url, title: title, images: oembed.thumbnail_url ? [oembed.thumbnail_url] : [], datePublished: published_at || '', dateModified: updated_at, authorName: [authorName], publisherName: newsroom.display_name, publisherLogo: newsroom.thumbnail_url, description: description }, void 0)] }, void 0));
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=StorySeo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorySeo.js","sourceRoot":"","sources":["../../../src/components-nextjs/StorySeo/StorySeo.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAMlD;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,EAAE,KAAK,EAAS;IACrC,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,WAAW,GAAG,QAAQ,IAAI,OAAO,CAAC;IAExC,OAAO,CACH,8BACI,KAAC,OAAO,IACJ,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,MAAM,CAAC,GAAG,EACrB,SAAS,EAAE;oBACP,KAAK;oBACL,WAAW;oBACX,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,WAErB,EACF,KAAC,aAAa,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,WAAW,WAC1B,YACH,CACN,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { StorySeo } from './StorySeo';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components-nextjs/StorySeo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components-nextjs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|