@prezly/theme-kit-nextjs 1.18.2 → 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 +27 -23
- package/build/adapter-nextjs/api-handlers/fetchGalleries.js.map +1 -1
- package/build/adapter-nextjs/api-handlers/fetchStories.js +37 -25
- package/build/adapter-nextjs/api-handlers/fetchStories.js.map +1 -1
- package/build/adapter-nextjs/api-handlers/index.js +2 -8
- package/build/adapter-nextjs/api-handlers/index.js.map +1 -1
- package/build/adapter-nextjs/getNewsroomServerSideProps.js +16 -15
- package/build/adapter-nextjs/getNewsroomServerSideProps.js.map +1 -1
- package/build/adapter-nextjs/getNewsroomStaticProps.js +15 -15
- package/build/adapter-nextjs/getNewsroomStaticProps.js.map +1 -1
- package/build/adapter-nextjs/index.js +6 -23
- package/build/adapter-nextjs/index.js.map +1 -1
- package/build/adapter-nextjs/page-props/category.d.ts +2 -2
- package/build/adapter-nextjs/page-props/category.js +118 -100
- package/build/adapter-nextjs/page-props/category.js.map +1 -1
- package/build/adapter-nextjs/page-props/gallery.js +87 -68
- package/build/adapter-nextjs/page-props/gallery.js.map +1 -1
- package/build/adapter-nextjs/page-props/galleryAlbum.js +64 -53
- package/build/adapter-nextjs/page-props/galleryAlbum.js.map +1 -1
- package/build/adapter-nextjs/page-props/home.d.ts +2 -2
- package/build/adapter-nextjs/page-props/home.js +83 -69
- package/build/adapter-nextjs/page-props/home.js.map +1 -1
- package/build/adapter-nextjs/page-props/index.js +8 -42
- package/build/adapter-nextjs/page-props/index.js.map +1 -1
- package/build/adapter-nextjs/page-props/lib/types.js +1 -3
- package/build/adapter-nextjs/page-props/search.js +25 -31
- package/build/adapter-nextjs/page-props/search.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js +29 -50
- package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/createPaths.js +13 -19
- package/build/adapter-nextjs/page-props/sitemap/createPaths.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js +33 -35
- package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/index.js +4 -25
- package/build/adapter-nextjs/page-props/sitemap/index.js.map +1 -1
- package/build/adapter-nextjs/page-props/sitemap/types.js +1 -3
- package/build/adapter-nextjs/page-props/story.js +77 -64
- package/build/adapter-nextjs/page-props/story.js.map +1 -1
- package/build/adapter-nextjs/page-props/storyPreview.js +27 -26
- package/build/adapter-nextjs/page-props/storyPreview.js.map +1 -1
- package/build/adapter-nextjs/processRequest.js +34 -25
- package/build/adapter-nextjs/processRequest.js.map +1 -1
- package/build/adapter-nextjs/processStaticRequest.js +19 -16
- package/build/adapter-nextjs/processStaticRequest.js.map +1 -1
- package/build/components-nextjs/PageSeo/PageSeo.js +84 -78
- package/build/components-nextjs/PageSeo/PageSeo.js.map +1 -1
- package/build/components-nextjs/PageSeo/index.js +2 -21
- package/build/components-nextjs/PageSeo/index.js.map +1 -1
- package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js +5 -10
- package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js.map +1 -1
- package/build/components-nextjs/PageSeo/lib/types.js +1 -3
- package/build/components-nextjs/StorySeo/StorySeo.js +69 -47
- package/build/components-nextjs/StorySeo/StorySeo.js.map +1 -1
- package/build/components-nextjs/StorySeo/index.js +1 -6
- package/build/components-nextjs/StorySeo/index.js.map +1 -1
- package/build/components-nextjs/document.js +31 -48
- package/build/components-nextjs/document.js.map +1 -1
- package/build/components-nextjs/index.js +3 -10
- package/build/components-nextjs/index.js.map +1 -1
- package/build/data-fetching/api/PrezlyApi.d.ts +4 -5
- package/build/data-fetching/api/PrezlyApi.js +207 -192
- package/build/data-fetching/api/PrezlyApi.js.map +1 -1
- package/build/data-fetching/api/getPrezlyApi.js +21 -21
- package/build/data-fetching/api/getPrezlyApi.js.map +1 -1
- package/build/data-fetching/api/index.js +1 -18
- package/build/data-fetching/api/index.js.map +1 -1
- package/build/data-fetching/api/queries.js +76 -47
- package/build/data-fetching/api/queries.js.map +1 -1
- package/build/data-fetching/index.js +3 -20
- package/build/data-fetching/index.js.map +1 -1
- package/build/data-fetching/lib/getAlgoliaSettings.js +22 -22
- package/build/data-fetching/lib/getAlgoliaSettings.js.map +1 -1
- package/build/data-fetching/lib/getEnvVariables.js +35 -38
- package/build/data-fetching/lib/getEnvVariables.js.map +1 -1
- package/build/data-fetching/lib/index.js +4 -12
- package/build/data-fetching/lib/index.js.map +1 -1
- package/build/data-fetching/lib/isSdkError.js +3 -8
- package/build/data-fetching/lib/isSdkError.js.map +1 -1
- package/build/data-fetching/lib/isUuid.js +3 -8
- package/build/data-fetching/lib/isUuid.js.map +1 -1
- package/build/data-fetching/types.js +1 -3
- package/build/index.js +9 -26
- package/build/index.js.map +1 -1
- package/build/infinite-loading/index.js +4 -25
- package/build/infinite-loading/index.js.map +1 -1
- package/build/infinite-loading/types.js +1 -3
- package/build/infinite-loading/useInfiniteGalleriesLoading.js +42 -37
- package/build/infinite-loading/useInfiniteGalleriesLoading.js.map +1 -1
- package/build/infinite-loading/useInfiniteLoading.js +50 -43
- package/build/infinite-loading/useInfiniteLoading.js.map +1 -1
- package/build/infinite-loading/useInfiniteStoriesLoading.d.ts +2 -2
- package/build/infinite-loading/useInfiniteStoriesLoading.js +56 -50
- package/build/infinite-loading/useInfiniteStoriesLoading.js.map +1 -1
- package/build/intl/index.d.ts +1 -1
- package/build/intl/index.js +4 -26
- package/build/intl/index.js.map +1 -1
- package/build/intl/languages.d.ts +1 -1
- package/build/intl/languages.js +146 -122
- package/build/intl/languages.js.map +1 -1
- package/build/intl/locale.js +52 -107
- package/build/intl/locale.js.map +1 -1
- package/build/intl/localeConfig.d.ts +1 -2
- package/build/intl/localeConfig.js +7 -14
- package/build/intl/localeConfig.js.map +1 -1
- package/build/intl/localeList.d.ts +4 -2
- package/build/intl/localeList.js +1 -109
- package/build/intl/localeList.js.map +1 -1
- package/build/intl/localeObject.js +80 -82
- package/build/intl/localeObject.js.map +1 -1
- package/build/newsroom-context/context.js +35 -25
- package/build/newsroom-context/context.js.map +1 -1
- package/build/newsroom-context/hooks/index.js +11 -28
- package/build/newsroom-context/hooks/index.js.map +1 -1
- package/build/newsroom-context/hooks/useAlgoliaSettings.js +5 -10
- package/build/newsroom-context/hooks/useAlgoliaSettings.js.map +1 -1
- package/build/newsroom-context/hooks/useCategories.js +5 -10
- package/build/newsroom-context/hooks/useCategories.js.map +1 -1
- package/build/newsroom-context/hooks/useCompanyInformation.js +5 -10
- package/build/newsroom-context/hooks/useCompanyInformation.js.map +1 -1
- package/build/newsroom-context/hooks/useCurrentCategory.js +5 -10
- package/build/newsroom-context/hooks/useCurrentCategory.js.map +1 -1
- package/build/newsroom-context/hooks/useCurrentLocale.js +5 -10
- package/build/newsroom-context/hooks/useCurrentLocale.js.map +1 -1
- package/build/newsroom-context/hooks/useCurrentStory.js +5 -10
- package/build/newsroom-context/hooks/useCurrentStory.js.map +1 -1
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js +17 -21
- package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js.map +1 -1
- package/build/newsroom-context/hooks/useGetTranslationUrl.js +52 -55
- package/build/newsroom-context/hooks/useGetTranslationUrl.js.map +1 -1
- package/build/newsroom-context/hooks/useLanguages.js +5 -10
- package/build/newsroom-context/hooks/useLanguages.js.map +1 -1
- package/build/newsroom-context/hooks/useNewsroom.js +5 -10
- package/build/newsroom-context/hooks/useNewsroom.js.map +1 -1
- package/build/newsroom-context/hooks/useNewsroomContext.js +11 -16
- package/build/newsroom-context/hooks/useNewsroomContext.js.map +1 -1
- package/build/newsroom-context/index.js +2 -22
- package/build/newsroom-context/index.js.map +1 -1
- package/build/sentry/client.js +4 -9
- package/build/sentry/client.js.map +1 -1
- package/build/sentry/common.js +26 -29
- package/build/sentry/common.js.map +1 -1
- package/build/sentry/index.js +2 -8
- package/build/sentry/index.js.map +1 -1
- package/build/sentry/server.js +4 -9
- package/build/sentry/server.js.map +1 -1
- package/build/types.d.ts +2 -2
- package/build/types.js +1 -3
- package/build/utils/boilerplate.js +7 -22
- package/build/utils/boilerplate.js.map +1 -1
- package/build/utils/constants.js +3 -7
- package/build/utils/constants.js.map +1 -1
- package/build/utils/getAssetsUrl.js +4 -9
- package/build/utils/getAssetsUrl.js.map +1 -1
- package/build/utils/getDataRequestLink.js +6 -12
- package/build/utils/getDataRequestLink.js.map +1 -1
- package/build/utils/getLocalizedCategoryData.js +33 -33
- package/build/utils/getLocalizedCategoryData.js.map +1 -1
- package/build/utils/getNewsroomLogoUrl.js +15 -21
- package/build/utils/getNewsroomLogoUrl.js.map +1 -1
- package/build/utils/getPrivacyPortalUrl.js +11 -13
- package/build/utils/getPrivacyPortalUrl.js.map +1 -1
- package/build/utils/getStoryPublicationDate.js +9 -14
- package/build/utils/getStoryPublicationDate.js.map +1 -1
- package/build/utils/getUploadcareGroupUrl.js +5 -10
- package/build/utils/getUploadcareGroupUrl.js.map +1 -1
- package/build/utils/index.js +10 -27
- package/build/utils/index.js.map +1 -1
- package/build/utils/isEmbargoStory.js +3 -8
- package/build/utils/isEmbargoStory.js.map +1 -1
- package/package.json +26 -18
- package/build/tsconfig.tsbuildinfo +0 -1
- package/src/@types/global.d.ts +0 -7
- package/src/__mocks__/languages.ts +0 -417
- package/src/__mocks__/story.ts +0 -351
- package/src/adapter-nextjs/api-handlers/fetchGalleries.ts +0 -24
- package/src/adapter-nextjs/api-handlers/fetchStories.ts +0 -26
- package/src/adapter-nextjs/api-handlers/index.ts +0 -2
- package/src/adapter-nextjs/getNewsroomServerSideProps.ts +0 -29
- package/src/adapter-nextjs/getNewsroomStaticProps.ts +0 -29
- package/src/adapter-nextjs/index.ts +0 -6
- package/src/adapter-nextjs/page-props/category.ts +0 -157
- package/src/adapter-nextjs/page-props/gallery.ts +0 -114
- package/src/adapter-nextjs/page-props/galleryAlbum.ts +0 -89
- package/src/adapter-nextjs/page-props/home.ts +0 -113
- package/src/adapter-nextjs/page-props/index.ts +0 -26
- package/src/adapter-nextjs/page-props/lib/types.ts +0 -8
- package/src/adapter-nextjs/page-props/search.ts +0 -53
- package/src/adapter-nextjs/page-props/sitemap/SitemapBuilder.ts +0 -56
- package/src/adapter-nextjs/page-props/sitemap/createPaths.ts +0 -21
- package/src/adapter-nextjs/page-props/sitemap/getServerSideProps.ts +0 -43
- package/src/adapter-nextjs/page-props/sitemap/index.ts +0 -5
- package/src/adapter-nextjs/page-props/sitemap/types.ts +0 -5
- package/src/adapter-nextjs/page-props/story.ts +0 -94
- package/src/adapter-nextjs/page-props/storyPreview.ts +0 -33
- package/src/adapter-nextjs/processRequest.ts +0 -49
- package/src/adapter-nextjs/processStaticRequest.ts +0 -32
- package/src/components-nextjs/PageSeo/PageSeo.tsx +0 -131
- package/src/components-nextjs/PageSeo/index.ts +0 -2
- package/src/components-nextjs/PageSeo/lib/getAbsoluteUrl.ts +0 -7
- package/src/components-nextjs/PageSeo/lib/types.ts +0 -4
- package/src/components-nextjs/StorySeo/StorySeo.tsx +0 -80
- package/src/components-nextjs/StorySeo/index.ts +0 -1
- package/src/components-nextjs/document.tsx +0 -38
- package/src/components-nextjs/index.ts +0 -3
- package/src/data-fetching/api/PrezlyApi.ts +0 -302
- package/src/data-fetching/api/getPrezlyApi.ts +0 -24
- package/src/data-fetching/api/index.ts +0 -1
- package/src/data-fetching/api/queries.ts +0 -51
- package/src/data-fetching/index.ts +0 -3
- package/src/data-fetching/lib/getAlgoliaSettings.ts +0 -29
- package/src/data-fetching/lib/getEnvVariables.ts +0 -46
- package/src/data-fetching/lib/index.ts +0 -4
- package/src/data-fetching/lib/isSdkError.ts +0 -5
- package/src/data-fetching/lib/isUuid.ts +0 -5
- package/src/data-fetching/types.ts +0 -14
- package/src/index.ts +0 -9
- package/src/infinite-loading/index.ts +0 -4
- package/src/infinite-loading/types.ts +0 -5
- package/src/infinite-loading/useInfiniteGalleriesLoading.ts +0 -53
- package/src/infinite-loading/useInfiniteLoading.ts +0 -66
- package/src/infinite-loading/useInfiniteStoriesLoading.ts +0 -81
- package/src/intl/index.ts +0 -4
- package/src/intl/languages.test.ts +0 -232
- package/src/intl/languages.ts +0 -233
- package/src/intl/locale.test.ts +0 -94
- package/src/intl/locale.ts +0 -140
- package/src/intl/localeConfig.js +0 -23
- package/src/intl/localeList.js +0 -110
- package/src/intl/localeObject.test.ts +0 -81
- package/src/intl/localeObject.ts +0 -99
- package/src/newsroom-context/context.tsx +0 -115
- package/src/newsroom-context/hooks/index.ts +0 -11
- package/src/newsroom-context/hooks/useAlgoliaSettings.ts +0 -7
- package/src/newsroom-context/hooks/useCategories.ts +0 -7
- package/src/newsroom-context/hooks/useCompanyInformation.ts +0 -7
- package/src/newsroom-context/hooks/useCurrentCategory.ts +0 -7
- package/src/newsroom-context/hooks/useCurrentLocale.ts +0 -7
- package/src/newsroom-context/hooks/useCurrentStory.ts +0 -7
- package/src/newsroom-context/hooks/useGetLinkLocaleSlug.ts +0 -37
- package/src/newsroom-context/hooks/useGetTranslationUrl.ts +0 -96
- package/src/newsroom-context/hooks/useLanguages.ts +0 -7
- package/src/newsroom-context/hooks/useNewsroom.ts +0 -7
- package/src/newsroom-context/hooks/useNewsroomContext.ts +0 -15
- package/src/newsroom-context/index.ts +0 -2
- package/src/sentry/client.ts +0 -7
- package/src/sentry/common.ts +0 -27
- package/src/sentry/index.ts +0 -2
- package/src/sentry/server.ts +0 -7
- package/src/types.ts +0 -51
- package/src/utils/boilerplate.ts +0 -27
- package/src/utils/constants.ts +0 -3
- package/src/utils/getAssetsUrl.test.ts +0 -9
- package/src/utils/getAssetsUrl.ts +0 -9
- package/src/utils/getDataRequestLink.ts +0 -14
- package/src/utils/getLocalizedCategoryData.ts +0 -47
- package/src/utils/getNewsroomLogoUrl.ts +0 -22
- package/src/utils/getPrivacyPortalUrl.ts +0 -25
- package/src/utils/getStoryPublicationDate.tsx +0 -15
- package/src/utils/getUploadcareGroupUrl.ts +0 -13
- package/src/utils/index.ts +0 -10
- package/src/utils/isEmbargoStory.ts +0 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/search.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/search.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAI/D,MAAM,UAAU,4BAA4B,CACxC,WAAqD;IAErD,OAAO,KAAK,UAAU,kBAAkB,CACpC,OAAkC;QAElC,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,0BAA0B,CAAC,OAAO,CAAC,CAAC;QAEtE,OAAO,cAAc,CACjB,OAAO,EACP;YACI,GAAG,eAAe;YAClB,GAAG,CAAC,OAAO,WAAW,KAAK,UAAU;gBACjC,CAAC,CAAC,MAAO,WAA0C,CAAC,OAAO,EAAE,eAAe,CAAC;gBAC7E,CAAC,CAAC,WAAW,CAAC;SACrB,EACD,SAAS,CACZ,CAAC;IACN,CAAC,CAAC;AACN,CAAC;AAED,MAAM,UAAU,wBAAwB,CACpC,WAA4E;IAE5E,OAAO,KAAK,UAAU,cAAc,CAChC,OAAkC;QAElC,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,sBAAsB,CAAC,OAAO,CAAC,CAAC;QAE9D,OAAO,oBAAoB,CAAC,OAAO,EAAE;YACjC,GAAG,WAAW;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"}
|
|
@@ -1,51 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
export class SitemapBuilder {
|
|
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';
|
|
9
21
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return 'daily';
|
|
20
|
-
return 'weekly';
|
|
21
|
-
}
|
|
22
|
-
static guessPriority(location) {
|
|
23
|
-
if (location === '/')
|
|
24
|
-
return '0.9';
|
|
25
|
-
if (location.startsWith('/category/')) {
|
|
26
|
-
return '0.8';
|
|
27
|
-
}
|
|
28
|
-
return '0.7';
|
|
29
|
-
}
|
|
30
|
-
static serializeLocation(url) {
|
|
31
|
-
return [
|
|
32
|
-
'<url>',
|
|
33
|
-
url.location && `\t<loc>${url.location}</loc>`,
|
|
34
|
-
url.changeFrequency && `\t<changefreq>${url.changeFrequency}</changefreq>`,
|
|
35
|
-
url.priority && `\t<priority>${url.priority}</priority>`,
|
|
36
|
-
'</url>',
|
|
37
|
-
]
|
|
38
|
-
.filter(Boolean)
|
|
39
|
-
.join('\n');
|
|
40
|
-
}
|
|
41
|
-
serialize() {
|
|
42
|
-
return [
|
|
43
|
-
'<?xml version="1.0" encoding="UTF-8" ?>',
|
|
44
|
-
'<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">',
|
|
45
|
-
this.urls.map(SitemapBuilder.serializeLocation).join('\n'),
|
|
46
|
-
'</urlset>',
|
|
47
|
-
].join('\n');
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.SitemapBuilder = SitemapBuilder;
|
|
51
|
-
//# 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SitemapBuilder.js","sourceRoot":"","sources":["../../../../src/adapter-nextjs/page-props/sitemap/SitemapBuilder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SitemapBuilder.js","sourceRoot":"","sources":["../../../../src/adapter-nextjs/page-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AAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;YAC1D,WAAW;SACd,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;CACJ"}
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
})
|
|
15
|
-
.flat();
|
|
16
|
-
return [...storiesUrls, ...categoriesUrls];
|
|
17
|
-
}
|
|
18
|
-
exports.createPaths = createPaths;
|
|
19
|
-
//# sourceMappingURL=createPaths.js.map
|
|
1
|
+
export function createPaths(stories, categories) {
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPaths.js","sourceRoot":"","sources":["../../../../src/adapter-nextjs/page-props/sitemap/createPaths.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createPaths.js","sourceRoot":"","sources":["../../../../src/adapter-nextjs/page-props/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,IA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
|
2
|
+
import { createPaths } from "./createPaths.js";
|
|
3
|
+
import { SitemapBuilder } from "./SitemapBuilder.js";
|
|
4
|
+
export function getSitemapServerSideProps(additionalPaths) {
|
|
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: {}
|
|
33
32
|
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
//# sourceMappingURL=getServerSideProps.js.map
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getServerSideProps.js","sourceRoot":"","sources":["../../../../src/adapter-nextjs/page-props/sitemap/getServerSideProps.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getServerSideProps.js","sourceRoot":"","sources":["../../../../src/adapter-nextjs/page-props/sitemap/getServerSideProps.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,M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AAC"}
|
|
@@ -1,25 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.createPaths = exports.SitemapBuilder = exports.getSitemapServerSideProps = void 0;
|
|
18
|
-
var getServerSideProps_1 = require("./getServerSideProps");
|
|
19
|
-
Object.defineProperty(exports, "getSitemapServerSideProps", { enumerable: true, get: function () { return getServerSideProps_1.getSitemapServerSideProps; } });
|
|
20
|
-
var SitemapBuilder_1 = require("./SitemapBuilder");
|
|
21
|
-
Object.defineProperty(exports, "SitemapBuilder", { enumerable: true, get: function () { return SitemapBuilder_1.SitemapBuilder; } });
|
|
22
|
-
var createPaths_1 = require("./createPaths");
|
|
23
|
-
Object.defineProperty(exports, "createPaths", { enumerable: true, get: function () { return createPaths_1.createPaths; } });
|
|
24
|
-
__exportStar(require("./types"), exports);
|
|
25
|
-
//# 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/adapter-nextjs/page-props/sitemap/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/adapter-nextjs/page-props/sitemap/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,cAAc,SAAS,CAAC"}
|
|
@@ -1,67 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { getPrezlyApi } from "../../data-fetching/index.js";
|
|
2
|
+
import { DUMMY_DEFAULT_LOCALE } from "../../intl/index.js";
|
|
3
|
+
import { getNewsroomServerSideProps } from "../getNewsroomServerSideProps.js";
|
|
4
|
+
import { getNewsroomStaticProps } from "../getNewsroomStaticProps.js";
|
|
5
|
+
import { processRequest } from "../processRequest.js";
|
|
6
|
+
import { processStaticRequest } from "../processStaticRequest.js";
|
|
7
|
+
export function getStoryPageServerSideProps(customProps) {
|
|
8
|
+
return async function getServerSideProps(context) {
|
|
9
|
+
const api = getPrezlyApi(context.req);
|
|
10
|
+
const {
|
|
11
|
+
slug
|
|
12
|
+
} = context.params;
|
|
13
|
+
const story = slug ? await api.getStoryBySlug(slug) : null;
|
|
14
|
+
if (!story) {
|
|
15
|
+
return {
|
|
16
|
+
notFound: true
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const {
|
|
20
|
+
serverSideProps
|
|
21
|
+
} = await getNewsroomServerSideProps(context, {
|
|
22
|
+
story
|
|
23
|
+
});
|
|
24
|
+
const {
|
|
25
|
+
locale
|
|
26
|
+
} = context;
|
|
27
|
+
if (locale && locale !== DUMMY_DEFAULT_LOCALE) {
|
|
28
|
+
return {
|
|
29
|
+
redirect: {
|
|
30
|
+
destination: `/${slug}`,
|
|
31
|
+
permanent: true
|
|
17
32
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
serverSideProps.newsroomContextProps.currentStory = story;
|
|
29
|
-
return (0, processRequest_1.processRequest)(context, {
|
|
30
|
-
...serverSideProps,
|
|
31
|
-
...(typeof customProps === 'function'
|
|
32
|
-
? await customProps(context, serverSideProps)
|
|
33
|
-
: customProps),
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
exports.getStoryPageServerSideProps = getStoryPageServerSideProps;
|
|
38
|
-
function getStoryPageStaticProps(customProps) {
|
|
39
|
-
return async function getStaticProps(context) {
|
|
40
|
-
const api = (0, data_fetching_1.getPrezlyApi)();
|
|
41
|
-
const { slug } = context.params;
|
|
42
|
-
const story = slug ? await api.getStoryBySlug(slug) : null;
|
|
43
|
-
if (!story) {
|
|
44
|
-
return { notFound: true };
|
|
45
|
-
}
|
|
46
|
-
const { staticProps } = await (0, getNewsroomStaticProps_1.getNewsroomStaticProps)(context, { story });
|
|
47
|
-
staticProps.newsroomContextProps.currentStory = story;
|
|
48
|
-
return (0, processStaticRequest_1.processStaticRequest)(context, {
|
|
49
|
-
...staticProps,
|
|
50
|
-
...(typeof customProps === 'function'
|
|
51
|
-
? await customProps(context, staticProps)
|
|
52
|
-
: customProps),
|
|
53
|
-
});
|
|
54
|
-
};
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
serverSideProps.newsroomContextProps.currentStory = story;
|
|
36
|
+
return processRequest(context, {
|
|
37
|
+
...serverSideProps,
|
|
38
|
+
...(typeof customProps === 'function' ? await customProps(context, serverSideProps) : customProps)
|
|
39
|
+
});
|
|
40
|
+
};
|
|
55
41
|
}
|
|
56
|
-
|
|
57
|
-
async function
|
|
58
|
-
const api =
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
42
|
+
export function getStoryPageStaticProps(customProps) {
|
|
43
|
+
return async function getStaticProps(context) {
|
|
44
|
+
const api = getPrezlyApi();
|
|
45
|
+
const {
|
|
46
|
+
slug
|
|
47
|
+
} = context.params;
|
|
48
|
+
const story = slug ? await api.getStoryBySlug(slug) : null;
|
|
49
|
+
if (!story) {
|
|
50
|
+
return {
|
|
51
|
+
notFound: true
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const {
|
|
55
|
+
staticProps
|
|
56
|
+
} = await getNewsroomStaticProps(context, {
|
|
57
|
+
story
|
|
58
|
+
});
|
|
59
|
+
staticProps.newsroomContextProps.currentStory = story;
|
|
60
|
+
return processStaticRequest(context, {
|
|
61
|
+
...staticProps,
|
|
62
|
+
...(typeof customProps === 'function' ? await customProps(context, staticProps) : customProps)
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
65
|
}
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
export async function getStoryPageStaticPaths() {
|
|
67
|
+
const api = getPrezlyApi();
|
|
68
|
+
const stories = await api.getAllStories();
|
|
69
|
+
const paths = stories.map(({
|
|
70
|
+
slug
|
|
71
|
+
}) => ({
|
|
72
|
+
params: {
|
|
73
|
+
slug
|
|
74
|
+
}
|
|
75
|
+
}));
|
|
76
|
+
return {
|
|
77
|
+
paths,
|
|
78
|
+
fallback: 'blocking'
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"story.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/story.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"story.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/story.ts"],"names":[],"mappings":"AAOA,OAAO,EAA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vB,CAAC;AACN,CAAC"}
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
import { getPrezlyApi } from "../../data-fetching/index.js";
|
|
2
|
+
import { getNewsroomServerSideProps } from "../getNewsroomServerSideProps.js";
|
|
3
|
+
import { processRequest } from "../processRequest.js";
|
|
4
|
+
export function getStoryPreviewPageServerSideProps(customProps) {
|
|
5
|
+
return async function getServerSideProps(context) {
|
|
6
|
+
const api = getPrezlyApi(context.req);
|
|
7
|
+
const {
|
|
8
|
+
uuid
|
|
9
|
+
} = context.params;
|
|
10
|
+
const story = await api.getStory(uuid);
|
|
11
|
+
if (!story) {
|
|
12
|
+
return {
|
|
13
|
+
notFound: true
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const {
|
|
17
|
+
serverSideProps
|
|
18
|
+
} = await getNewsroomServerSideProps(context, {
|
|
19
|
+
story
|
|
20
|
+
});
|
|
21
|
+
serverSideProps.newsroomContextProps.currentStory = story;
|
|
22
|
+
return processRequest(context, {
|
|
23
|
+
...serverSideProps,
|
|
24
|
+
...(typeof customProps === 'function' ? await customProps(context, serverSideProps) : customProps)
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storyPreview.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/storyPreview.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storyPreview.js","sourceRoot":"","sources":["../../../src/adapter-nextjs/page-props/storyPreview.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAInD,MAAM,UAAU,kCAAkC,CAC9C,WAAqD;IAErD,OAAO,KAAK,UAAU,kBAAkB,CACpC,OAAkC;QAElC,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACtC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAA0B,CAAC;QACpD,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,KAAK,EAAE;YACR,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;SAC7B;QAED,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,0BAA0B,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAEjF,eAAe,CAAC,oBAAoB,CAAC,YAAY,GAAG,KAAK,CAAC;QAE1D,OAAO,cAAc,CAAC,OAAO,EAAE;YAC3B,GAAG,eAAe;YAClB,GAAG,CAAC,OAAO,WAAW,KAAK,UAAU;gBACjC,CAAC,CAAC,MAAO,WAA0C,CAAC,OAAO,EAAE,eAAe,CAAC;gBAC7E,CAAC,CAAC,WAAW,CAAC;SACrB,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.processRequest = void 0;
|
|
4
|
-
const intl_1 = require("../intl");
|
|
1
|
+
import { getRedirectToCanonicalLocale, getShortestLocaleCode, LocaleObject } from "../intl/index.js";
|
|
5
2
|
/**
|
|
6
3
|
* This function combines the props returned from `getNewsroomServerSideProps` and your optional custom props for the page.
|
|
7
4
|
* It also handles locale redirects, if `canonicalUrl` parameter is provided.
|
|
@@ -11,26 +8,38 @@ const intl_1 = require("../intl");
|
|
|
11
8
|
* @param props Object containing the return of `getNewsroomServerSideProps` and your optional custom props.
|
|
12
9
|
* @param canonicalUrl Optional: a canonical URL for the current page without locale part. If provided, locale redirects will be handled by the function.
|
|
13
10
|
*/
|
|
14
|
-
function processRequest(context, props, canonicalUrl) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (redirect) {
|
|
28
|
-
return { redirect };
|
|
29
|
-
}
|
|
30
|
-
}
|
|
11
|
+
export function processRequest(context, props, canonicalUrl) {
|
|
12
|
+
const {
|
|
13
|
+
locale: nextLocale,
|
|
14
|
+
query
|
|
15
|
+
} = context;
|
|
16
|
+
const {
|
|
17
|
+
localeResolved,
|
|
18
|
+
...pageProps
|
|
19
|
+
} = props;
|
|
20
|
+
|
|
21
|
+
// If no locale was provided by Next, it most likely means that the theme is not supporting multi-language.
|
|
22
|
+
// In that case we won't show 404 page.
|
|
23
|
+
if (!localeResolved && nextLocale) {
|
|
31
24
|
return {
|
|
32
|
-
|
|
25
|
+
notFound: true
|
|
33
26
|
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
}
|
|
28
|
+
if (canonicalUrl) {
|
|
29
|
+
const {
|
|
30
|
+
languages,
|
|
31
|
+
localeCode
|
|
32
|
+
} = pageProps.newsroomContextProps;
|
|
33
|
+
const currentLocale = LocaleObject.fromAnyCode(localeCode);
|
|
34
|
+
const shortestLocaleCode = getShortestLocaleCode(languages, currentLocale);
|
|
35
|
+
const redirect = getRedirectToCanonicalLocale(shortestLocaleCode, nextLocale, canonicalUrl, query);
|
|
36
|
+
if (redirect) {
|
|
37
|
+
return {
|
|
38
|
+
redirect
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
props: pageProps
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -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,4BAA4B,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG5F;;;;;;;;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"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.processStaticRequest = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* This function combines the props returned from `getNewsroomStaticProps` and your optional custom props for the page.
|
|
6
3
|
* See README for usage examples.
|
|
@@ -9,18 +6,24 @@ exports.processStaticRequest = void 0;
|
|
|
9
6
|
* @param props Object containing the return of `getNewsroomServerSideProps` and your optional custom props.
|
|
10
7
|
* @param revalidateTimeout Optional: timeout in seconds to use with Next ISR.
|
|
11
8
|
*/
|
|
12
|
-
function processStaticRequest(context, props, revalidateTimeout) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
export function processStaticRequest(context, props, revalidateTimeout) {
|
|
10
|
+
const {
|
|
11
|
+
locale: nextLocale
|
|
12
|
+
} = context;
|
|
13
|
+
const {
|
|
14
|
+
localeResolved,
|
|
15
|
+
...pageProps
|
|
16
|
+
} = props;
|
|
17
|
+
|
|
18
|
+
// If no locale was provided by Next, it most likely means that the theme is not supporting multi-language.
|
|
19
|
+
// In that case we won't show 404 page.
|
|
20
|
+
if (!localeResolved && nextLocale) {
|
|
20
21
|
return {
|
|
21
|
-
|
|
22
|
-
revalidate: revalidateTimeout,
|
|
22
|
+
notFound: true
|
|
23
23
|
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
props: pageProps,
|
|
27
|
+
revalidate: revalidateTimeout
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processStaticRequest.js","sourceRoot":"","sources":["../../src/adapter-nextjs/processStaticRequest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"processStaticRequest.js","sourceRoot":"","sources":["../../src/adapter-nextjs/processStaticRequest.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAChC,OAA8B,EAC9B,KAA8C,EAC9C,iBAA0B;IAE1B,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAEvC,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,OAAO;QACH,KAAK,EAAE,SAA8B;QACrC,UAAU,EAAE,iBAAiB;KAChC,CAAC;AACN,CAAC"}
|