@prezly/theme-kit-nextjs 2.0.0-0 → 2.0.0-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 +8 -13
- package/build/@types/global.d.js +1 -0
- package/build/adapter-nextjs/api-handlers/fetchGalleries.js +26 -18
- package/build/adapter-nextjs/api-handlers/fetchStories.js +36 -20
- package/build/adapter-nextjs/api-handlers/index.js +2 -3
- package/build/adapter-nextjs/getNewsroomServerSideProps.js +15 -10
- package/build/adapter-nextjs/getNewsroomStaticProps.js +14 -10
- package/build/adapter-nextjs/index.js +6 -7
- package/build/adapter-nextjs/page-props/category.js +115 -91
- package/build/adapter-nextjs/page-props/gallery.js +85 -61
- package/build/adapter-nextjs/page-props/galleryAlbum.js +61 -44
- package/build/adapter-nextjs/page-props/home.js +81 -62
- package/build/adapter-nextjs/page-props/index.js +8 -9
- package/build/adapter-nextjs/page-props/lib/types.js +1 -2
- package/build/adapter-nextjs/page-props/search.js +23 -24
- package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js +28 -45
- package/build/adapter-nextjs/page-props/sitemap/createPaths.js +12 -14
- package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js +32 -30
- package/build/adapter-nextjs/page-props/sitemap/index.js +4 -5
- package/build/adapter-nextjs/page-props/sitemap/types.js +1 -2
- package/build/adapter-nextjs/page-props/story.js +74 -55
- package/build/adapter-nextjs/page-props/storyPreview.js +26 -21
- package/build/adapter-nextjs/processRequest.js +33 -20
- package/build/adapter-nextjs/processStaticRequest.js +18 -11
- package/build/components-nextjs/PageSeo/PageSeo.js +81 -71
- package/build/components-nextjs/PageSeo/index.js +2 -3
- package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js +4 -5
- package/build/components-nextjs/PageSeo/lib/types.js +1 -2
- package/build/components-nextjs/StorySeo/StorySeo.js +67 -41
- package/build/components-nextjs/StorySeo/index.js +1 -2
- package/build/components-nextjs/document.js +29 -19
- package/build/components-nextjs/index.js +3 -4
- package/build/data-fetching/api/PrezlyApi.js +205 -185
- package/build/data-fetching/api/getPrezlyApi.js +20 -16
- package/build/data-fetching/api/index.js +1 -2
- package/build/data-fetching/api/queries.js +71 -34
- package/build/data-fetching/index.js +3 -4
- package/build/data-fetching/lib/getAlgoliaSettings.js +21 -17
- package/build/data-fetching/lib/getEnvVariables.js +33 -29
- package/build/data-fetching/lib/index.js +4 -5
- package/build/data-fetching/lib/isSdkError.js +2 -3
- package/build/data-fetching/lib/isUuid.js +2 -3
- package/build/data-fetching/types.js +1 -2
- package/build/index.js +9 -10
- package/build/infinite-loading/index.js +4 -5
- package/build/infinite-loading/types.js +1 -2
- package/build/infinite-loading/useInfiniteGalleriesLoading.js +41 -32
- package/build/infinite-loading/useInfiniteLoading.js +48 -37
- package/build/infinite-loading/useInfiniteStoriesLoading.js +54 -44
- package/build/intl/index.d.ts +1 -1
- package/build/intl/index.js +4 -5
- package/build/intl/index.js.map +1 -1
- package/build/intl/languages.js +135 -97
- package/build/intl/languages.js.map +1 -1
- package/build/intl/locale.d.ts +0 -1
- package/build/intl/locale.js +47 -97
- package/build/intl/locale.js.map +1 -1
- package/build/intl/localeConfig.d.ts +3 -1
- package/build/intl/localeConfig.js +20 -13
- package/build/intl/localeConfig.js.map +1 -1
- package/build/intl/localeList.js +1 -108
- package/build/intl/localeObject.js +79 -74
- package/build/intl/localeObject.js.map +1 -1
- package/build/newsroom-context/context.js +34 -20
- package/build/newsroom-context/hooks/index.js +11 -12
- package/build/newsroom-context/hooks/useAlgoliaSettings.js +4 -5
- package/build/newsroom-context/hooks/useCategories.js +4 -5
- package/build/newsroom-context/hooks/useCompanyInformation.js +4 -5
- package/build/newsroom-context/hooks/useCurrentCategory.js +4 -5
- package/build/newsroom-context/hooks/useCurrentLocale.js +4 -5
- package/build/newsroom-context/hooks/useCurrentStory.js +4 -5
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js +15 -15
- package/build/newsroom-context/hooks/useGetTranslationUrl.js +48 -44
- package/build/newsroom-context/hooks/useLanguages.js +4 -5
- package/build/newsroom-context/hooks/useNewsroom.js +4 -5
- package/build/newsroom-context/hooks/useNewsroomContext.js +9 -10
- package/build/newsroom-context/index.js +2 -3
- package/build/sentry/client.js +3 -4
- package/build/sentry/common.js +25 -24
- package/build/sentry/index.js +2 -3
- package/build/sentry/server.js +3 -4
- package/build/types.js +1 -2
- package/build/utils/boilerplate.js +4 -13
- package/build/utils/constants.js +1 -2
- package/build/utils/getAssetsUrl.js +3 -4
- package/build/utils/getDataRequestLink.js +5 -7
- package/build/utils/getLocalizedCategoryData.js +30 -24
- package/build/utils/getNewsroomLogoUrl.js +12 -13
- package/build/utils/getPrivacyPortalUrl.js +10 -8
- package/build/utils/getStoryPublicationDate.js +8 -9
- package/build/utils/getUploadcareGroupUrl.js +4 -5
- package/build/utils/index.js +10 -11
- package/build/utils/isEmbargoStory.js +2 -3
- package/package.json +17 -2
- package/build/tsconfig.tsbuildinfo +0 -1
|
@@ -1,49 +1,66 @@
|
|
|
1
|
-
import { getPrezlyApi } from
|
|
2
|
-
import { getNewsroomServerSideProps } from
|
|
3
|
-
import { getNewsroomStaticProps } from
|
|
4
|
-
import { processRequest } from
|
|
5
|
-
import { processStaticRequest } from
|
|
1
|
+
import { getPrezlyApi } from "../../data-fetching/index.js";
|
|
2
|
+
import { getNewsroomServerSideProps } from "../getNewsroomServerSideProps.js";
|
|
3
|
+
import { getNewsroomStaticProps } from "../getNewsroomStaticProps.js";
|
|
4
|
+
import { processRequest } from "../processRequest.js";
|
|
5
|
+
import { processStaticRequest } from "../processStaticRequest.js";
|
|
6
6
|
export function getGalleryAlbumPageServerSideProps(customProps) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
return async function getServerSideProps(context) {
|
|
8
|
+
const {
|
|
9
|
+
api,
|
|
10
|
+
serverSideProps
|
|
11
|
+
} = await getNewsroomServerSideProps(context);
|
|
12
|
+
const {
|
|
13
|
+
uuid
|
|
14
|
+
} = context.params;
|
|
15
|
+
const gallery = await api.getGallery(uuid);
|
|
16
|
+
if (!gallery || !gallery.images_number) {
|
|
17
|
+
return {
|
|
18
|
+
notFound: true
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return processRequest(context, {
|
|
22
|
+
...serverSideProps,
|
|
23
|
+
gallery,
|
|
24
|
+
...(typeof customProps === 'function' ? await customProps(context, serverSideProps) : customProps)
|
|
25
|
+
}, `/media/album/${uuid}`);
|
|
26
|
+
};
|
|
22
27
|
}
|
|
23
28
|
export function getGalleryAlbumPageStaticProps(customProps) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
return async function getStaticProps(context) {
|
|
30
|
+
const {
|
|
31
|
+
api,
|
|
32
|
+
staticProps
|
|
33
|
+
} = await getNewsroomStaticProps(context);
|
|
34
|
+
const {
|
|
35
|
+
uuid
|
|
36
|
+
} = context.params;
|
|
37
|
+
const gallery = await api.getGallery(uuid);
|
|
38
|
+
if (!gallery || !gallery.images_number) {
|
|
39
|
+
return {
|
|
40
|
+
notFound: true
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return processStaticRequest(context, {
|
|
44
|
+
...staticProps,
|
|
45
|
+
gallery,
|
|
46
|
+
...(typeof customProps === 'function' ? await customProps(context, staticProps) : customProps)
|
|
47
|
+
});
|
|
48
|
+
};
|
|
39
49
|
}
|
|
40
50
|
export async function getGalleryAlbumPageStaticPaths() {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
const api = getPrezlyApi();
|
|
52
|
+
const {
|
|
53
|
+
galleries
|
|
54
|
+
} = await api.getGalleries({});
|
|
55
|
+
const paths = galleries.map(({
|
|
56
|
+
uuid
|
|
57
|
+
}) => ({
|
|
58
|
+
params: {
|
|
59
|
+
uuid
|
|
60
|
+
}
|
|
61
|
+
}));
|
|
62
|
+
return {
|
|
63
|
+
paths,
|
|
64
|
+
fallback: 'blocking'
|
|
65
|
+
};
|
|
66
|
+
}
|
|
@@ -1,65 +1,84 @@
|
|
|
1
|
-
import { DEFAULT_PAGE_SIZE } from
|
|
2
|
-
import { getNewsroomServerSideProps } from
|
|
3
|
-
import { getNewsroomStaticProps } from
|
|
4
|
-
import { processRequest } from
|
|
5
|
-
import { processStaticRequest } from
|
|
1
|
+
import { DEFAULT_PAGE_SIZE } from "../../utils/index.js";
|
|
2
|
+
import { getNewsroomServerSideProps } from "../getNewsroomServerSideProps.js";
|
|
3
|
+
import { getNewsroomStaticProps } from "../getNewsroomStaticProps.js";
|
|
4
|
+
import { processRequest } from "../processRequest.js";
|
|
5
|
+
import { processStaticRequest } from "../processStaticRequest.js";
|
|
6
6
|
export function getHomepageServerSideProps(customProps, options) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
7
|
+
const {
|
|
8
|
+
pageSize = DEFAULT_PAGE_SIZE,
|
|
9
|
+
extraStoryFields
|
|
10
|
+
} = options || {};
|
|
11
|
+
return async function getServerSideProps(context) {
|
|
12
|
+
const {
|
|
13
|
+
api,
|
|
14
|
+
serverSideProps
|
|
15
|
+
} = await getNewsroomServerSideProps(context, {
|
|
16
|
+
loadHomepageContacts: true
|
|
17
|
+
});
|
|
18
|
+
const {
|
|
19
|
+
query
|
|
20
|
+
} = context;
|
|
21
|
+
const page = query.page && typeof query.page === 'string' ? Number(query.page) : undefined;
|
|
22
|
+
const {
|
|
23
|
+
localeCode
|
|
24
|
+
} = serverSideProps.newsroomContextProps;
|
|
25
|
+
const storiesPaginated = await api.getStories({
|
|
26
|
+
page,
|
|
27
|
+
pageSize,
|
|
28
|
+
include: extraStoryFields,
|
|
29
|
+
localeCode
|
|
30
|
+
});
|
|
31
|
+
const {
|
|
32
|
+
stories,
|
|
33
|
+
storiesTotal
|
|
34
|
+
} = storiesPaginated;
|
|
35
|
+
return processRequest(context, {
|
|
36
|
+
...serverSideProps,
|
|
37
|
+
// TODO: This is temporary until return types from API are figured out
|
|
38
|
+
stories: stories,
|
|
39
|
+
pagination: {
|
|
40
|
+
itemsTotal: storiesTotal,
|
|
41
|
+
currentPage: page ?? 1,
|
|
42
|
+
pageSize
|
|
43
|
+
},
|
|
44
|
+
...(typeof customProps === 'function' ? await customProps(context, serverSideProps) : customProps)
|
|
45
|
+
}, '/');
|
|
46
|
+
};
|
|
36
47
|
}
|
|
37
48
|
export function getHomepageStaticProps(customProps, options) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
49
|
+
const {
|
|
50
|
+
pageSize = DEFAULT_PAGE_SIZE,
|
|
51
|
+
extraStoryFields
|
|
52
|
+
} = options || {};
|
|
53
|
+
return async function getStaticProps(context) {
|
|
54
|
+
const {
|
|
55
|
+
api,
|
|
56
|
+
staticProps
|
|
57
|
+
} = await getNewsroomStaticProps(context, {
|
|
58
|
+
loadHomepageContacts: true
|
|
59
|
+
});
|
|
60
|
+
const {
|
|
61
|
+
localeCode
|
|
62
|
+
} = staticProps.newsroomContextProps;
|
|
63
|
+
const storiesPaginated = await api.getStories({
|
|
64
|
+
pageSize,
|
|
65
|
+
include: extraStoryFields,
|
|
66
|
+
localeCode
|
|
67
|
+
});
|
|
68
|
+
const {
|
|
69
|
+
stories,
|
|
70
|
+
storiesTotal
|
|
71
|
+
} = storiesPaginated;
|
|
72
|
+
return processStaticRequest(context, {
|
|
73
|
+
...staticProps,
|
|
74
|
+
// TODO: This is temporary until return types from API are figured out
|
|
75
|
+
stories: stories,
|
|
76
|
+
pagination: {
|
|
77
|
+
itemsTotal: storiesTotal,
|
|
78
|
+
currentPage: 1,
|
|
79
|
+
pageSize
|
|
80
|
+
},
|
|
81
|
+
...(typeof customProps === 'function' ? await customProps(context, staticProps) : customProps)
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
export { getCategoryPageServerSideProps, getCategoryPageStaticPaths, getCategoryPageStaticProps
|
|
2
|
-
export { getGalleryPageServerSideProps, getGalleryPageStaticProps
|
|
3
|
-
export { getGalleryAlbumPageServerSideProps, getGalleryAlbumPageStaticPaths, getGalleryAlbumPageStaticProps
|
|
4
|
-
export { getHomepageServerSideProps, getHomepageStaticProps } from
|
|
5
|
-
export { getSearchPageServerSideProps, getSearchPageStaticProps } from
|
|
6
|
-
export * from
|
|
7
|
-
export { getStoryPageServerSideProps, getStoryPageStaticPaths, getStoryPageStaticProps
|
|
8
|
-
export { getStoryPreviewPageServerSideProps } from
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { getCategoryPageServerSideProps, getCategoryPageStaticPaths, getCategoryPageStaticProps } from "./category.js";
|
|
2
|
+
export { getGalleryPageServerSideProps, getGalleryPageStaticProps } from "./gallery.js";
|
|
3
|
+
export { getGalleryAlbumPageServerSideProps, getGalleryAlbumPageStaticPaths, getGalleryAlbumPageStaticProps } from "./galleryAlbum.js";
|
|
4
|
+
export { getHomepageServerSideProps, getHomepageStaticProps } from "./home.js";
|
|
5
|
+
export { getSearchPageServerSideProps, getSearchPageStaticProps } from "./search.js";
|
|
6
|
+
export * from "./sitemap/index.js";
|
|
7
|
+
export { getStoryPageServerSideProps, getStoryPageStaticPaths, getStoryPageStaticProps } from "./story.js";
|
|
8
|
+
export { getStoryPreviewPageServerSideProps } from "./storyPreview.js";
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
//# sourceMappingURL=types.js.map
|
|
1
|
+
export {};
|
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
import { getNewsroomServerSideProps } from
|
|
2
|
-
import { getNewsroomStaticProps } from
|
|
3
|
-
import { processRequest } from
|
|
4
|
-
import { processStaticRequest } from
|
|
1
|
+
import { getNewsroomServerSideProps } from "../getNewsroomServerSideProps.js";
|
|
2
|
+
import { getNewsroomStaticProps } from "../getNewsroomStaticProps.js";
|
|
3
|
+
import { processRequest } from "../processRequest.js";
|
|
4
|
+
import { processStaticRequest } from "../processStaticRequest.js";
|
|
5
5
|
export function getSearchPageServerSideProps(customProps) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
return async function getServerSideProps(context) {
|
|
7
|
+
const {
|
|
8
|
+
serverSideProps
|
|
9
|
+
} = await getNewsroomServerSideProps(context);
|
|
10
|
+
return processRequest(context, {
|
|
11
|
+
...serverSideProps,
|
|
12
|
+
...(typeof customProps === 'function' ? await customProps(context, serverSideProps) : customProps)
|
|
13
|
+
}, '/search');
|
|
14
|
+
};
|
|
15
15
|
}
|
|
16
16
|
export function getSearchPageStaticProps(customProps) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=search.js.map
|
|
17
|
+
return async function getStaticProps(context) {
|
|
18
|
+
const {
|
|
19
|
+
staticProps
|
|
20
|
+
} = await getNewsroomStaticProps(context);
|
|
21
|
+
return processStaticRequest(context, {
|
|
22
|
+
...staticProps,
|
|
23
|
+
...(typeof customProps === 'function' ? await customProps(context, staticProps) : customProps)
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -1,47 +1,30 @@
|
|
|
1
1
|
export class SitemapBuilder {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
urls = [];
|
|
3
|
+
constructor(baseUrl) {
|
|
4
|
+
this.baseUrl = baseUrl;
|
|
5
|
+
}
|
|
6
|
+
addUrl(location) {
|
|
7
|
+
this.urls.push({
|
|
8
|
+
location: this.baseUrl + location,
|
|
9
|
+
changeFrequency: SitemapBuilder.guessFrequency(location),
|
|
10
|
+
priority: SitemapBuilder.guessPriority(location)
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
static guessFrequency(location) {
|
|
14
|
+
if (location === '/') return 'daily';
|
|
15
|
+
return 'weekly';
|
|
16
|
+
}
|
|
17
|
+
static guessPriority(location) {
|
|
18
|
+
if (location === '/') return '0.9';
|
|
19
|
+
if (location.startsWith('/category/')) {
|
|
20
|
+
return '0.8';
|
|
6
21
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
|
22
|
+
return '0.7';
|
|
23
|
+
}
|
|
24
|
+
static serializeLocation(url) {
|
|
25
|
+
return ['<url>', url.location && `\t<loc>${url.location}</loc>`, url.changeFrequency && `\t<changefreq>${url.changeFrequency}</changefreq>`, url.priority && `\t<priority>${url.priority}</priority>`, '</url>'].filter(Boolean).join('\n');
|
|
26
|
+
}
|
|
27
|
+
serialize() {
|
|
28
|
+
return ['<?xml version="1.0" encoding="UTF-8" ?>', '<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">', this.urls.map(SitemapBuilder.serializeLocation).join('\n'), '</urlset>'].join('\n');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
export function createPaths(stories, categories) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=createPaths.js.map
|
|
2
|
+
const storiesUrls = stories.map(({
|
|
3
|
+
slug
|
|
4
|
+
}) => `/${slug}`);
|
|
5
|
+
const categoriesUrls = categories.map(category => {
|
|
6
|
+
const translations = Object.values(category.i18n);
|
|
7
|
+
const allSlugs = translations.map(({
|
|
8
|
+
slug
|
|
9
|
+
}) => slug || '').filter(Boolean).reduce((slugs, slug) => slugs.includes(slug) ? [...slugs] : [...slugs, slug], []);
|
|
10
|
+
return allSlugs.map(slug => `/category/${slug}`);
|
|
11
|
+
}).flat();
|
|
12
|
+
return [...storiesUrls, ...categoriesUrls];
|
|
13
|
+
}
|
|
@@ -1,32 +1,34 @@
|
|
|
1
|
-
import { getPrezlyApi } from
|
|
2
|
-
import { createPaths } from
|
|
3
|
-
import { SitemapBuilder } from
|
|
1
|
+
import { getPrezlyApi } from "../../../data-fetching/index.js";
|
|
2
|
+
import { createPaths } from "./createPaths.js";
|
|
3
|
+
import { SitemapBuilder } from "./SitemapBuilder.js";
|
|
4
4
|
export function getSitemapServerSideProps(additionalPaths) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
5
|
+
return async function getServerSideProps(ctx) {
|
|
6
|
+
const {
|
|
7
|
+
res,
|
|
8
|
+
req
|
|
9
|
+
} = ctx;
|
|
10
|
+
if (!req || !res) {
|
|
11
|
+
// client side
|
|
12
|
+
return {
|
|
13
|
+
props: {}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const baseUrl = req.headers.host || '/';
|
|
17
|
+
const api = getPrezlyApi(req);
|
|
18
|
+
const stories = await api.getAllStories();
|
|
19
|
+
const categories = await api.getCategories();
|
|
20
|
+
const paths = createPaths(stories, categories);
|
|
21
|
+
const sitemapBuilder = new SitemapBuilder(baseUrl);
|
|
22
|
+
sitemapBuilder.addUrl('/');
|
|
23
|
+
paths.forEach(path => sitemapBuilder.addUrl(path));
|
|
24
|
+
if (additionalPaths) {
|
|
25
|
+
additionalPaths.forEach(path => sitemapBuilder.addUrl(path));
|
|
26
|
+
}
|
|
27
|
+
res.setHeader('Content-Type', 'text/xml');
|
|
28
|
+
res.write(sitemapBuilder.serialize());
|
|
29
|
+
res.end();
|
|
30
|
+
return {
|
|
31
|
+
props: {}
|
|
30
32
|
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export { getSitemapServerSideProps } from
|
|
2
|
-
export { SitemapBuilder } from
|
|
3
|
-
export { createPaths } from
|
|
4
|
-
export * from
|
|
5
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { getSitemapServerSideProps } from "./getServerSideProps.js";
|
|
2
|
+
export { SitemapBuilder } from "./SitemapBuilder.js";
|
|
3
|
+
export { createPaths } from "./createPaths.js";
|
|
4
|
+
export * from "./types.js";
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
//# sourceMappingURL=types.js.map
|
|
1
|
+
export {};
|