@prezly/theme-kit-nextjs 2.0.0-0 → 2.0.0-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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.js +4 -5
- package/build/intl/languages.js +135 -97
- package/build/intl/locale.js +46 -95
- package/build/intl/localeConfig.js +7 -13
- package/build/intl/localeList.js +1 -108
- package/build/intl/localeObject.js +79 -74
- 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 +10 -2
- package/build/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,19 +1,27 @@
|
|
|
1
|
-
import { getPrezlyApi } from
|
|
1
|
+
import { getPrezlyApi } from "../../data-fetching/index.js";
|
|
2
2
|
export async function fetchGalleries(req, res) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
3
|
+
if (req.method !== 'POST') {
|
|
4
|
+
res.status(405);
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const {
|
|
8
|
+
page,
|
|
9
|
+
pageSize
|
|
10
|
+
} = req.body;
|
|
11
|
+
try {
|
|
12
|
+
const api = getPrezlyApi(req);
|
|
13
|
+
const {
|
|
14
|
+
galleries
|
|
15
|
+
} = await api.getGalleries({
|
|
16
|
+
page,
|
|
17
|
+
pageSize
|
|
18
|
+
});
|
|
19
|
+
res.status(200).json({
|
|
20
|
+
galleries
|
|
21
|
+
});
|
|
22
|
+
} catch (error) {
|
|
23
|
+
res.status(500).send({
|
|
24
|
+
message: error.message
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,21 +1,37 @@
|
|
|
1
|
-
import { getPrezlyApi } from
|
|
1
|
+
import { getPrezlyApi } from "../../data-fetching/index.js";
|
|
2
2
|
export async function fetchStories(req, res) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
3
|
+
if (req.method !== 'POST') {
|
|
4
|
+
res.status(405);
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const {
|
|
8
|
+
page,
|
|
9
|
+
pageSize,
|
|
10
|
+
category,
|
|
11
|
+
include,
|
|
12
|
+
localeCode
|
|
13
|
+
} = req.body;
|
|
14
|
+
try {
|
|
15
|
+
const api = getPrezlyApi(req);
|
|
16
|
+
const {
|
|
17
|
+
stories
|
|
18
|
+
} = await (category ? api.getStoriesFromCategory(category, {
|
|
19
|
+
page,
|
|
20
|
+
pageSize,
|
|
21
|
+
include,
|
|
22
|
+
localeCode
|
|
23
|
+
}) : api.getStories({
|
|
24
|
+
page,
|
|
25
|
+
pageSize,
|
|
26
|
+
include,
|
|
27
|
+
localeCode
|
|
28
|
+
}));
|
|
29
|
+
res.status(200).json({
|
|
30
|
+
stories
|
|
31
|
+
});
|
|
32
|
+
} catch (error) {
|
|
33
|
+
res.status(500).send({
|
|
34
|
+
message: error.message
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export { fetchGalleries } from
|
|
2
|
-
export { fetchStories } from
|
|
3
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { fetchGalleries } from "./fetchGalleries.js";
|
|
2
|
+
export { fetchStories } from "./fetchStories.js";
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import { getPrezlyApi } from
|
|
1
|
+
import { getPrezlyApi } from "../data-fetching/index.js";
|
|
2
2
|
/**
|
|
3
3
|
* Use this function in your `getServerSideProps` page methods to retrieve the data necessary for the NewsroomContextProvider and `processRequest` function.
|
|
4
4
|
* See README for usage examples.
|
|
5
5
|
*/
|
|
6
6
|
export async function getNewsroomServerSideProps(context, options = {}) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
const {
|
|
8
|
+
req: request,
|
|
9
|
+
locale
|
|
10
|
+
} = context;
|
|
11
|
+
const api = getPrezlyApi(request);
|
|
12
|
+
const serverSideProps = await api.getNewsroomServerSideProps(request, locale, options.story);
|
|
13
|
+
if (options.loadHomepageContacts) {
|
|
14
|
+
serverSideProps.newsroomContextProps.contacts = await api.getNewsroomContacts();
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
api,
|
|
18
|
+
serverSideProps
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import { getPrezlyApi } from
|
|
1
|
+
import { getPrezlyApi } from "../data-fetching/index.js";
|
|
2
2
|
/**
|
|
3
3
|
* Use this function in your `getNewsroomStaticProps` page methods to retrieve the data necessary for the NewsroomContextProvider and `processRequest` function.
|
|
4
4
|
* See README for usage examples.
|
|
5
5
|
*/
|
|
6
6
|
export async function getNewsroomStaticProps(context, options = {}) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
7
|
+
const {
|
|
8
|
+
locale
|
|
9
|
+
} = context;
|
|
10
|
+
const api = getPrezlyApi();
|
|
11
|
+
const staticProps = await api.getNewsroomServerSideProps(undefined, locale, options.story);
|
|
12
|
+
if (options.loadHomepageContacts) {
|
|
13
|
+
staticProps.newsroomContextProps.contacts = await api.getNewsroomContacts();
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
api,
|
|
17
|
+
staticProps
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from "./api-handlers/index.js";
|
|
2
|
+
export * from "./getNewsroomServerSideProps.js";
|
|
3
|
+
export * from "./getNewsroomStaticProps.js";
|
|
4
|
+
export * from "./page-props/index.js";
|
|
5
|
+
export * from "./processRequest.js";
|
|
6
|
+
export * from "./processStaticRequest.js";
|
|
@@ -1,98 +1,122 @@
|
|
|
1
|
-
import { getPrezlyApi } from
|
|
2
|
-
import { LocaleObject } from
|
|
3
|
-
import { DEFAULT_PAGE_SIZE, getLocalizedCategoryData } from
|
|
4
|
-
import { getNewsroomServerSideProps } from
|
|
5
|
-
import { getNewsroomStaticProps } from
|
|
6
|
-
import { processRequest } from
|
|
7
|
-
import { processStaticRequest } from
|
|
1
|
+
import { getPrezlyApi } from "../../data-fetching/index.js";
|
|
2
|
+
import { LocaleObject } from "../../intl/index.js";
|
|
3
|
+
import { DEFAULT_PAGE_SIZE, getLocalizedCategoryData } from "../../utils/index.js";
|
|
4
|
+
import { getNewsroomServerSideProps } from "../getNewsroomServerSideProps.js";
|
|
5
|
+
import { getNewsroomStaticProps } from "../getNewsroomStaticProps.js";
|
|
6
|
+
import { processRequest } from "../processRequest.js";
|
|
7
|
+
import { processStaticRequest } from "../processStaticRequest.js";
|
|
8
8
|
export function getCategoryPageServerSideProps(customProps, options) {
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
9
|
+
const {
|
|
10
|
+
pageSize = DEFAULT_PAGE_SIZE,
|
|
11
|
+
extraStoryFields
|
|
12
|
+
} = options || {};
|
|
13
|
+
return async function getServerSideProps(context) {
|
|
14
|
+
const {
|
|
15
|
+
api,
|
|
16
|
+
serverSideProps
|
|
17
|
+
} = await getNewsroomServerSideProps(context);
|
|
18
|
+
const {
|
|
19
|
+
slug
|
|
20
|
+
} = context.params;
|
|
21
|
+
const category = await api.getCategoryBySlug(slug);
|
|
22
|
+
if (!category) {
|
|
23
|
+
return {
|
|
24
|
+
notFound: true
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const {
|
|
28
|
+
query
|
|
29
|
+
} = context;
|
|
30
|
+
const page = query.page && typeof query.page === 'string' ? Number(query.page) : undefined;
|
|
31
|
+
const {
|
|
32
|
+
localeCode
|
|
33
|
+
} = serverSideProps.newsroomContextProps;
|
|
34
|
+
const {
|
|
35
|
+
stories,
|
|
36
|
+
storiesTotal
|
|
37
|
+
} = await api.getStoriesFromCategory(category, {
|
|
38
|
+
page,
|
|
39
|
+
pageSize,
|
|
40
|
+
include: extraStoryFields,
|
|
41
|
+
localeCode
|
|
42
|
+
});
|
|
43
|
+
serverSideProps.newsroomContextProps.currentCategory = category;
|
|
44
|
+
return processRequest(context, {
|
|
45
|
+
...serverSideProps,
|
|
46
|
+
// TODO: This is temporary until return types from API are figured out
|
|
47
|
+
stories: stories,
|
|
48
|
+
pagination: {
|
|
49
|
+
itemsTotal: storiesTotal,
|
|
50
|
+
currentPage: page ?? 1,
|
|
51
|
+
pageSize
|
|
52
|
+
},
|
|
53
|
+
...(typeof customProps === 'function' ? await customProps(context, serverSideProps) : customProps)
|
|
54
|
+
}, `/category/${slug}`);
|
|
55
|
+
};
|
|
43
56
|
}
|
|
44
57
|
export function getCategoryPageStaticProps(customProps, options) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
58
|
+
const {
|
|
59
|
+
pageSize = DEFAULT_PAGE_SIZE,
|
|
60
|
+
extraStoryFields
|
|
61
|
+
} = options || {};
|
|
62
|
+
return async function getStaticProps(context) {
|
|
63
|
+
const {
|
|
64
|
+
api,
|
|
65
|
+
staticProps
|
|
66
|
+
} = await getNewsroomStaticProps(context);
|
|
67
|
+
const {
|
|
68
|
+
slug
|
|
69
|
+
} = context.params;
|
|
70
|
+
const category = await api.getCategoryBySlug(slug);
|
|
71
|
+
if (!category) {
|
|
72
|
+
return {
|
|
73
|
+
notFound: true
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const {
|
|
77
|
+
localeCode
|
|
78
|
+
} = staticProps.newsroomContextProps;
|
|
79
|
+
const {
|
|
80
|
+
stories,
|
|
81
|
+
storiesTotal
|
|
82
|
+
} = await api.getStoriesFromCategory(category, {
|
|
83
|
+
pageSize,
|
|
84
|
+
include: extraStoryFields,
|
|
85
|
+
localeCode
|
|
86
|
+
});
|
|
87
|
+
staticProps.newsroomContextProps.currentCategory = category;
|
|
88
|
+
return processStaticRequest(context, {
|
|
89
|
+
...staticProps,
|
|
90
|
+
// TODO: This is temporary until return types from API are figured out
|
|
91
|
+
stories: stories,
|
|
92
|
+
pagination: {
|
|
93
|
+
itemsTotal: storiesTotal,
|
|
94
|
+
currentPage: 1,
|
|
95
|
+
pageSize
|
|
96
|
+
},
|
|
97
|
+
...(typeof customProps === 'function' ? await customProps(context, staticProps) : customProps)
|
|
98
|
+
});
|
|
99
|
+
};
|
|
76
100
|
}
|
|
77
101
|
export async function getCategoryPageStaticPaths() {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return undefined;
|
|
89
|
-
}
|
|
90
|
-
return { params: { slug } };
|
|
91
|
-
})
|
|
92
|
-
.filter(Boolean);
|
|
102
|
+
const api = getPrezlyApi();
|
|
103
|
+
const [categories, defaultLanguage] = await Promise.all([api.getCategories(), api.getNewsroomDefaultLanguage()]);
|
|
104
|
+
const locale = LocaleObject.fromAnyCode(defaultLanguage.code);
|
|
105
|
+
const paths = categories.map(category => {
|
|
106
|
+
const {
|
|
107
|
+
slug
|
|
108
|
+
} = getLocalizedCategoryData(category, locale);
|
|
109
|
+
if (!slug) {
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
93
112
|
return {
|
|
94
|
-
|
|
95
|
-
|
|
113
|
+
params: {
|
|
114
|
+
slug
|
|
115
|
+
}
|
|
96
116
|
};
|
|
97
|
-
}
|
|
98
|
-
|
|
117
|
+
}).filter(Boolean);
|
|
118
|
+
return {
|
|
119
|
+
paths,
|
|
120
|
+
fallback: 'blocking'
|
|
121
|
+
};
|
|
122
|
+
}
|
|
@@ -1,66 +1,90 @@
|
|
|
1
|
-
import { DEFAULT_GALLERY_PAGE_SIZE } from
|
|
2
|
-
import { getNewsroomServerSideProps } from
|
|
3
|
-
import { getNewsroomStaticProps } from
|
|
4
|
-
import { processRequest } from
|
|
5
|
-
import { processStaticRequest } from
|
|
1
|
+
import { DEFAULT_GALLERY_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 getGalleryPageServerSideProps(customProps, options) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
const {
|
|
8
|
+
pageSize = DEFAULT_GALLERY_PAGE_SIZE
|
|
9
|
+
} = options || {};
|
|
10
|
+
return async function getServerSideProps(context) {
|
|
11
|
+
const {
|
|
12
|
+
api,
|
|
13
|
+
serverSideProps
|
|
14
|
+
} = await getNewsroomServerSideProps(context);
|
|
15
|
+
const {
|
|
16
|
+
query
|
|
17
|
+
} = context;
|
|
18
|
+
const page = query.page && typeof query.page === 'string' ? Number(query.page) : undefined;
|
|
19
|
+
const {
|
|
20
|
+
galleries,
|
|
21
|
+
pagination
|
|
22
|
+
} = await api.getGalleries({
|
|
23
|
+
page,
|
|
24
|
+
pageSize
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// If there's only one gallery, redirect to it immediately
|
|
28
|
+
if (galleries.length === 1) {
|
|
29
|
+
const {
|
|
30
|
+
uuid
|
|
31
|
+
} = galleries[0];
|
|
32
|
+
return {
|
|
33
|
+
redirect: {
|
|
34
|
+
destination: `/media/album/${uuid}`,
|
|
35
|
+
permanent: false
|
|
22
36
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return processRequest(context, {
|
|
40
|
+
...serverSideProps,
|
|
41
|
+
galleries,
|
|
42
|
+
pagination: {
|
|
43
|
+
itemsTotal: pagination.matched_records_number,
|
|
44
|
+
currentPage: page ?? 1,
|
|
45
|
+
pageSize
|
|
46
|
+
},
|
|
47
|
+
...(typeof customProps === 'function' ? await customProps(context, serverSideProps) : customProps)
|
|
48
|
+
}, '/media');
|
|
49
|
+
};
|
|
36
50
|
}
|
|
37
51
|
export function getGalleryPageStaticProps(customProps, options) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
const {
|
|
53
|
+
pageSize = DEFAULT_GALLERY_PAGE_SIZE
|
|
54
|
+
} = options || {};
|
|
55
|
+
return async function getStaticProps(context) {
|
|
56
|
+
const {
|
|
57
|
+
api,
|
|
58
|
+
staticProps
|
|
59
|
+
} = await getNewsroomStaticProps(context);
|
|
60
|
+
const {
|
|
61
|
+
galleries,
|
|
62
|
+
pagination
|
|
63
|
+
} = await api.getGalleries({
|
|
64
|
+
pageSize
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// If there's only one gallery, redirect to it immediately
|
|
68
|
+
if (galleries.length === 1) {
|
|
69
|
+
const {
|
|
70
|
+
uuid
|
|
71
|
+
} = galleries[0];
|
|
72
|
+
return {
|
|
73
|
+
redirect: {
|
|
74
|
+
destination: `/media/album/${uuid}`,
|
|
75
|
+
permanent: false
|
|
51
76
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=gallery.js.map
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return processStaticRequest(context, {
|
|
80
|
+
...staticProps,
|
|
81
|
+
galleries,
|
|
82
|
+
pagination: {
|
|
83
|
+
itemsTotal: pagination.matched_records_number,
|
|
84
|
+
currentPage: 1,
|
|
85
|
+
pageSize
|
|
86
|
+
},
|
|
87
|
+
...(typeof customProps === 'function' ? await customProps(context, staticProps) : customProps)
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
}
|