@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.
Files changed (86) hide show
  1. package/build/@types/global.d.js +1 -0
  2. package/build/adapter-nextjs/api-handlers/fetchGalleries.js +26 -18
  3. package/build/adapter-nextjs/api-handlers/fetchStories.js +36 -20
  4. package/build/adapter-nextjs/api-handlers/index.js +2 -3
  5. package/build/adapter-nextjs/getNewsroomServerSideProps.js +15 -10
  6. package/build/adapter-nextjs/getNewsroomStaticProps.js +14 -10
  7. package/build/adapter-nextjs/index.js +6 -7
  8. package/build/adapter-nextjs/page-props/category.js +115 -91
  9. package/build/adapter-nextjs/page-props/gallery.js +85 -61
  10. package/build/adapter-nextjs/page-props/galleryAlbum.js +61 -44
  11. package/build/adapter-nextjs/page-props/home.js +81 -62
  12. package/build/adapter-nextjs/page-props/index.js +8 -9
  13. package/build/adapter-nextjs/page-props/lib/types.js +1 -2
  14. package/build/adapter-nextjs/page-props/search.js +23 -24
  15. package/build/adapter-nextjs/page-props/sitemap/SitemapBuilder.js +28 -45
  16. package/build/adapter-nextjs/page-props/sitemap/createPaths.js +12 -14
  17. package/build/adapter-nextjs/page-props/sitemap/getServerSideProps.js +32 -30
  18. package/build/adapter-nextjs/page-props/sitemap/index.js +4 -5
  19. package/build/adapter-nextjs/page-props/sitemap/types.js +1 -2
  20. package/build/adapter-nextjs/page-props/story.js +74 -55
  21. package/build/adapter-nextjs/page-props/storyPreview.js +26 -21
  22. package/build/adapter-nextjs/processRequest.js +33 -20
  23. package/build/adapter-nextjs/processStaticRequest.js +18 -11
  24. package/build/components-nextjs/PageSeo/PageSeo.js +81 -71
  25. package/build/components-nextjs/PageSeo/index.js +2 -3
  26. package/build/components-nextjs/PageSeo/lib/getAbsoluteUrl.js +4 -5
  27. package/build/components-nextjs/PageSeo/lib/types.js +1 -2
  28. package/build/components-nextjs/StorySeo/StorySeo.js +67 -41
  29. package/build/components-nextjs/StorySeo/index.js +1 -2
  30. package/build/components-nextjs/document.js +29 -19
  31. package/build/components-nextjs/index.js +3 -4
  32. package/build/data-fetching/api/PrezlyApi.js +205 -185
  33. package/build/data-fetching/api/getPrezlyApi.js +20 -16
  34. package/build/data-fetching/api/index.js +1 -2
  35. package/build/data-fetching/api/queries.js +71 -34
  36. package/build/data-fetching/index.js +3 -4
  37. package/build/data-fetching/lib/getAlgoliaSettings.js +21 -17
  38. package/build/data-fetching/lib/getEnvVariables.js +33 -29
  39. package/build/data-fetching/lib/index.js +4 -5
  40. package/build/data-fetching/lib/isSdkError.js +2 -3
  41. package/build/data-fetching/lib/isUuid.js +2 -3
  42. package/build/data-fetching/types.js +1 -2
  43. package/build/index.js +9 -10
  44. package/build/infinite-loading/index.js +4 -5
  45. package/build/infinite-loading/types.js +1 -2
  46. package/build/infinite-loading/useInfiniteGalleriesLoading.js +41 -32
  47. package/build/infinite-loading/useInfiniteLoading.js +48 -37
  48. package/build/infinite-loading/useInfiniteStoriesLoading.js +54 -44
  49. package/build/intl/index.js +4 -5
  50. package/build/intl/languages.js +135 -97
  51. package/build/intl/locale.js +46 -95
  52. package/build/intl/localeConfig.js +7 -13
  53. package/build/intl/localeList.js +1 -108
  54. package/build/intl/localeObject.js +79 -74
  55. package/build/newsroom-context/context.js +34 -20
  56. package/build/newsroom-context/hooks/index.js +11 -12
  57. package/build/newsroom-context/hooks/useAlgoliaSettings.js +4 -5
  58. package/build/newsroom-context/hooks/useCategories.js +4 -5
  59. package/build/newsroom-context/hooks/useCompanyInformation.js +4 -5
  60. package/build/newsroom-context/hooks/useCurrentCategory.js +4 -5
  61. package/build/newsroom-context/hooks/useCurrentLocale.js +4 -5
  62. package/build/newsroom-context/hooks/useCurrentStory.js +4 -5
  63. package/build/newsroom-context/hooks/useGetLinkLocaleSlug.js +15 -15
  64. package/build/newsroom-context/hooks/useGetTranslationUrl.js +48 -44
  65. package/build/newsroom-context/hooks/useLanguages.js +4 -5
  66. package/build/newsroom-context/hooks/useNewsroom.js +4 -5
  67. package/build/newsroom-context/hooks/useNewsroomContext.js +9 -10
  68. package/build/newsroom-context/index.js +2 -3
  69. package/build/sentry/client.js +3 -4
  70. package/build/sentry/common.js +25 -24
  71. package/build/sentry/index.js +2 -3
  72. package/build/sentry/server.js +3 -4
  73. package/build/types.js +1 -2
  74. package/build/utils/boilerplate.js +4 -13
  75. package/build/utils/constants.js +1 -2
  76. package/build/utils/getAssetsUrl.js +3 -4
  77. package/build/utils/getDataRequestLink.js +5 -7
  78. package/build/utils/getLocalizedCategoryData.js +30 -24
  79. package/build/utils/getNewsroomLogoUrl.js +12 -13
  80. package/build/utils/getPrivacyPortalUrl.js +10 -8
  81. package/build/utils/getStoryPublicationDate.js +8 -9
  82. package/build/utils/getUploadcareGroupUrl.js +4 -5
  83. package/build/utils/index.js +10 -11
  84. package/build/utils/isEmbargoStory.js +2 -3
  85. package/package.json +10 -2
  86. package/build/tsconfig.tsbuildinfo +0 -1
@@ -1,84 +1,89 @@
1
- import { localeConfig } from './localeConfig';
1
+ import { localeConfig } from "./localeConfig.js";
2
2
  /**
3
3
  * This class is created to simplify working with locales and transforming between different locale code formats.
4
4
  * Prezly API uses underscore-codes, while most frontend application tend to use hyphen-codes or slugs.
5
5
  * Note that `fromAnyCode` constructor only accepts locales supported by Prezly backend. See `localeConfig` for reference.
6
6
  */
7
7
  export class LocaleObject {
8
- /**
9
- * Hyphen-separated locale code.
10
- * Examples: `nl-BE`, `en-US`, `fr`, `fil`
11
- */
12
- localeCode;
13
- constructor(localeCode) {
14
- if (!/^([a-z]{2,3})(-[a-z\d]{1,4})?$/i.test(localeCode)) {
15
- throw new Error('Invalid locale code provided!');
16
- }
17
- const [language, region] = localeCode.split('-');
18
- if (region) {
19
- // Workaround for `zh-Hant` locale, which is the only locale with non-uppercase region part
20
- const regionSuffix = region === 'hant' ? 'Hant' : region.toUpperCase();
21
- this.localeCode = [language, regionSuffix].join('-');
22
- }
23
- else {
24
- this.localeCode = language;
25
- }
8
+ /**
9
+ * Hyphen-separated locale code.
10
+ * Examples: `nl-BE`, `en-US`, `fr`, `fil`
11
+ */
12
+
13
+ constructor(localeCode) {
14
+ if (!/^([a-z]{2,3})(-[a-z\d]{1,4})?$/i.test(localeCode)) {
15
+ throw new Error('Invalid locale code provided!');
26
16
  }
27
- /**
28
- * @param localeCode Locale code in any of the formats below.
29
- * Examples:
30
- * - Hyphen-codes: `nl-BE`, `en-US`, `fr`, `fil`
31
- * - Underscore-codes: `nl_BE`, `en_US`, `fr`, `fil`
32
- * - Slugs: `nl-be`, `en-us`, `fr`, `fil`
33
- */
34
- static fromAnyCode(localeCode) {
35
- const lowercaseCode = localeCode.toLowerCase().replace('_', '-');
36
- const foundCode = localeConfig.find((code) => code === lowercaseCode);
37
- if (!foundCode) {
38
- throw new Error(`Unsupported locale code provided: "${lowercaseCode}"`);
39
- }
40
- return new LocaleObject(foundCode);
17
+ const [language, region] = localeCode.split('-');
18
+ if (region) {
19
+ // Workaround for `zh-Hant` locale, which is the only locale with non-uppercase region part
20
+ const regionSuffix = region === 'hant' ? 'Hant' : region.toUpperCase();
21
+ this.localeCode = [language, regionSuffix].join('-');
22
+ } else {
23
+ this.localeCode = language;
41
24
  }
42
- /**
43
- * @returns Code formatted into hyphen format: `nl-BE`, `en-US`, `fr`, `fil`
44
- */
45
- toHyphenCode() {
46
- return this.localeCode;
25
+ }
26
+
27
+ /**
28
+ * @param localeCode Locale code in any of the formats below.
29
+ * Examples:
30
+ * - Hyphen-codes: `nl-BE`, `en-US`, `fr`, `fil`
31
+ * - Underscore-codes: `nl_BE`, `en_US`, `fr`, `fil`
32
+ * - Slugs: `nl-be`, `en-us`, `fr`, `fil`
33
+ */
34
+ static fromAnyCode(localeCode) {
35
+ const lowercaseCode = localeCode.toLowerCase().replace('_', '-');
36
+ const foundCode = localeConfig.find(code => code === lowercaseCode);
37
+ if (!foundCode) {
38
+ throw new Error(`Unsupported locale code provided: "${lowercaseCode}"`);
47
39
  }
48
- /**
49
- * @returns Code formatted into underscore format, as expected by Prezly API: `nl_BE`, `en_US`, `fr`, `fil`
50
- */
51
- toUnderscoreCode() {
52
- return this.localeCode.replace('-', '_');
40
+ return new LocaleObject(foundCode);
41
+ }
42
+
43
+ /**
44
+ * @returns Code formatted into hyphen format: `nl-BE`, `en-US`, `fr`, `fil`
45
+ */
46
+ toHyphenCode() {
47
+ return this.localeCode;
48
+ }
49
+
50
+ /**
51
+ * @returns Code formatted into underscore format, as expected by Prezly API: `nl_BE`, `en_US`, `fr`, `fil`
52
+ */
53
+ toUnderscoreCode() {
54
+ return this.localeCode.replace('-', '_');
55
+ }
56
+
57
+ /**
58
+ * @returns Code formatted to a URL-friendly lowercase slug format: `nl-be`, `en-us`, `fr`, `fil`
59
+ */
60
+ toUrlSlug() {
61
+ return this.localeCode.toLowerCase();
62
+ }
63
+
64
+ /**
65
+ * @returns Only the language part of the code without culture/region part: `nl`, `en`, `fr`
66
+ */
67
+ toNeutralLanguageCode() {
68
+ const [language] = this.localeCode.split('-');
69
+ return language;
70
+ }
71
+
72
+ /**
73
+ * @returns Only the culture/regtion part without the language part: `be`, `us`, `fr`
74
+ */
75
+ toRegionCode() {
76
+ const [language, region] = this.localeCode.split('-');
77
+ if (!region) {
78
+ return language.toUpperCase();
53
79
  }
54
- /**
55
- * @returns Code formatted to a URL-friendly lowercase slug format: `nl-be`, `en-us`, `fr`, `fil`
56
- */
57
- toUrlSlug() {
58
- return this.localeCode.toLowerCase();
59
- }
60
- /**
61
- * @returns Only the language part of the code without culture/region part: `nl`, `en`, `fr`
62
- */
63
- toNeutralLanguageCode() {
64
- const [language] = this.localeCode.split('-');
65
- return language;
66
- }
67
- /**
68
- * @returns Only the culture/regtion part without the language part: `be`, `us`, `fr`
69
- */
70
- toRegionCode() {
71
- const [language, region] = this.localeCode.split('-');
72
- if (!region) {
73
- return language.toUpperCase();
74
- }
75
- return region.toUpperCase();
76
- }
77
- /**
78
- * Check if two LocaleObject instances are representing the same locale code.
79
- */
80
- isEqual(anotherLocale) {
81
- return anotherLocale.toHyphenCode() === this.localeCode;
82
- }
83
- }
84
- //# sourceMappingURL=localeObject.js.map
80
+ return region.toUpperCase();
81
+ }
82
+
83
+ /**
84
+ * Check if two LocaleObject instances are representing the same locale code.
85
+ */
86
+ isEqual(anotherLocale) {
87
+ return anotherLocale.toHyphenCode() === this.localeCode;
88
+ }
89
+ }
@@ -1,25 +1,39 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
1
  import { createContext, useMemo } from 'react';
3
- import { DEFAULT_LOCALE, LocaleObject } from '../intl';
4
- export const NewsroomContext = createContext(undefined);
2
+ import { DEFAULT_LOCALE, LocaleObject } from "../intl/index.js";
3
+ export const NewsroomContext = /*#__PURE__*/createContext(undefined);
4
+
5
5
  /**
6
6
  * This context provides common Newsroom information retrieved by `getNewsroomServerSideProps` helper.
7
7
  * Please refer to the `NewsroomContextType` definition for more info on what's exposed from the context.
8
8
  */
9
- export function NewsroomContextProvider({ categories, contacts, newsroom, currentCategory, currentStory, companyInformation, languages, localeCode, notifications, themePreset, algoliaSettings, children, }) {
10
- const locale = useMemo(() => LocaleObject.fromAnyCode(localeCode || DEFAULT_LOCALE), [localeCode]);
11
- return (_jsx(NewsroomContext.Provider, { value: {
12
- categories,
13
- contacts,
14
- newsroom,
15
- currentCategory,
16
- currentStory,
17
- companyInformation,
18
- languages,
19
- locale,
20
- notifications,
21
- themePreset,
22
- algoliaSettings,
23
- }, children: children }));
24
- }
25
- //# sourceMappingURL=context.js.map
9
+ export function NewsroomContextProvider({
10
+ categories,
11
+ contacts,
12
+ newsroom,
13
+ currentCategory,
14
+ currentStory,
15
+ companyInformation,
16
+ languages,
17
+ localeCode,
18
+ notifications,
19
+ themePreset,
20
+ algoliaSettings,
21
+ children
22
+ }) {
23
+ const locale = useMemo(() => LocaleObject.fromAnyCode(localeCode || DEFAULT_LOCALE), [localeCode]);
24
+ return /*#__PURE__*/React.createElement(NewsroomContext.Provider, {
25
+ value: {
26
+ categories,
27
+ contacts,
28
+ newsroom,
29
+ currentCategory,
30
+ currentStory,
31
+ companyInformation,
32
+ languages,
33
+ locale,
34
+ notifications,
35
+ themePreset,
36
+ algoliaSettings
37
+ }
38
+ }, children);
39
+ }
@@ -1,12 +1,11 @@
1
- export * from './useAlgoliaSettings';
2
- export * from './useCategories';
3
- export * from './useCompanyInformation';
4
- export * from './useCurrentCategory';
5
- export * from './useCurrentLocale';
6
- export * from './useCurrentStory';
7
- export * from './useGetLinkLocaleSlug';
8
- export * from './useGetTranslationUrl';
9
- export * from './useLanguages';
10
- export * from './useNewsroom';
11
- export * from './useNewsroomContext';
12
- //# sourceMappingURL=index.js.map
1
+ export * from "./useAlgoliaSettings.js";
2
+ export * from "./useCategories.js";
3
+ export * from "./useCompanyInformation.js";
4
+ export * from "./useCurrentCategory.js";
5
+ export * from "./useCurrentLocale.js";
6
+ export * from "./useCurrentStory.js";
7
+ export * from "./useGetLinkLocaleSlug.js";
8
+ export * from "./useGetTranslationUrl.js";
9
+ export * from "./useLanguages.js";
10
+ export * from "./useNewsroom.js";
11
+ export * from "./useNewsroomContext.js";
@@ -1,6 +1,5 @@
1
- import { useNewsroomContext } from './useNewsroomContext';
1
+ import { useNewsroomContext } from "./useNewsroomContext.js";
2
2
  export function useAlgoliaSettings() {
3
- const context = useNewsroomContext();
4
- return context.algoliaSettings;
5
- }
6
- //# sourceMappingURL=useAlgoliaSettings.js.map
3
+ const context = useNewsroomContext();
4
+ return context.algoliaSettings;
5
+ }
@@ -1,6 +1,5 @@
1
- import { useNewsroomContext } from './useNewsroomContext';
1
+ import { useNewsroomContext } from "./useNewsroomContext.js";
2
2
  export function useCategories() {
3
- const context = useNewsroomContext();
4
- return context.categories;
5
- }
6
- //# sourceMappingURL=useCategories.js.map
3
+ const context = useNewsroomContext();
4
+ return context.categories;
5
+ }
@@ -1,6 +1,5 @@
1
- import { useNewsroomContext } from './useNewsroomContext';
1
+ import { useNewsroomContext } from "./useNewsroomContext.js";
2
2
  export function useCompanyInformation() {
3
- const context = useNewsroomContext();
4
- return context.companyInformation;
5
- }
6
- //# sourceMappingURL=useCompanyInformation.js.map
3
+ const context = useNewsroomContext();
4
+ return context.companyInformation;
5
+ }
@@ -1,6 +1,5 @@
1
- import { useNewsroomContext } from './useNewsroomContext';
1
+ import { useNewsroomContext } from "./useNewsroomContext.js";
2
2
  export function useCurrentCategory() {
3
- const context = useNewsroomContext();
4
- return context.currentCategory;
5
- }
6
- //# sourceMappingURL=useCurrentCategory.js.map
3
+ const context = useNewsroomContext();
4
+ return context.currentCategory;
5
+ }
@@ -1,6 +1,5 @@
1
- import { useNewsroomContext } from './useNewsroomContext';
1
+ import { useNewsroomContext } from "./useNewsroomContext.js";
2
2
  export function useCurrentLocale() {
3
- const context = useNewsroomContext();
4
- return context.locale;
5
- }
6
- //# sourceMappingURL=useCurrentLocale.js.map
3
+ const context = useNewsroomContext();
4
+ return context.locale;
5
+ }
@@ -1,6 +1,5 @@
1
- import { useNewsroomContext } from './useNewsroomContext';
1
+ import { useNewsroomContext } from "./useNewsroomContext.js";
2
2
  export function useCurrentStory() {
3
- const context = useNewsroomContext();
4
- return context.currentStory;
5
- }
6
- //# sourceMappingURL=useCurrentStory.js.map
3
+ const context = useNewsroomContext();
4
+ return context.currentStory;
5
+ }
@@ -1,7 +1,7 @@
1
1
  import { useCallback } from 'react';
2
- import { getShortestLocaleCode, LocaleObject } from '../../intl';
3
- import { useCurrentLocale } from './useCurrentLocale';
4
- import { useLanguages } from './useLanguages';
2
+ import { getShortestLocaleCode, LocaleObject } from "../../intl/index.js";
3
+ import { useCurrentLocale } from "./useCurrentLocale.js";
4
+ import { useLanguages } from "./useLanguages.js";
5
5
  /**
6
6
  * Determines correct locale slug for the link (trying to shorten the locale code if possible).
7
7
  * E.g. if newsroom has a single locale for Dutch (`nl_BE`), it will be shortened to `nl`.
@@ -9,17 +9,17 @@ import { useLanguages } from './useLanguages';
9
9
  * `false` means that a default locale should be used (no locale in URL required).
10
10
  */
11
11
  function getLinkLocaleSlug(languages, locale) {
12
- const shortestLocaleCode = getShortestLocaleCode(languages, locale);
13
- // When navigating to default language, we don't append the locale to the URL.
14
- if (!shortestLocaleCode) {
15
- return shortestLocaleCode;
16
- }
17
- return LocaleObject.fromAnyCode(shortestLocaleCode).toUrlSlug();
12
+ const shortestLocaleCode = getShortestLocaleCode(languages, locale);
13
+ // When navigating to default language, we don't append the locale to the URL.
14
+ if (!shortestLocaleCode) {
15
+ return shortestLocaleCode;
16
+ }
17
+ return LocaleObject.fromAnyCode(shortestLocaleCode).toUrlSlug();
18
18
  }
19
19
  export function useGetLinkLocaleSlug() {
20
- const currentLocale = useCurrentLocale();
21
- const languages = useLanguages();
22
- // The `locale` parameter is mainly used for Language Dropdown
23
- return useCallback((locale) => getLinkLocaleSlug(languages, locale || currentLocale), [languages, currentLocale]);
24
- }
25
- //# sourceMappingURL=useGetLinkLocaleSlug.js.map
20
+ const currentLocale = useCurrentLocale();
21
+ const languages = useLanguages();
22
+
23
+ // The `locale` parameter is mainly used for Language Dropdown
24
+ return useCallback(locale => getLinkLocaleSlug(languages, locale || currentLocale), [languages, currentLocale]);
25
+ }
@@ -1,26 +1,25 @@
1
1
  import { Story } from '@prezly/sdk';
2
2
  import { useRouter } from 'next/router';
3
3
  import { useCallback } from 'react';
4
- import { getCategoryHasTranslation, getCategoryUrl } from '../../utils';
5
- import { useCurrentCategory } from './useCurrentCategory';
6
- import { useCurrentStory } from './useCurrentStory';
4
+ import { getCategoryHasTranslation, getCategoryUrl } from "../../utils/index.js";
5
+ import { useCurrentCategory } from "./useCurrentCategory.js";
6
+ import { useCurrentStory } from "./useCurrentStory.js";
7
7
  function getAllowedTranslationVisibilityValues(story) {
8
- const { visibility } = story;
9
- switch (visibility) {
10
- case Story.Visibility.EMBARGO:
11
- return [Story.Visibility.EMBARGO, Story.Visibility.PUBLIC];
12
- case Story.Visibility.PRIVATE:
13
- return [Story.Visibility.PRIVATE, Story.Visibility.PUBLIC];
14
- case Story.Visibility.CONFIDENTIAL:
15
- return [
16
- Story.Visibility.CONFIDENTIAL,
17
- Story.Visibility.PRIVATE,
18
- Story.Visibility.PUBLIC,
19
- ];
20
- default:
21
- return [Story.Visibility.PUBLIC];
22
- }
8
+ const {
9
+ visibility
10
+ } = story;
11
+ switch (visibility) {
12
+ case Story.Visibility.EMBARGO:
13
+ return [Story.Visibility.EMBARGO, Story.Visibility.PUBLIC];
14
+ case Story.Visibility.PRIVATE:
15
+ return [Story.Visibility.PRIVATE, Story.Visibility.PUBLIC];
16
+ case Story.Visibility.CONFIDENTIAL:
17
+ return [Story.Visibility.CONFIDENTIAL, Story.Visibility.PRIVATE, Story.Visibility.PUBLIC];
18
+ default:
19
+ return [Story.Visibility.PUBLIC];
20
+ }
23
21
  }
22
+
24
23
  /**
25
24
  * Determine correct URL for translated stories/categories with a fallback to homepage.
26
25
  * E.g. if a story has a translation, the function will return the localized slug URL.
@@ -28,37 +27,42 @@ function getAllowedTranslationVisibilityValues(story) {
28
27
  * or empty string, if `noFallback` is set to `true` (this is useful for alternate locale links).
29
28
  */
30
29
  function getTranslationUrl(locale, path, currentCategory, currentStory, noFallback) {
31
- if (currentCategory) {
32
- if (getCategoryHasTranslation(currentCategory, locale)) {
33
- return getCategoryUrl(currentCategory, locale);
34
- }
35
- if (noFallback) {
36
- return '';
37
- }
38
- return '/';
30
+ if (currentCategory) {
31
+ if (getCategoryHasTranslation(currentCategory, locale)) {
32
+ return getCategoryUrl(currentCategory, locale);
33
+ }
34
+ if (noFallback) {
35
+ return '';
39
36
  }
40
- const localeCode = locale.toUnderscoreCode();
41
- if (currentStory && currentStory.culture.locale !== localeCode) {
42
- const allowedVisibilityValues = getAllowedTranslationVisibilityValues(currentStory);
43
- const translatedStory = currentStory.translations.find(({ culture, visibility }) => culture.locale === localeCode && allowedVisibilityValues.includes(visibility));
44
- if (translatedStory) {
45
- return `/${translatedStory.slug}`;
46
- }
47
- if (noFallback) {
48
- return '';
49
- }
50
- return '/';
37
+ return '/';
38
+ }
39
+ const localeCode = locale.toUnderscoreCode();
40
+ if (currentStory && currentStory.culture.locale !== localeCode) {
41
+ const allowedVisibilityValues = getAllowedTranslationVisibilityValues(currentStory);
42
+ const translatedStory = currentStory.translations.find(({
43
+ culture,
44
+ visibility
45
+ }) => culture.locale === localeCode && allowedVisibilityValues.includes(visibility));
46
+ if (translatedStory) {
47
+ return `/${translatedStory.slug}`;
51
48
  }
52
- return path;
49
+ if (noFallback) {
50
+ return '';
51
+ }
52
+ return '/';
53
+ }
54
+ return path;
53
55
  }
56
+
54
57
  /**
55
58
  * This hook returns a function that is meant to be used in language pickers and alternate locales list for the pages.
56
59
  * `noFallback` parameter is useful for alternate language links in the `head` section of the document (so that there are no unwanted links to the homepage).
57
60
  */
58
61
  export function useGetTranslationUrl() {
59
- const { asPath } = useRouter();
60
- const currentCategory = useCurrentCategory();
61
- const currentStory = useCurrentStory();
62
- return useCallback((locale, noFallback) => getTranslationUrl(locale, asPath, currentCategory, currentStory, noFallback), [asPath, currentCategory, currentStory]);
63
- }
64
- //# sourceMappingURL=useGetTranslationUrl.js.map
62
+ const {
63
+ asPath
64
+ } = useRouter();
65
+ const currentCategory = useCurrentCategory();
66
+ const currentStory = useCurrentStory();
67
+ return useCallback((locale, noFallback) => getTranslationUrl(locale, asPath, currentCategory, currentStory, noFallback), [asPath, currentCategory, currentStory]);
68
+ }
@@ -1,6 +1,5 @@
1
- import { useNewsroomContext } from './useNewsroomContext';
1
+ import { useNewsroomContext } from "./useNewsroomContext.js";
2
2
  export function useLanguages() {
3
- const context = useNewsroomContext();
4
- return context.languages;
5
- }
6
- //# sourceMappingURL=useLanguages.js.map
3
+ const context = useNewsroomContext();
4
+ return context.languages;
5
+ }
@@ -1,6 +1,5 @@
1
- import { useNewsroomContext } from './useNewsroomContext';
1
+ import { useNewsroomContext } from "./useNewsroomContext.js";
2
2
  export function useNewsroom() {
3
- const context = useNewsroomContext();
4
- return context.newsroom;
5
- }
6
- //# sourceMappingURL=useNewsroom.js.map
3
+ const context = useNewsroomContext();
4
+ return context.newsroom;
5
+ }
@@ -1,12 +1,11 @@
1
1
  import { useContext } from 'react';
2
- import { NewsroomContext } from '../context';
2
+ import { NewsroomContext } from "../context.js";
3
3
  export function useNewsroomContext() {
4
- // TS Compiler is having a hard time figuring this type implicitly, so we have to set it explicitly
5
- // See https://github.com/microsoft/TypeScript/issues/5711#issuecomment-340283439
6
- const newsroomContext = useContext(NewsroomContext);
7
- if (!newsroomContext) {
8
- throw new Error('No `NewsroomContextProvider` found when calling `useNewsroomContext`');
9
- }
10
- return newsroomContext;
11
- }
12
- //# sourceMappingURL=useNewsroomContext.js.map
4
+ // TS Compiler is having a hard time figuring this type implicitly, so we have to set it explicitly
5
+ // See https://github.com/microsoft/TypeScript/issues/5711#issuecomment-340283439
6
+ const newsroomContext = useContext(NewsroomContext);
7
+ if (!newsroomContext) {
8
+ throw new Error('No `NewsroomContextProvider` found when calling `useNewsroomContext`');
9
+ }
10
+ return newsroomContext;
11
+ }
@@ -1,3 +1,2 @@
1
- export { NewsroomContext, NewsroomContextProvider } from './context';
2
- export * from './hooks';
3
- //# sourceMappingURL=index.js.map
1
+ export { NewsroomContext, NewsroomContextProvider, NewsroomContextProps } from "./context.js";
2
+ export * from "./hooks/index.js";
@@ -1,5 +1,4 @@
1
- import { getCommonClientOptions } from './common';
1
+ import { getCommonClientOptions } from "./common.js";
2
2
  export function getSentryClientOptions(dsn, themeName) {
3
- return getCommonClientOptions(dsn, themeName);
4
- }
5
- //# sourceMappingURL=client.js.map
3
+ return getCommonClientOptions(dsn, themeName);
4
+ }
@@ -1,25 +1,26 @@
1
1
  export function getCommonClientOptions(dsn, themeName) {
2
- return {
3
- dsn,
4
- // Adjust this value in production, or use tracesSampler for greater control
5
- tracesSampleRate: 0.02,
6
- // ...
7
- // Note: if you want to override the automatic release value, do not set a
8
- // `release` value here - use the environment variable `SENTRY_RELEASE`, so
9
- // that it will also get attached to your source maps
10
- ignoreErrors: [
11
- // This particular error is coming from Microsoft Outlook SafeLink crawler.
12
- // It doesn't affect the user experience in any way, but produces a lot of unwanted Sentry events.
13
- // See https://forum.sentry.io/t/unhandledrejection-non-error-promise-rejection-captured-with-value/14062
14
- 'Object Not Found Matching Id',
15
- // This error is caused by `beacon.min.js` polyfill in Cloudflare Insights. From what we see, it doesn't affect the user experience.
16
- 'Illegal invocation',
17
- ],
18
- // Attach theme tag to each event
19
- initialScope: (scope) => {
20
- scope.setTags({ prezly_theme: themeName });
21
- return scope;
22
- },
23
- };
24
- }
25
- //# sourceMappingURL=common.js.map
2
+ return {
3
+ dsn,
4
+ // Adjust this value in production, or use tracesSampler for greater control
5
+ tracesSampleRate: 0.02,
6
+ // ...
7
+ // Note: if you want to override the automatic release value, do not set a
8
+ // `release` value here - use the environment variable `SENTRY_RELEASE`, so
9
+ // that it will also get attached to your source maps
10
+
11
+ ignoreErrors: [
12
+ // This particular error is coming from Microsoft Outlook SafeLink crawler.
13
+ // It doesn't affect the user experience in any way, but produces a lot of unwanted Sentry events.
14
+ // See https://forum.sentry.io/t/unhandledrejection-non-error-promise-rejection-captured-with-value/14062
15
+ 'Object Not Found Matching Id',
16
+ // This error is caused by `beacon.min.js` polyfill in Cloudflare Insights. From what we see, it doesn't affect the user experience.
17
+ 'Illegal invocation'],
18
+ // Attach theme tag to each event
19
+ initialScope: scope => {
20
+ scope.setTags({
21
+ prezly_theme: themeName
22
+ });
23
+ return scope;
24
+ }
25
+ };
26
+ }
@@ -1,3 +1,2 @@
1
- export { getSentryClientOptions } from './client';
2
- export { getSentryServerOptions } from './server';
3
- //# sourceMappingURL=index.js.map
1
+ export { getSentryClientOptions } from "./client.js";
2
+ export { getSentryServerOptions } from "./server.js";
@@ -1,5 +1,4 @@
1
- import { getCommonClientOptions } from './common';
1
+ import { getCommonClientOptions } from "./common.js";
2
2
  export function getSentryServerOptions(dsn, themeName) {
3
- return getCommonClientOptions(dsn, themeName);
4
- }
5
- //# sourceMappingURL=server.js.map
3
+ return getCommonClientOptions(dsn, themeName);
4
+ }
package/build/types.js CHANGED
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
1
+ export {};
@@ -1,18 +1,9 @@
1
1
  export function hasAnySocialMedia(companyInformation) {
2
- return Boolean(companyInformation.facebook ||
3
- companyInformation.instagram ||
4
- companyInformation.linkedin ||
5
- companyInformation.pinterest ||
6
- companyInformation.tiktok ||
7
- companyInformation.twitter ||
8
- companyInformation.youtube);
2
+ return Boolean(companyInformation.facebook || companyInformation.instagram || companyInformation.linkedin || companyInformation.pinterest || companyInformation.tiktok || companyInformation.twitter || companyInformation.youtube);
9
3
  }
10
4
  export function hasAnyAboutInformation(companyInformation) {
11
- return Boolean(companyInformation.about ||
12
- companyInformation.website ||
13
- hasAnySocialMedia(companyInformation));
5
+ return Boolean(companyInformation.about || companyInformation.website || hasAnySocialMedia(companyInformation));
14
6
  }
15
7
  export function hasAnyContactInformation(companyInformation) {
16
- return Boolean(companyInformation.address || companyInformation.phone || companyInformation.email);
17
- }
18
- //# sourceMappingURL=boilerplate.js.map
8
+ return Boolean(companyInformation.address || companyInformation.phone || companyInformation.email);
9
+ }