@prezly/theme-kit-nextjs 6.8.0 → 7.0.0
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 +1 -1
- package/build/adapter-nextjs/api-handlers/fetchGalleries.js +6 -2
- package/build/adapter-nextjs/api-handlers/fetchGalleries.js.map +1 -1
- package/build/adapter-nextjs/api-handlers/fetchStories.js +13 -14
- package/build/adapter-nextjs/api-handlers/fetchStories.js.map +1 -1
- package/build/adapter-nextjs/getNewsroomServerSideProps.d.ts +2 -1
- package/build/adapter-nextjs/getNewsroomServerSideProps.js +2 -5
- package/build/adapter-nextjs/getNewsroomServerSideProps.js.map +1 -1
- package/build/adapter-nextjs/getNewsroomStaticProps.d.ts +2 -1
- package/build/adapter-nextjs/getNewsroomStaticProps.js +2 -5
- package/build/adapter-nextjs/getNewsroomStaticProps.js.map +1 -1
- package/build/adapter-nextjs/page-props/category.js +20 -16
- package/build/adapter-nextjs/page-props/category.js.map +1 -1
- package/build/adapter-nextjs/page-props/gallery.js +7 -4
- package/build/adapter-nextjs/page-props/gallery.js.map +1 -1
- package/build/adapter-nextjs/page-props/galleryAlbum.js +4 -4
- package/build/adapter-nextjs/page-props/galleryAlbum.js.map +1 -1
- package/build/adapter-nextjs/page-props/home.d.ts +0 -4
- package/build/adapter-nextjs/page-props/home.js +18 -18
- package/build/adapter-nextjs/page-props/home.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.d.ts +12 -3
- package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js +91 -13
- package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.d.ts +0 -4
- package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js +17 -11
- package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/index.d.ts +0 -1
- package/build/adapter-nextjs/page-props/sitemap/index.js +1 -3
- package/build/adapter-nextjs/page-props/sitemap/index.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/types.d.ts +4 -0
- package/build/adapter-nextjs/page-props/story.d.ts +1 -6
- package/build/adapter-nextjs/page-props/story.js +22 -13
- package/build/adapter-nextjs/page-props/story.js.map +1 -1
- package/build/adapter-nextjs/page-props/storyPreview.js +5 -3
- package/build/adapter-nextjs/page-props/storyPreview.js.map +1 -1
- package/build/adapter-nextjs/processRequest.js.map +1 -1
- package/build/adapter-nextjs/processStaticRequest.js.map +1 -1
- package/build/components-nextjs/PageSeo/PageSeo.js.map +1 -1
- package/build/components-nextjs/document.d.ts +1 -1
- package/build/data-fetching/client.d.ts +10 -0
- package/build/data-fetching/client.js +51 -0
- package/build/data-fetching/client.js.map +1 -0
- package/build/data-fetching/index.d.ts +1 -1
- package/build/data-fetching/index.js +25 -3
- package/build/data-fetching/index.js.map +1 -1
- package/build/infinite-loading/lib/useAsync.js.map +1 -1
- package/build/infinite-loading/useInfiniteGalleriesLoading.js.map +1 -1
- package/build/infinite-loading/useInfiniteLoading.js.map +1 -1
- package/build/infinite-loading/useInfiniteStoriesLoading.d.ts +1 -5
- package/build/infinite-loading/useInfiniteStoriesLoading.js +3 -12
- package/build/infinite-loading/useInfiniteStoriesLoading.js.map +1 -1
- package/build/intl/languages.js.map +1 -1
- package/build/intl/locale.js.map +1 -1
- package/build/newsroom-context/context.d.ts +2 -2
- package/build/newsroom-context/context.js.map +1 -1
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js.map +1 -1
- package/build/newsroom-context/hooks/useGetTranslationUrl.js.map +1 -1
- package/build/newsroom-context/hooks/useNewsroomContext.js.map +1 -1
- package/build/sentry/common.js.map +1 -1
- package/build/utils.js.map +1 -1
- package/package.json +5 -4
- package/build/adapter-nextjs/page-props/sitemap/createPaths.d.ts +0 -2
- package/build/adapter-nextjs/page-props/sitemap/createPaths.js +0 -19
- package/build/adapter-nextjs/page-props/sitemap/createPaths.js.map +0 -1
- package/build/data-fetching/NextPrezlyApi.d.ts +0 -8
- package/build/data-fetching/NextPrezlyApi.js +0 -40
- package/build/data-fetching/NextPrezlyApi.js.map +0 -1
- package/build/data-fetching/getNextPrezlyApi.d.ts +0 -4
- package/build/data-fetching/getNextPrezlyApi.js +0 -20
- package/build/data-fetching/getNextPrezlyApi.js.map +0 -1
package/README.md
CHANGED
|
@@ -192,7 +192,7 @@ Since all of the common data is loaded into the `NewsroomContextProvider`, you d
|
|
|
192
192
|
```ts
|
|
193
193
|
const { api, serverSideProps } = await getNewsroomServerSideProps(context);
|
|
194
194
|
```
|
|
195
|
-
This function fetches all the required base props and exposes the `
|
|
195
|
+
This function fetches all the required base props and exposes the `ContentDelivery.Client` instance, which you can use to fetch additional content like stories or categories.
|
|
196
196
|
|
|
197
197
|
```ts
|
|
198
198
|
return processRequest(
|
|
@@ -11,8 +11,12 @@ async function fetchGalleries(req, res) {
|
|
|
11
11
|
}
|
|
12
12
|
const { page, pageSize, type } = req.body;
|
|
13
13
|
try {
|
|
14
|
-
const api =
|
|
15
|
-
const { galleries, pagination } = await api.
|
|
14
|
+
const api = data_fetching_1.NextContentDelivery.initClient(req);
|
|
15
|
+
const { galleries, pagination } = await api.galleries({
|
|
16
|
+
type,
|
|
17
|
+
limit: pageSize,
|
|
18
|
+
offset: (page - 1) * pageSize,
|
|
19
|
+
});
|
|
16
20
|
res.status(200).json({ galleries, galleriesTotal: pagination.matched_records_number });
|
|
17
21
|
}
|
|
18
22
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchGalleries.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/api-handlers/fetchGalleries.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;AAGzD,
|
|
1
|
+
{"version":3,"file":"fetchGalleries.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/api-handlers/fetchGalleries.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;AAGzD,uDAA0D;AAEnD,KAAK,UAAU,cAAc,CAAC,GAAmB,EAAE,GAAoB;IAC1E,IAAA,gCAAe,EAAC,gBAAgB,CAAC,CAAC;IAElC,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QACxB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChB,OAAO;IACX,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC;IAE1C,IAAI,CAAC;QACD,MAAM,GAAG,GAAG,mCAAmB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAEhD,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,MAAM,GAAG,CAAC,SAAS,CAAC;YAClD,IAAI;YACJ,KAAK,EAAE,QAAQ;YACf,MAAM,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,QAAQ;SAChC,CAAC,CAAC;QAEH,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,CAAC,sBAAsB,EAAE,CAAC,CAAC;IAC3F,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACjB,OAAO,EAAG,KAAe,CAAC,OAAO;SACpC,CAAC,CAAC;IACP,CAAC;AACL,CAAC;AAzBD,wCAyBC"}
|
|
@@ -9,21 +9,20 @@ async function fetchStories(req, res) {
|
|
|
9
9
|
res.status(405);
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
const { page, pageSize, withHighlightedStory, category, include,
|
|
12
|
+
const { page, pageSize, withHighlightedStory, category, include, formats, localeCode, filterQuery, } = req.body;
|
|
13
13
|
try {
|
|
14
|
-
const api =
|
|
15
|
-
const { stories,
|
|
16
|
-
|
|
17
|
-
:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
res.status(200).json({ stories, storiesTotal });
|
|
14
|
+
const api = data_fetching_1.NextContentDelivery.initClient(req, { formats });
|
|
15
|
+
const { stories, pagination } = await api.stories({
|
|
16
|
+
category,
|
|
17
|
+
offset: (page - 1) * pageSize,
|
|
18
|
+
limit: pageSize,
|
|
19
|
+
locale: localeCode,
|
|
20
|
+
highlighted: withHighlightedStory ? 1 : 0,
|
|
21
|
+
query: filterQuery,
|
|
22
|
+
}, {
|
|
23
|
+
include,
|
|
24
|
+
});
|
|
25
|
+
res.status(200).json({ stories, storiesTotal: pagination.matched_records_number });
|
|
27
26
|
}
|
|
28
27
|
catch (error) {
|
|
29
28
|
res.status(500).send({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchStories.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/api-handlers/fetchStories.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;AAGzD,
|
|
1
|
+
{"version":3,"file":"fetchStories.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/api-handlers/fetchStories.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;AAGzD,uDAA0D;AAEnD,KAAK,UAAU,YAAY,CAAC,GAAmB,EAAE,GAAoB;IACxE,IAAA,gCAAe,EAAC,cAAc,CAAC,CAAC;IAEhC,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QACxB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChB,OAAO;IACX,CAAC;IAED,MAAM,EACF,IAAI,EACJ,QAAQ,EACR,oBAAoB,EACpB,QAAQ,EACR,OAAO,EACP,OAAO,EACP,UAAU,EACV,WAAW,GACd,GAAG,GAAG,CAAC,IAAI,CAAC;IAEb,IAAI,CAAC;QACD,MAAM,GAAG,GAAG,mCAAmB,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QAE7D,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,GAAG,CAAC,OAAO,CAC7C;YACI,QAAQ;YACR,MAAM,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,QAAQ;YAC7B,KAAK,EAAE,QAAQ;YACf,MAAM,EAAE,UAAU;YAClB,WAAW,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACzC,KAAK,EAAE,WAAW;SACrB,EACD;YACI,OAAO;SACV,CACJ,CAAC;QAEF,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,CAAC,sBAAsB,EAAE,CAAC,CAAC;IACvF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACjB,OAAO,EAAG,KAAe,CAAC,OAAO;SACpC,CAAC,CAAC;IACP,CAAC;AACL,CAAC;AA1CD,oCA0CC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Story } from '@prezly/sdk';
|
|
2
2
|
import type { GetServerSidePropsContext } from 'next';
|
|
3
|
+
import { NextContentDelivery } from '../data-fetching';
|
|
3
4
|
interface Options {
|
|
4
5
|
loadHomepageContacts?: boolean;
|
|
5
6
|
story?: Pick<Story, 'culture'>;
|
|
@@ -9,7 +10,7 @@ interface Options {
|
|
|
9
10
|
* See README for usage examples.
|
|
10
11
|
*/
|
|
11
12
|
export declare function getNewsroomServerSideProps(context: GetServerSidePropsContext, options?: Options): Promise<{
|
|
12
|
-
api:
|
|
13
|
+
api: NextContentDelivery.Client;
|
|
13
14
|
serverSideProps: import("..").PageProps & import("..").ServerSidePageProps;
|
|
14
15
|
}>;
|
|
15
16
|
export {};
|
|
@@ -10,11 +10,8 @@ const data_fetching_1 = require("../data-fetching");
|
|
|
10
10
|
async function getNewsroomServerSideProps(context, options = {}) {
|
|
11
11
|
(0, theme_kit_core_1.assertServerEnv)('getNewsroomServerSideProps');
|
|
12
12
|
const { req: request, locale } = context;
|
|
13
|
-
const api =
|
|
14
|
-
const serverSideProps = await api.getNewsroomServerSideProps(
|
|
15
|
-
if (options.loadHomepageContacts) {
|
|
16
|
-
serverSideProps.newsroomContextProps.contacts = await api.getNewsroomContacts();
|
|
17
|
-
}
|
|
13
|
+
const api = data_fetching_1.NextContentDelivery.initClient(request);
|
|
14
|
+
const serverSideProps = await api.getNewsroomServerSideProps(locale, options.story, options.loadHomepageContacts);
|
|
18
15
|
return { api, serverSideProps };
|
|
19
16
|
}
|
|
20
17
|
exports.getNewsroomServerSideProps = getNewsroomServerSideProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNewsroomServerSideProps.js","sourceRoot":"","sources":["../../src/adapter-nextjs/getNewsroomServerSideProps.ts"],"names":[],"mappings":";;;AACA,2DAAyD;AAGzD,
|
|
1
|
+
{"version":3,"file":"getNewsroomServerSideProps.js","sourceRoot":"","sources":["../../src/adapter-nextjs/getNewsroomServerSideProps.ts"],"names":[],"mappings":";;;AACA,2DAAyD;AAGzD,oDAAuD;AAOvD;;;GAGG;AACI,KAAK,UAAU,0BAA0B,CAC5C,OAAkC,EAClC,UAAmB,EAAE;IAErB,IAAA,gCAAe,EAAC,4BAA4B,CAAC,CAAC;IAC9C,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAEzC,MAAM,GAAG,GAAG,mCAAmB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAEpD,MAAM,eAAe,GAAG,MAAM,GAAG,CAAC,0BAA0B,CACxD,MAAM,EACN,OAAO,CAAC,KAAK,EACb,OAAO,CAAC,oBAAoB,CAC/B,CAAC;IAEF,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,CAAC;AACpC,CAAC;AAhBD,gEAgBC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Story } from '@prezly/sdk';
|
|
2
2
|
import type { GetStaticPropsContext } from 'next';
|
|
3
|
+
import { NextContentDelivery } from '../data-fetching';
|
|
3
4
|
interface Options {
|
|
4
5
|
loadHomepageContacts?: boolean;
|
|
5
6
|
story?: Pick<Story, 'culture'>;
|
|
@@ -9,7 +10,7 @@ interface Options {
|
|
|
9
10
|
* See README for usage examples.
|
|
10
11
|
*/
|
|
11
12
|
export declare function getNewsroomStaticProps(context: GetStaticPropsContext, options?: Options): Promise<{
|
|
12
|
-
api:
|
|
13
|
+
api: NextContentDelivery.Client;
|
|
13
14
|
staticProps: import("..").PageProps & import("..").ServerSidePageProps;
|
|
14
15
|
}>;
|
|
15
16
|
export {};
|
|
@@ -10,11 +10,8 @@ const data_fetching_1 = require("../data-fetching");
|
|
|
10
10
|
async function getNewsroomStaticProps(context, options = {}) {
|
|
11
11
|
(0, theme_kit_core_1.assertServerEnv)('getNewsroomStaticProps');
|
|
12
12
|
const { locale } = context;
|
|
13
|
-
const api =
|
|
14
|
-
const staticProps = await api.getNewsroomServerSideProps(
|
|
15
|
-
if (options.loadHomepageContacts) {
|
|
16
|
-
staticProps.newsroomContextProps.contacts = await api.getNewsroomContacts();
|
|
17
|
-
}
|
|
13
|
+
const api = data_fetching_1.NextContentDelivery.initClient();
|
|
14
|
+
const staticProps = await api.getNewsroomServerSideProps(locale, options.story, options.loadHomepageContacts);
|
|
18
15
|
return { api, staticProps };
|
|
19
16
|
}
|
|
20
17
|
exports.getNewsroomStaticProps = getNewsroomStaticProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNewsroomStaticProps.js","sourceRoot":"","sources":["../../src/adapter-nextjs/getNewsroomStaticProps.ts"],"names":[],"mappings":";;;AACA,2DAAyD;AAGzD,
|
|
1
|
+
{"version":3,"file":"getNewsroomStaticProps.js","sourceRoot":"","sources":["../../src/adapter-nextjs/getNewsroomStaticProps.ts"],"names":[],"mappings":";;;AACA,2DAAyD;AAGzD,oDAAuD;AAOvD;;;GAGG;AACI,KAAK,UAAU,sBAAsB,CACxC,OAA8B,EAC9B,UAAmB,EAAE;IAErB,IAAA,gCAAe,EAAC,wBAAwB,CAAC,CAAC;IAC1C,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE3B,MAAM,GAAG,GAAG,mCAAmB,CAAC,UAAU,EAAE,CAAC;IAC7C,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,0BAA0B,CACpD,MAAM,EACN,OAAO,CAAC,KAAK,EACb,OAAO,CAAC,oBAAoB,CAC/B,CAAC;IAEF,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC;AAChC,CAAC;AAfD,wDAeC"}
|
|
@@ -12,28 +12,30 @@ function getCategoryPageServerSideProps(customProps, options = {}) {
|
|
|
12
12
|
return async function getServerSideProps(context) {
|
|
13
13
|
const { api, serverSideProps } = await (0, getNewsroomServerSideProps_1.getNewsroomServerSideProps)(context);
|
|
14
14
|
const { slug } = context.params;
|
|
15
|
-
const category = await api.
|
|
15
|
+
const category = await api.category(slug);
|
|
16
16
|
if (!category) {
|
|
17
17
|
return {
|
|
18
18
|
notFound: true,
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
const { query } = context;
|
|
22
|
-
const page = query.page && typeof query.page === 'string' ? Number(query.page) :
|
|
22
|
+
const page = query.page && typeof query.page === 'string' ? Number(query.page) : 1;
|
|
23
23
|
const { localeCode } = serverSideProps.newsroomContextProps;
|
|
24
|
-
const { stories,
|
|
25
|
-
|
|
26
|
-
pageSize,
|
|
24
|
+
const { stories, pagination } = await api.stories({
|
|
25
|
+
category,
|
|
26
|
+
offset: (page - 1) * pageSize,
|
|
27
|
+
limit: pageSize,
|
|
28
|
+
locale: localeCode ? { code: localeCode } : undefined,
|
|
29
|
+
}, {
|
|
27
30
|
include: extraStoryFields,
|
|
28
|
-
localeCode,
|
|
29
31
|
});
|
|
30
32
|
serverSideProps.newsroomContextProps.currentCategory = category;
|
|
31
33
|
return (0, processRequest_1.processRequest)(context, {
|
|
32
34
|
...serverSideProps,
|
|
33
35
|
stories,
|
|
34
36
|
pagination: {
|
|
35
|
-
itemsTotal:
|
|
36
|
-
currentPage: page
|
|
37
|
+
itemsTotal: pagination.matched_records_number,
|
|
38
|
+
currentPage: page,
|
|
37
39
|
pageSize,
|
|
38
40
|
},
|
|
39
41
|
...(typeof customProps === 'function'
|
|
@@ -48,24 +50,26 @@ function getCategoryPageStaticProps(customProps, options = {}) {
|
|
|
48
50
|
return async function getStaticProps(context) {
|
|
49
51
|
const { api, staticProps } = await (0, getNewsroomStaticProps_1.getNewsroomStaticProps)(context);
|
|
50
52
|
const { slug } = context.params;
|
|
51
|
-
const category = await api.
|
|
53
|
+
const category = await api.category(slug);
|
|
52
54
|
if (!category) {
|
|
53
55
|
return {
|
|
54
56
|
notFound: true,
|
|
55
57
|
};
|
|
56
58
|
}
|
|
57
59
|
const { localeCode } = staticProps.newsroomContextProps;
|
|
58
|
-
const { stories,
|
|
59
|
-
|
|
60
|
+
const { stories, pagination } = await api.stories({
|
|
61
|
+
category,
|
|
62
|
+
limit: pageSize,
|
|
63
|
+
locale: localeCode ? { code: localeCode } : undefined,
|
|
64
|
+
}, {
|
|
60
65
|
include: extraStoryFields,
|
|
61
|
-
localeCode,
|
|
62
66
|
});
|
|
63
67
|
staticProps.newsroomContextProps.currentCategory = category;
|
|
64
68
|
return (0, processStaticRequest_1.processStaticRequest)(context, {
|
|
65
69
|
...staticProps,
|
|
66
70
|
stories,
|
|
67
71
|
pagination: {
|
|
68
|
-
itemsTotal:
|
|
72
|
+
itemsTotal: pagination.matched_records_number,
|
|
69
73
|
currentPage: 1,
|
|
70
74
|
pageSize,
|
|
71
75
|
},
|
|
@@ -77,10 +81,10 @@ function getCategoryPageStaticProps(customProps, options = {}) {
|
|
|
77
81
|
}
|
|
78
82
|
exports.getCategoryPageStaticProps = getCategoryPageStaticProps;
|
|
79
83
|
async function getCategoryPageStaticPaths() {
|
|
80
|
-
const api =
|
|
84
|
+
const api = data_fetching_1.NextContentDelivery.initClient();
|
|
81
85
|
const [categories, defaultLanguage] = await Promise.all([
|
|
82
|
-
api.
|
|
83
|
-
api.
|
|
86
|
+
api.categories(),
|
|
87
|
+
api.defaultLanguage(),
|
|
84
88
|
]);
|
|
85
89
|
const locale = theme_kit_core_1.LocaleObject.fromAnyCode(defaultLanguage.code);
|
|
86
90
|
const paths = categories
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"category.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/category.ts"],"names":[],"mappings":";;;AACA,2DAAmG;AASnG,
|
|
1
|
+
{"version":3,"file":"category.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/category.ts"],"names":[],"mappings":";;;AACA,2DAAmG;AASnG,uDAA0D;AAE1D,8EAA2E;AAC3E,sEAAmE;AACnE,sDAAmD;AACnD,kEAA+D;AAc/D,SAAgB,8BAA8B,CAG5C,WAAqD,EAAE,UAA4B,EAAE;IACnF,MAAM,EAAE,QAAQ,GAAG,kCAAiB,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC;IAEnE,OAAO,KAAK,UAAU,kBAAkB,CACpC,OAAkC;QAElC,MAAM,EAAE,GAAG,EAAE,eAAe,EAAE,GAAG,MAAM,IAAA,uDAA0B,EAAC,OAAO,CAAC,CAAC;QAE3E,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAA0B,CAAC;QACpD,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAE1C,IAAI,CAAC,QAAQ,EAAE,CAAC;YACZ,OAAO;gBACH,QAAQ,EAAE,IAAI;aACjB,CAAC;QACN,CAAC;QAED,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QAC1B,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MA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AAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAE9D,MAAM,KAAK,GAAG,UAAU;SACnB,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;QACd,MAAM,EAAE,IAAI,EAAE,GAAG,IAAA,yCAAwB,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC;IAChC,CAAC,CAAC;SACD,MAAM,CAA+B,OAAc,CAAC,CAAC;IAE1D,OAAO;QACH,KAAK;QACL,QAAQ,EAAE,UAAU;KACvB,CAAC;AACN,CAAC;AAvBD,gEAuBC"}
|
|
@@ -11,8 +11,11 @@ function getGalleryPageServerSideProps(customProps, options) {
|
|
|
11
11
|
return async function getServerSideProps(context) {
|
|
12
12
|
const { api, serverSideProps } = await (0, getNewsroomServerSideProps_1.getNewsroomServerSideProps)(context);
|
|
13
13
|
const { query } = context;
|
|
14
|
-
const page = query.page && typeof query.page === 'string' ? Number(query.page) :
|
|
15
|
-
const { galleries, pagination } = await api.
|
|
14
|
+
const page = query.page && typeof query.page === 'string' ? Number(query.page) : 1;
|
|
15
|
+
const { galleries, pagination } = await api.galleries({
|
|
16
|
+
offset: (page - 1) * pageSize,
|
|
17
|
+
limit: pageSize,
|
|
18
|
+
});
|
|
16
19
|
// If there's only one gallery, redirect to it immediately
|
|
17
20
|
if (galleries.length === 1) {
|
|
18
21
|
const { uuid } = galleries[0];
|
|
@@ -28,7 +31,7 @@ function getGalleryPageServerSideProps(customProps, options) {
|
|
|
28
31
|
galleries,
|
|
29
32
|
pagination: {
|
|
30
33
|
itemsTotal: pagination.matched_records_number,
|
|
31
|
-
currentPage: page
|
|
34
|
+
currentPage: page,
|
|
32
35
|
pageSize,
|
|
33
36
|
},
|
|
34
37
|
...(typeof customProps === 'function'
|
|
@@ -42,7 +45,7 @@ function getGalleryPageStaticProps(customProps, options) {
|
|
|
42
45
|
const { pageSize = theme_kit_core_1.DEFAULT_GALLERY_PAGE_SIZE } = options || {};
|
|
43
46
|
return async function getStaticProps(context) {
|
|
44
47
|
const { api, staticProps } = await (0, getNewsroomStaticProps_1.getNewsroomStaticProps)(context);
|
|
45
|
-
const { galleries, pagination } = await api.
|
|
48
|
+
const { galleries, pagination } = await api.galleries({ limit: pageSize });
|
|
46
49
|
// If there's only one gallery, redirect to it immediately
|
|
47
50
|
if (galleries.length === 1) {
|
|
48
51
|
const { uuid } = galleries[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gallery.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/gallery.ts"],"names":[],"mappings":";;;AACA,2DAAmE;AASnE,8EAA2E;AAC3E,sEAAmE;AACnE,sDAAmD;AACnD,kEAA+D;AAa/D,SAAgB,6BAA6B,CACzC,WAAqD,EACrD,OAAiB;IAEjB,MAAM,EAAE,QAAQ,GAAG,0CAAyB,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAE/D,OAAO,KAAK,UAAU,kBAAkB,CACpC,OAAkC;QAElC,MAAM,EAAE,GAAG,EAAE,eAAe,EAAE,GAAG,MAAM,IAAA,uDAA0B,EAAC,OAAO,CAAC,CAAC;QAC3E,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QAE1B,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"gallery.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/gallery.ts"],"names":[],"mappings":";;;AACA,2DAAmE;AASnE,8EAA2E;AAC3E,sEAAmE;AACnE,sDAAmD;AACnD,kEAA+D;AAa/D,SAAgB,6BAA6B,CACzC,WAAqD,EACrD,OAAiB;IAEj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ACN,CAAC;AA/CD,sEA+CC;AAED,SAAgB,yBAAyB,CACrC,WAA4E,EAC5E,OAAiB;IAEjB,MAAM,EAAE,QAAQ,GAAG,0CAAyB,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAE/D,OAAO,KAAK,UAAU,cAAc,CAChC,OAA8B;QAE9B,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,MAAM,IAAA,+CAAsB,EAAC,OAAO,CAAC,CAAC;QAEnE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,MAAM,GAAG,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAE3E,0DAA0D;QAC1D,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,MAAM,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;YAE9B,OAAO;gBACH,QAAQ,EAAE;oBACN,WAAW,EAAE,gBAAgB,IAAI,EAAE;oBACnC,SAAS,EAAE,KAAK;iBACnB;aACJ,CAAC;QACN,CAAC;QAED,OAAO,IAAA,2CAAoB,EAAC,OAAO,EAAE;YACjC,GAAG,WAAW;YACd,SAAS;YACT,UAAU,EAAE;gBACR,UAAU,EAAE,UAAU,CAAC,sBAAsB;gBAC7C,WAAW,EAAE,CAAC;gBACd,QAAQ;aACX;YACD,GAAG,CAAC,OAAO,WAAW,KAAK,UAAU;gBACjC,CAAC,CAAC,MAAO,WAAiE,CACpE,OAAO,EACP,WAAW,CACd;gBACH,CAAC,CAAC,WAAW,CAAC;SACrB,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC;AAzCD,8DAyCC"}
|
|
@@ -11,7 +11,7 @@ function getGalleryAlbumPageServerSideProps(customProps) {
|
|
|
11
11
|
return async function getServerSideProps(context) {
|
|
12
12
|
const { api, serverSideProps } = await (0, getNewsroomServerSideProps_1.getNewsroomServerSideProps)(context);
|
|
13
13
|
const { uuid } = context.params;
|
|
14
|
-
const gallery = await api.
|
|
14
|
+
const gallery = await api.gallery(uuid);
|
|
15
15
|
if (!gallery || (0, theme_kit_core_1.isGalleryEmpty)(gallery)) {
|
|
16
16
|
return { notFound: true };
|
|
17
17
|
}
|
|
@@ -29,7 +29,7 @@ function getGalleryAlbumPageStaticProps(customProps) {
|
|
|
29
29
|
return async function getStaticProps(context) {
|
|
30
30
|
const { api, staticProps } = await (0, getNewsroomStaticProps_1.getNewsroomStaticProps)(context);
|
|
31
31
|
const { uuid } = context.params;
|
|
32
|
-
const gallery = await api.
|
|
32
|
+
const gallery = await api.gallery(uuid);
|
|
33
33
|
if (!gallery || (0, theme_kit_core_1.isGalleryEmpty)(gallery)) {
|
|
34
34
|
return { notFound: true };
|
|
35
35
|
}
|
|
@@ -44,8 +44,8 @@ function getGalleryAlbumPageStaticProps(customProps) {
|
|
|
44
44
|
}
|
|
45
45
|
exports.getGalleryAlbumPageStaticProps = getGalleryAlbumPageStaticProps;
|
|
46
46
|
async function getGalleryAlbumPageStaticPaths() {
|
|
47
|
-
const api =
|
|
48
|
-
const { galleries } = await api.
|
|
47
|
+
const api = data_fetching_1.NextContentDelivery.initClient();
|
|
48
|
+
const { galleries } = await api.galleries();
|
|
49
49
|
const paths = galleries.map(({ uuid }) => ({ params: { uuid } }));
|
|
50
50
|
return {
|
|
51
51
|
paths,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"galleryAlbum.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/galleryAlbum.ts"],"names":[],"mappings":";;;AACA,2DAAwD;AASxD,
|
|
1
|
+
{"version":3,"file":"galleryAlbum.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/galleryAlbum.ts"],"names":[],"mappings":";;;AACA,2DAAwD;AASxD,uDAA0D;AAC1D,8EAA2E;AAC3E,sEAAmE;AACnE,sDAAmD;AACnD,kEAA+D;AAQ/D,SAAgB,kCAAkC,CAC9C,WAAqD;IAErD,OAAO,KAAK,UAAU,k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;gBACjC,CAAC,CAAC,MAAO,WAAiE,CACpE,OAAO,EACP,WAAW,CACd;gBACH,CAAC,CAAC,WAAW,CAAC;SACrB,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC;AA1BD,wEA0BC;AAEM,KAAK,UAAU,8BAA8B;IAChD,MAAM,GAAG,GAAG,mCAAmB,CAAC,UAAU,EAAE,CAAC;IAC7C,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,GAAG,CAAC,SAAS,EAAE,CAAC;IAE5C,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IAElE,OAAO;QACH,KAAK;QACL,QAAQ,EAAE,UAAU;KACvB,CAAC;AACN,CAAC;AAVD,wEAUC"}
|
|
@@ -14,10 +14,6 @@ interface Options<Include extends keyof Story.ExtraFields> {
|
|
|
14
14
|
*/
|
|
15
15
|
withHighlightedStory?: boolean;
|
|
16
16
|
pageSize?: number;
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated Story Pinning will always be enabled in the next major release.
|
|
19
|
-
*/
|
|
20
|
-
pinning?: boolean;
|
|
21
17
|
filterQuery?: Object;
|
|
22
18
|
}
|
|
23
19
|
export declare function getHomepageServerSideProps<CustomProps extends Record<string, any>, Include extends keyof Story.ExtraFields = never>(customProps: CustomProps | PropsFunction<CustomProps>, options?: Options<Include>): (context: GetServerSidePropsContext) => Promise<GetServerSidePropsResult<HomePageProps<Include> & CustomProps>>;
|
|
@@ -7,29 +7,29 @@ const getNewsroomStaticProps_1 = require("../getNewsroomStaticProps");
|
|
|
7
7
|
const processRequest_1 = require("../processRequest");
|
|
8
8
|
const processStaticRequest_1 = require("../processStaticRequest");
|
|
9
9
|
function getHomepageServerSideProps(customProps, options) {
|
|
10
|
-
const { pageSize = theme_kit_core_1.DEFAULT_PAGE_SIZE, extraStoryFields,
|
|
10
|
+
const { pageSize = theme_kit_core_1.DEFAULT_PAGE_SIZE, extraStoryFields, withHighlightedStory = false, filterQuery, } = options || {};
|
|
11
11
|
return async function getServerSideProps(context) {
|
|
12
12
|
const { api, serverSideProps } = await (0, getNewsroomServerSideProps_1.getNewsroomServerSideProps)(context, {
|
|
13
13
|
loadHomepageContacts: true,
|
|
14
14
|
});
|
|
15
15
|
const { query } = context;
|
|
16
|
-
const page = query.page && typeof query.page === 'string' ? Number(query.page) :
|
|
16
|
+
const page = query.page && typeof query.page === 'string' ? Number(query.page) : 1;
|
|
17
17
|
const { localeCode } = serverSideProps.newsroomContextProps;
|
|
18
|
-
const storiesPaginated = await api.
|
|
19
|
-
page,
|
|
20
|
-
pageSize,
|
|
21
|
-
|
|
18
|
+
const storiesPaginated = await api.stories({
|
|
19
|
+
offset: (page - 1) * pageSize,
|
|
20
|
+
limit: pageSize,
|
|
21
|
+
locale: localeCode,
|
|
22
|
+
highlighted: withHighlightedStory ? 1 : 0,
|
|
23
|
+
query: filterQuery,
|
|
24
|
+
}, {
|
|
22
25
|
include: extraStoryFields,
|
|
23
|
-
localeCode,
|
|
24
|
-
withHighlightedStory,
|
|
25
|
-
filterQuery,
|
|
26
26
|
});
|
|
27
|
-
const { stories,
|
|
27
|
+
const { stories, pagination } = storiesPaginated;
|
|
28
28
|
return (0, processRequest_1.processRequest)(context, {
|
|
29
29
|
...serverSideProps,
|
|
30
30
|
stories,
|
|
31
31
|
pagination: {
|
|
32
|
-
itemsTotal:
|
|
32
|
+
itemsTotal: pagination.matched_records_number,
|
|
33
33
|
currentPage: page ?? 1,
|
|
34
34
|
pageSize,
|
|
35
35
|
withHighlightedStory,
|
|
@@ -42,24 +42,24 @@ function getHomepageServerSideProps(customProps, options) {
|
|
|
42
42
|
}
|
|
43
43
|
exports.getHomepageServerSideProps = getHomepageServerSideProps;
|
|
44
44
|
function getHomepageStaticProps(customProps, options = {}) {
|
|
45
|
-
const { pageSize = theme_kit_core_1.DEFAULT_PAGE_SIZE, extraStoryFields = []
|
|
45
|
+
const { pageSize = theme_kit_core_1.DEFAULT_PAGE_SIZE, extraStoryFields = [] } = options;
|
|
46
46
|
return async function getStaticProps(context) {
|
|
47
47
|
const { api, staticProps } = await (0, getNewsroomStaticProps_1.getNewsroomStaticProps)(context, {
|
|
48
48
|
loadHomepageContacts: true,
|
|
49
49
|
});
|
|
50
50
|
const { localeCode } = staticProps.newsroomContextProps;
|
|
51
|
-
const storiesPaginated = await api.
|
|
52
|
-
pageSize,
|
|
53
|
-
|
|
51
|
+
const storiesPaginated = await api.stories({
|
|
52
|
+
limit: pageSize,
|
|
53
|
+
locale: localeCode,
|
|
54
|
+
}, {
|
|
54
55
|
include: extraStoryFields,
|
|
55
|
-
localeCode,
|
|
56
56
|
});
|
|
57
|
-
const { stories,
|
|
57
|
+
const { stories, pagination } = storiesPaginated;
|
|
58
58
|
return (0, processStaticRequest_1.processStaticRequest)(context, {
|
|
59
59
|
...staticProps,
|
|
60
60
|
stories,
|
|
61
61
|
pagination: {
|
|
62
|
-
itemsTotal:
|
|
62
|
+
itemsTotal: pagination.matched_records_number,
|
|
63
63
|
currentPage: 1,
|
|
64
64
|
pageSize,
|
|
65
65
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"home.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/home.ts"],"names":[],"mappings":";;;AACA,2DAA2D;AAS3D,8EAA2E;AAC3E,sEAAmE;AACnE,sDAAmD;AACnD,kEAA+D;
|
|
1
|
+
{"version":3,"file":"home.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/home.ts"],"names":[],"mappings":";;;AACA,2DAA2D;AAS3D,8EAA2E;AAC3E,sEAAmE;AACnE,sDAAmD;AACnD,kEAA+D;AAoB/D,SAAgB,0BAA0B,CAGxC,WAAqD,EAAE,OAA0B;IAC/E,MAAM,EACF,QAAQ,GAAG,kCAAiB,EAC5B,gBAAgB,EAChB,oBAAoB,GAAG,KAAK,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B,EACD,GAAG,CACN,CAAC;IACN,CAAC,CAAC;AACN,CAAC;AAvDD,gEAuDC;AAED,SAAgB,sBAAsB,CAIlC,WAA4E,EAC5E,UAA4B,EAAE;IAE9B,MAAM,EAAE,QAAQ,GAAG,kCAAiB,EAAE,gBAAgB,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IAExE,OAAO,KAAK,UAAU,cAAc,CAChC,OAA8B;QAE9B,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,MAAM,IAAA,+CAAsB,EAAC,OAAO,EAAE;YAC/D,oBAAoB,EAAE,IAAI;SAC7B,CAAC,CAAC;QAEH,MAAM,EAAE,UAAU,EAAE,GAAG,WAAW,CAAC,oBAAoB,CAAC;QAExD,MAAM,gBAAgB,GAAG,MAAM,GAAG,CAAC,OAAO,CACtC;YACI,KAAK,EAAE,QAAQ;YACf,MAAM,EAAE,UAAU;SACrB,EACD;YACI,OAAO,EAAE,gBAAgB;SAC5B,CACJ,CAAC;QACF,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,gBAAgB,CAAC;QAEjD,OAAO,IAAA,2CAAoB,EAAC,OAAO,EAAE;YACjC,GAAG,WAAW;YACd,OAAO;YACP,UAAU,EAAE;gBACR,UAAU,EAAE,UAAU,CAAC,sBAAsB;gBAC7C,WAAW,EAAE,CAAC;gBACd,QAAQ;aACX;YACD,GAAG,CAAC,OAAO,WAAW,KAAK,UAAU;gBACjC,CAAC,CAAC,MAAO,WAAiE,CACpE,OAAO,EACP,WAAW,CACd;gBACH,CAAC,CAAC,WAAW,CAAC;SACrB,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC;AA7CD,wDA6CC"}
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
+
import { Category } from '@prezly/sdk';
|
|
2
|
+
import type { NewsroomLanguageSettings, Story } from '@prezly/sdk';
|
|
1
3
|
import type { SitemapUrl } from './types';
|
|
2
4
|
export declare class SitemapBuilder {
|
|
3
5
|
private baseUrl;
|
|
4
6
|
private basePath;
|
|
7
|
+
private usedLanguages;
|
|
5
8
|
private urls;
|
|
6
|
-
constructor(baseUrl: string, basePath
|
|
7
|
-
private
|
|
8
|
-
|
|
9
|
+
constructor(baseUrl: string, basePath: string | undefined, languages: NewsroomLanguageSettings[]);
|
|
10
|
+
private buildUrl;
|
|
11
|
+
/**
|
|
12
|
+
* Add a non-dynamic URL to the sitemap (e.g. `/` or `/media`)
|
|
13
|
+
* The URL will be added once for each used locale on the site, with proper locale code part.
|
|
14
|
+
*/
|
|
15
|
+
addPageUrl(url: string): void;
|
|
16
|
+
addStoryUrl(story: Story): void;
|
|
17
|
+
addCategoryUrl(category: Category): void;
|
|
9
18
|
private static guessFrequency;
|
|
10
19
|
private static guessPriority;
|
|
11
20
|
static serializeLocation(url: SitemapUrl): string;
|
|
@@ -1,29 +1,106 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SitemapBuilder = void 0;
|
|
4
|
+
const sdk_1 = require("@prezly/sdk");
|
|
5
|
+
const theme_kit_core_1 = require("@prezly/theme-kit-core");
|
|
4
6
|
class SitemapBuilder {
|
|
5
7
|
baseUrl;
|
|
6
8
|
basePath;
|
|
9
|
+
usedLanguages;
|
|
7
10
|
urls = [];
|
|
8
|
-
constructor(baseUrl, basePath) {
|
|
11
|
+
constructor(baseUrl, basePath, languages) {
|
|
9
12
|
this.baseUrl = baseUrl;
|
|
10
13
|
this.basePath = basePath;
|
|
14
|
+
// Sort languages to place the default language first
|
|
15
|
+
this.usedLanguages = (0, theme_kit_core_1.getUsedLanguages)(languages).sort((a, b) => {
|
|
16
|
+
if (a.is_default)
|
|
17
|
+
return -1;
|
|
18
|
+
if (b.is_default)
|
|
19
|
+
return 1;
|
|
20
|
+
return 0;
|
|
21
|
+
});
|
|
11
22
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
buildUrl(location, localeCode) {
|
|
24
|
+
const shortestLocaleCode = localeCode
|
|
25
|
+
? (0, theme_kit_core_1.getShortestLocaleCode)(this.usedLanguages, theme_kit_core_1.LocaleObject.fromAnyCode(localeCode))
|
|
26
|
+
: false;
|
|
27
|
+
const basePart = this.basePath ?? '';
|
|
28
|
+
const localePart = shortestLocaleCode
|
|
29
|
+
? `/${theme_kit_core_1.LocaleObject.fromAnyCode(shortestLocaleCode).toUrlSlug()}`
|
|
30
|
+
: '';
|
|
31
|
+
const finalPart = (basePart || localePart) && location === '/' ? '' : location;
|
|
32
|
+
return this.baseUrl + basePart + localePart + finalPart;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Add a non-dynamic URL to the sitemap (e.g. `/` or `/media`)
|
|
36
|
+
* The URL will be added once for each used locale on the site, with proper locale code part.
|
|
37
|
+
*/
|
|
38
|
+
addPageUrl(url) {
|
|
39
|
+
this.usedLanguages.forEach(({ code }) => {
|
|
40
|
+
this.urls.push({
|
|
41
|
+
location: this.buildUrl(url, code),
|
|
42
|
+
changeFrequency: SitemapBuilder.guessFrequency(url),
|
|
43
|
+
priority: SitemapBuilder.guessPriority(url),
|
|
44
|
+
alternateLinks: this.usedLanguages.map((language) => ({
|
|
45
|
+
href: this.buildUrl(url, language.code),
|
|
46
|
+
lang: theme_kit_core_1.LocaleObject.fromAnyCode(language.code).toUrlSlug(),
|
|
47
|
+
})),
|
|
48
|
+
});
|
|
49
|
+
});
|
|
19
50
|
}
|
|
20
|
-
|
|
51
|
+
addStoryUrl(story) {
|
|
52
|
+
const url = `/${story.slug}`;
|
|
53
|
+
// De-dupe translations and only include locales that are enabled on the site
|
|
54
|
+
const translationsMap = story.translations.reduce((map, translation) => {
|
|
55
|
+
if (this.usedLanguages.some(({ code }) => code === translation.culture.code) &&
|
|
56
|
+
translation.status === 'published') {
|
|
57
|
+
map.set(translation.culture.code, translation);
|
|
58
|
+
}
|
|
59
|
+
return map;
|
|
60
|
+
}, new Map());
|
|
61
|
+
// Include the original story to display it in alternate links
|
|
62
|
+
translationsMap.set(story.culture.code, story);
|
|
63
|
+
const translations = Array.from(translationsMap.values());
|
|
21
64
|
this.urls.push({
|
|
22
|
-
location: this.
|
|
23
|
-
changeFrequency: SitemapBuilder.guessFrequency(
|
|
24
|
-
priority: SitemapBuilder.guessPriority(
|
|
65
|
+
location: this.buildUrl(`/${story.slug}`),
|
|
66
|
+
changeFrequency: SitemapBuilder.guessFrequency(url),
|
|
67
|
+
priority: SitemapBuilder.guessPriority(url),
|
|
68
|
+
...(translations.length > 1 && {
|
|
69
|
+
alternateLinks: translations.map((translatedStory) => ({
|
|
70
|
+
href: this.buildUrl(`/${translatedStory.slug}`),
|
|
71
|
+
lang: theme_kit_core_1.LocaleObject.fromAnyCode(translatedStory.culture.code).toUrlSlug(),
|
|
72
|
+
})),
|
|
73
|
+
}),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
addCategoryUrl(category) {
|
|
77
|
+
// De-dupe translations and only include locales that are enabled on the site
|
|
78
|
+
const translationsMap = Object.values(category.i18n).reduce((map, translation) => {
|
|
79
|
+
if (this.usedLanguages.some(({ code }) => code === translation.locale.code)) {
|
|
80
|
+
map.set(translation.locale.code, translation);
|
|
81
|
+
}
|
|
82
|
+
return map;
|
|
83
|
+
}, new Map());
|
|
84
|
+
const translations = Array.from(translationsMap.values());
|
|
85
|
+
this.usedLanguages.forEach(({ code }) => {
|
|
86
|
+
const translatedCategory = sdk_1.Category.translation(category, code);
|
|
87
|
+
if (translatedCategory) {
|
|
88
|
+
const url = `/category/${translatedCategory.slug}`;
|
|
89
|
+
this.urls.push({
|
|
90
|
+
location: this.buildUrl(url, code),
|
|
91
|
+
changeFrequency: SitemapBuilder.guessFrequency(url),
|
|
92
|
+
priority: SitemapBuilder.guessPriority(url),
|
|
93
|
+
...(translations.length > 1 && {
|
|
94
|
+
alternateLinks: translations.map((translation) => ({
|
|
95
|
+
href: this.buildUrl(`/category/${translation.slug}`, translation.locale.code),
|
|
96
|
+
lang: theme_kit_core_1.LocaleObject.fromAnyCode(translation.locale.code).toUrlSlug(),
|
|
97
|
+
})),
|
|
98
|
+
}),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
25
101
|
});
|
|
26
102
|
}
|
|
103
|
+
// TODO: Allow specyfying changeFrequency and priority externally
|
|
27
104
|
static guessFrequency(location) {
|
|
28
105
|
if (location === '/')
|
|
29
106
|
return 'daily';
|
|
@@ -43,6 +120,7 @@ class SitemapBuilder {
|
|
|
43
120
|
url.location && `\t<loc>${url.location}</loc>`,
|
|
44
121
|
url.changeFrequency && `\t<changefreq>${url.changeFrequency}</changefreq>`,
|
|
45
122
|
url.priority && `\t<priority>${url.priority}</priority>`,
|
|
123
|
+
url.alternateLinks?.map(({ lang, href }) => `\t<xhtml:link rel="alternate" hreflang="${lang}" href="${href}"/>`),
|
|
46
124
|
'</url>',
|
|
47
125
|
]
|
|
48
126
|
.filter(Boolean)
|
|
@@ -51,7 +129,7 @@ class SitemapBuilder {
|
|
|
51
129
|
serialize() {
|
|
52
130
|
return [
|
|
53
131
|
'<?xml version="1.0" encoding="UTF-8" ?>',
|
|
54
|
-
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns
|
|
132
|
+
'<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.w3.org/TR/xhtml11/xhtml11_schema.html http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/TR/xhtml11/xhtml11_schema.html">',
|
|
55
133
|
this.urls.map(SitemapBuilder.serializeLocation).join('\n'),
|
|
56
134
|
'</urlset>',
|
|
57
135
|
].join('\n');
|