@anywayseo/tools 5.11.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/dist/components/game-demo/index.d.ts +2 -6
  2. package/dist/components/index.cjs +3 -3
  3. package/dist/components/index.mjs +3 -3
  4. package/dist/components/seo/href-langs/index.d.ts +8 -0
  5. package/dist/components/seo/index.d.ts +3 -2
  6. package/dist/components/seo/json-ld/index.d.ts +7 -0
  7. package/dist/components/seo/types.d.ts +4 -3
  8. package/dist/components/seo/utils.d.ts +1 -0
  9. package/dist/components/{strapi-component → strapi-content-renderer/strapi-component}/external-image/index.d.ts +1 -1
  10. package/dist/components/{strapi-component → strapi-content-renderer/strapi-component}/index.d.ts +1 -1
  11. package/dist/components/{strapi-component → strapi-content-renderer/strapi-component}/rich-text/index.d.ts +2 -1
  12. package/dist/components/{strapi-component → strapi-content-renderer/strapi-component}/utils.d.ts +1 -1
  13. package/dist/hooks/index.cjs +1 -1
  14. package/dist/hooks/index.mjs +1 -1
  15. package/dist/i18n/index.cjs +24 -12
  16. package/dist/i18n/index.mjs +24 -12
  17. package/dist/i18n/resources/bn/index.d.ts +331 -0
  18. package/dist/i18n/resources/cs/index.d.ts +331 -0
  19. package/dist/i18n/resources/el/index.d.ts +331 -0
  20. package/dist/i18n/resources/hu/index.d.ts +331 -0
  21. package/dist/i18n/resources/nb/index.d.ts +331 -0
  22. package/dist/i18n/resources/nl/index.d.ts +331 -0
  23. package/dist/i18n/resources/pl/index.d.ts +331 -0
  24. package/dist/i18n/resources/ro/index.d.ts +331 -0
  25. package/dist/i18n/resources/sr/index.d.ts +331 -0
  26. package/dist/i18n/resources/sv/index.d.ts +331 -0
  27. package/dist/i18n/resources/tr/index.d.ts +331 -0
  28. package/dist/i18n/resources/uz/index.d.ts +331 -0
  29. package/dist/{index-DqMBmwe5.mjs → index-2sU4ya6z.mjs} +5 -6
  30. package/dist/{index-B6wLLS6t.mjs → index-B5WurBlm.mjs} +2 -2
  31. package/dist/{index-Ca9tsjT8.js → index-BAxlqkw0.js} +2 -2
  32. package/dist/{index-CG7F6SYt.mjs → index-BBU_vIrY.mjs} +68 -30
  33. package/dist/{index-C1kr7Vd-.mjs → index-BS5T9Il4.mjs} +1 -1
  34. package/dist/{index-RzByAgHO.mjs → index-C6A-3gBz.mjs} +4577 -432
  35. package/dist/{index-hGzNO4AL.js → index-C93pA9Jv.js} +69 -31
  36. package/dist/{index-C3n63_nP.js → index-CAjUjAgI.js} +1 -1
  37. package/dist/{index-CBRFCYhV.js → index-CMLDQbgR.js} +4577 -432
  38. package/dist/{index-DSP348cK.mjs → index-CQC6DRGf.mjs} +1 -1
  39. package/dist/index-CnVcCa5O.js +151 -0
  40. package/dist/index-CoNbTY7l.mjs +152 -0
  41. package/dist/{index-CVv755RW.js → index-CuIVcnIS.js} +1 -1
  42. package/dist/{index-DhhGhwm2.js → index-CxuOu0E2.js} +5 -6
  43. package/dist/{index-D-jM-cHx.js → index-DAPaiozu.js} +2 -2
  44. package/dist/index-MnQnVvsM.mjs +198 -0
  45. package/dist/index-P_fDAJVz.js +197 -0
  46. package/dist/{index-CPbWQKoT.mjs → index-TcBorTSf.mjs} +2 -2
  47. package/dist/index.cjs +20 -9
  48. package/dist/index.mjs +31 -20
  49. package/dist/layout/header/locale-switcher/icons/bangladesh/index.d.ts +2 -0
  50. package/dist/layout/header/locale-switcher/icons/belgium/index.d.ts +2 -0
  51. package/dist/layout/header/locale-switcher/icons/canada/index.d.ts +2 -0
  52. package/dist/layout/header/locale-switcher/icons/czechia/index.d.ts +2 -0
  53. package/dist/layout/header/locale-switcher/icons/greece/index.d.ts +2 -0
  54. package/dist/layout/header/locale-switcher/icons/hungary/index.d.ts +2 -0
  55. package/dist/layout/header/locale-switcher/icons/index.d.ts +20 -1
  56. package/dist/layout/header/locale-switcher/icons/india/index.d.ts +2 -0
  57. package/dist/layout/header/locale-switcher/icons/morocco/index.d.ts +2 -0
  58. package/dist/layout/header/locale-switcher/icons/netherlands/index.d.ts +2 -0
  59. package/dist/layout/header/locale-switcher/icons/nigeria/index.d.ts +2 -0
  60. package/dist/layout/header/locale-switcher/icons/norway/index.d.ts +2 -0
  61. package/dist/layout/header/locale-switcher/icons/poland/index.d.ts +2 -0
  62. package/dist/layout/header/locale-switcher/icons/romania/index.d.ts +2 -0
  63. package/dist/layout/header/locale-switcher/icons/serbia/index.d.ts +2 -0
  64. package/dist/layout/header/locale-switcher/icons/south-africa/index.d.ts +2 -0
  65. package/dist/layout/header/locale-switcher/icons/sweden/index.d.ts +2 -0
  66. package/dist/layout/header/locale-switcher/icons/switzerland/index.d.ts +2 -0
  67. package/dist/layout/header/locale-switcher/icons/turkey/index.d.ts +2 -0
  68. package/dist/layout/header/locale-switcher/icons/uzbekistan/index.d.ts +2 -0
  69. package/dist/layout/index.cjs +396 -52
  70. package/dist/layout/index.mjs +396 -52
  71. package/dist/providers/index.cjs +2 -2
  72. package/dist/providers/index.mjs +2 -2
  73. package/dist/providers/site-provider/index.d.ts +2 -1
  74. package/dist/types/api/index.d.ts +2 -16
  75. package/dist/types/api/strapi-navigation.d.ts +16 -0
  76. package/dist/types/api/strapi-page.d.ts +46 -0
  77. package/dist/types/components/game-demo/index.d.ts +5 -0
  78. package/dist/types/components/index.d.ts +1 -1
  79. package/dist/types/content/seo/index.d.ts +38 -1
  80. package/dist/types/i18n/index.d.ts +1 -1
  81. package/dist/types/index.d.ts +1 -1
  82. package/dist/types/json-ld/index.d.ts +162 -0
  83. package/dist/types/site/index.d.ts +9 -4
  84. package/dist/utils/api/index.d.ts +4 -2
  85. package/dist/utils/api/strapi-guards.d.ts +5 -0
  86. package/dist/utils/api/strapi-navigation.d.ts +2 -0
  87. package/dist/utils/api/strapi-seo.d.ts +13 -0
  88. package/dist/utils/index.cjs +14 -3
  89. package/dist/utils/index.d.ts +1 -0
  90. package/dist/utils/index.mjs +25 -14
  91. package/dist/utils/json-ld/index.d.ts +70 -0
  92. package/dist/utils/navigation/index.d.ts +1 -1
  93. package/package.json +1 -1
  94. package/dist/components/strapi-content-renderer/utils.d.ts +0 -2
  95. package/dist/index-Ba_pXx_e.js +0 -97
  96. package/dist/index-BeJTy4iY.mjs +0 -26
  97. package/dist/index-BfITsKAr.js +0 -25
  98. package/dist/index-CJANSiM5.mjs +0 -98
  99. package/dist/types/components/strapi-component/index.d.ts +0 -5
  100. package/dist/types/page/index.d.ts +0 -7
@@ -1,7 +1,7 @@
1
1
  function buildPath(slug, parentSlug) {
2
2
  return parentSlug === "" ? slug : `${parentSlug}/${slug}`;
3
3
  }
4
- function buildCanonicalUrl(domain, path) {
4
+ function buildCanonicalUrl(domain, path = "") {
5
5
  const cleanPath = path.split(/[?#]/)[0];
6
6
  return `https://${domain}${cleanPath === "/" ? "" : cleanPath}`;
7
7
  }
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+ const i18n = require("./i18n/index.cjs");
3
+ function isStrapiContent(array) {
4
+ return Array.isArray(array) && array.every(
5
+ (item) => typeof item === "object" && item !== null && "__typename" in item && typeof item.__typename === "string"
6
+ );
7
+ }
8
+ function isStrapiRichText(value) {
9
+ return Boolean(
10
+ value && typeof value === "object" && "__typename" in value && value.__typename === "STRAPI__COMPONENT_CONTENT_RICH_TEXT"
11
+ );
12
+ }
13
+ function isStrapiPageData(data) {
14
+ const maybe = data;
15
+ return Boolean(typeof data === "object" && maybe.content);
16
+ }
17
+ function isStrapiPageContext(context) {
18
+ const maybe = context;
19
+ return Boolean(typeof context === "object" && maybe.hrefLangs);
20
+ }
21
+ function getCurrencySymbol(currencyCode, locale = i18n.DEFAULT_LANGUAGE) {
22
+ const symbol = 0 .toLocaleString(locale, {
23
+ style: "currency",
24
+ currency: currencyCode,
25
+ minimumFractionDigits: 0,
26
+ maximumFractionDigits: 0
27
+ }).replace(/\d/g, "").trim();
28
+ return symbol;
29
+ }
30
+ function buildGraph(schemas) {
31
+ return Object.values(schemas);
32
+ }
33
+ const id = {
34
+ organization: (siteUrl) => `${siteUrl}/#organization`,
35
+ website: (siteUrl) => `${siteUrl}/#website`,
36
+ webpage: (pageUrl) => `${pageUrl}`,
37
+ review: (pageUrl) => `${pageUrl}#review`,
38
+ game: (pageUrl) => `${pageUrl}#game`,
39
+ author: (authorPageUrl) => `${authorPageUrl}#person`
40
+ };
41
+ function buildOrganizationSchema(params) {
42
+ const { site, lang } = params;
43
+ const logoUrl = `${site.url}${site.logo.url}`;
44
+ return {
45
+ "@type": "Organization",
46
+ "@id": id.organization(site.url),
47
+ name: site.name,
48
+ url: site.url,
49
+ logo: {
50
+ "@type": "ImageObject",
51
+ url: logoUrl,
52
+ contentUrl: logoUrl,
53
+ width: site.logo.width,
54
+ height: site.logo.height,
55
+ caption: site.logo.alt,
56
+ inLanguage: lang
57
+ }
58
+ };
59
+ }
60
+ function buildWebsiteSchema(params) {
61
+ const { site, lang } = params;
62
+ return {
63
+ "@type": "WebSite",
64
+ "@id": id.website(site.url),
65
+ url: site.url,
66
+ name: site.name,
67
+ inLanguage: lang,
68
+ publisher: { "@id": id.organization(site.url) }
69
+ };
70
+ }
71
+ function getEntitySchema({ site, page, structuredData }) {
72
+ if (!structuredData) {
73
+ return null;
74
+ }
75
+ const { entity, content } = structuredData;
76
+ if (entity === "game-review" && content.review && content.game) {
77
+ return buildGameReviewSchema({ site, page, author: content.author, review: content.review, game: content.game });
78
+ }
79
+ return null;
80
+ }
81
+ function buildWebpageSchema(params, mainEntity) {
82
+ const { site, page, lang } = params;
83
+ return {
84
+ "@type": "WebPage",
85
+ "@id": id.webpage(page.url),
86
+ url: page.url,
87
+ name: page.title,
88
+ ...page.description ? { description: page.description } : {},
89
+ inLanguage: lang,
90
+ isPartOf: { "@id": id.website(site.url) },
91
+ ...mainEntity ? { mainEntity } : {}
92
+ };
93
+ }
94
+ function buildGameReviewSchema(params) {
95
+ const { site, page, author, review, game } = params;
96
+ return {
97
+ "@type": "Review",
98
+ "@id": id.review(page.url),
99
+ name: review.title,
100
+ reviewBody: review.description,
101
+ ...author ? {
102
+ author: {
103
+ "@type": "Person",
104
+ name: author.name,
105
+ ...author.url ? { "@id": id.author(author.url), url: author.url } : {}
106
+ }
107
+ } : {},
108
+ publisher: { "@id": id.organization(site.url) },
109
+ datePublished: review.publishedAt,
110
+ dateModified: review.updatedAt || review.publishedAt,
111
+ ...review.rating ? {
112
+ reviewRating: {
113
+ "@type": "Rating",
114
+ ratingValue: review.rating.value,
115
+ bestRating: review.rating.max,
116
+ worstRating: review.rating.min
117
+ }
118
+ } : {},
119
+ itemReviewed: {
120
+ "@type": "Game",
121
+ "@id": id.game(page.url),
122
+ url: page.url,
123
+ name: game.name,
124
+ ...game.genre ? { genre: game.genre } : {}
125
+ }
126
+ };
127
+ }
128
+ function randomComparator() {
129
+ return Math.random() - 0.5;
130
+ }
131
+ function seededRandom(seed) {
132
+ return Math.abs(Math.sin(seed));
133
+ }
134
+ function getSeededRandomComparator(seed) {
135
+ const safeSeed = Math.abs(seed) % Number.MAX_SAFE_INTEGER;
136
+ let index = 0;
137
+ return () => seededRandom(safeSeed + index++) - 0.5;
138
+ }
139
+ exports.buildGameReviewSchema = buildGameReviewSchema;
140
+ exports.buildGraph = buildGraph;
141
+ exports.buildOrganizationSchema = buildOrganizationSchema;
142
+ exports.buildWebpageSchema = buildWebpageSchema;
143
+ exports.buildWebsiteSchema = buildWebsiteSchema;
144
+ exports.getCurrencySymbol = getCurrencySymbol;
145
+ exports.getEntitySchema = getEntitySchema;
146
+ exports.getSeededRandomComparator = getSeededRandomComparator;
147
+ exports.isStrapiContent = isStrapiContent;
148
+ exports.isStrapiPageContext = isStrapiPageContext;
149
+ exports.isStrapiPageData = isStrapiPageData;
150
+ exports.isStrapiRichText = isStrapiRichText;
151
+ exports.randomComparator = randomComparator;
@@ -0,0 +1,152 @@
1
+ import { DEFAULT_LANGUAGE } from "./i18n/index.mjs";
2
+ function isStrapiContent(array) {
3
+ return Array.isArray(array) && array.every(
4
+ (item) => typeof item === "object" && item !== null && "__typename" in item && typeof item.__typename === "string"
5
+ );
6
+ }
7
+ function isStrapiRichText(value) {
8
+ return Boolean(
9
+ value && typeof value === "object" && "__typename" in value && value.__typename === "STRAPI__COMPONENT_CONTENT_RICH_TEXT"
10
+ );
11
+ }
12
+ function isStrapiPageData(data) {
13
+ const maybe = data;
14
+ return Boolean(typeof data === "object" && maybe.content);
15
+ }
16
+ function isStrapiPageContext(context) {
17
+ const maybe = context;
18
+ return Boolean(typeof context === "object" && maybe.hrefLangs);
19
+ }
20
+ function getCurrencySymbol(currencyCode, locale = DEFAULT_LANGUAGE) {
21
+ const symbol = 0 .toLocaleString(locale, {
22
+ style: "currency",
23
+ currency: currencyCode,
24
+ minimumFractionDigits: 0,
25
+ maximumFractionDigits: 0
26
+ }).replace(/\d/g, "").trim();
27
+ return symbol;
28
+ }
29
+ function buildGraph(schemas) {
30
+ return Object.values(schemas);
31
+ }
32
+ const id = {
33
+ organization: (siteUrl) => `${siteUrl}/#organization`,
34
+ website: (siteUrl) => `${siteUrl}/#website`,
35
+ webpage: (pageUrl) => `${pageUrl}`,
36
+ review: (pageUrl) => `${pageUrl}#review`,
37
+ game: (pageUrl) => `${pageUrl}#game`,
38
+ author: (authorPageUrl) => `${authorPageUrl}#person`
39
+ };
40
+ function buildOrganizationSchema(params) {
41
+ const { site, lang } = params;
42
+ const logoUrl = `${site.url}${site.logo.url}`;
43
+ return {
44
+ "@type": "Organization",
45
+ "@id": id.organization(site.url),
46
+ name: site.name,
47
+ url: site.url,
48
+ logo: {
49
+ "@type": "ImageObject",
50
+ url: logoUrl,
51
+ contentUrl: logoUrl,
52
+ width: site.logo.width,
53
+ height: site.logo.height,
54
+ caption: site.logo.alt,
55
+ inLanguage: lang
56
+ }
57
+ };
58
+ }
59
+ function buildWebsiteSchema(params) {
60
+ const { site, lang } = params;
61
+ return {
62
+ "@type": "WebSite",
63
+ "@id": id.website(site.url),
64
+ url: site.url,
65
+ name: site.name,
66
+ inLanguage: lang,
67
+ publisher: { "@id": id.organization(site.url) }
68
+ };
69
+ }
70
+ function getEntitySchema({ site, page, structuredData }) {
71
+ if (!structuredData) {
72
+ return null;
73
+ }
74
+ const { entity, content } = structuredData;
75
+ if (entity === "game-review" && content.review && content.game) {
76
+ return buildGameReviewSchema({ site, page, author: content.author, review: content.review, game: content.game });
77
+ }
78
+ return null;
79
+ }
80
+ function buildWebpageSchema(params, mainEntity) {
81
+ const { site, page, lang } = params;
82
+ return {
83
+ "@type": "WebPage",
84
+ "@id": id.webpage(page.url),
85
+ url: page.url,
86
+ name: page.title,
87
+ ...page.description ? { description: page.description } : {},
88
+ inLanguage: lang,
89
+ isPartOf: { "@id": id.website(site.url) },
90
+ ...mainEntity ? { mainEntity } : {}
91
+ };
92
+ }
93
+ function buildGameReviewSchema(params) {
94
+ const { site, page, author, review, game } = params;
95
+ return {
96
+ "@type": "Review",
97
+ "@id": id.review(page.url),
98
+ name: review.title,
99
+ reviewBody: review.description,
100
+ ...author ? {
101
+ author: {
102
+ "@type": "Person",
103
+ name: author.name,
104
+ ...author.url ? { "@id": id.author(author.url), url: author.url } : {}
105
+ }
106
+ } : {},
107
+ publisher: { "@id": id.organization(site.url) },
108
+ datePublished: review.publishedAt,
109
+ dateModified: review.updatedAt || review.publishedAt,
110
+ ...review.rating ? {
111
+ reviewRating: {
112
+ "@type": "Rating",
113
+ ratingValue: review.rating.value,
114
+ bestRating: review.rating.max,
115
+ worstRating: review.rating.min
116
+ }
117
+ } : {},
118
+ itemReviewed: {
119
+ "@type": "Game",
120
+ "@id": id.game(page.url),
121
+ url: page.url,
122
+ name: game.name,
123
+ ...game.genre ? { genre: game.genre } : {}
124
+ }
125
+ };
126
+ }
127
+ function randomComparator() {
128
+ return Math.random() - 0.5;
129
+ }
130
+ function seededRandom(seed) {
131
+ return Math.abs(Math.sin(seed));
132
+ }
133
+ function getSeededRandomComparator(seed) {
134
+ const safeSeed = Math.abs(seed) % Number.MAX_SAFE_INTEGER;
135
+ let index = 0;
136
+ return () => seededRandom(safeSeed + index++) - 0.5;
137
+ }
138
+ export {
139
+ isStrapiRichText as a,
140
+ isStrapiPageData as b,
141
+ isStrapiPageContext as c,
142
+ buildGraph as d,
143
+ buildOrganizationSchema as e,
144
+ buildWebsiteSchema as f,
145
+ getCurrencySymbol as g,
146
+ getEntitySchema as h,
147
+ isStrapiContent as i,
148
+ buildWebpageSchema as j,
149
+ buildGameReviewSchema as k,
150
+ getSeededRandomComparator as l,
151
+ randomComparator as r
152
+ };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  const react = require("@chakra-ui/react");
3
3
  require("./index-C6MG_f24.js");
4
- require("./index-CBRFCYhV.js");
4
+ require("./index-CMLDQbgR.js");
5
5
  const index = require("./index-CbuiYkSg.js");
6
6
  function usePrimaryColors() {
7
7
  const color = react.useColorModeValue(index.LIGHT_THEME_COLOR, index.DARK_THEME_COLOR);
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  const jsxRuntime = require("react/jsx-runtime");
3
3
  const react = require("@chakra-ui/react");
4
- const index = require("./index-D-jM-cHx.js");
4
+ const index = require("./index-DAPaiozu.js");
5
5
  require("@mdx-js/react");
6
6
  const reactI18next = require("react-i18next");
7
7
  const index$2 = require("./index-C6MG_f24.js");
8
- const index$3 = require("./index-CBRFCYhV.js");
8
+ const index$3 = require("./index-CMLDQbgR.js");
9
9
  const icons = require("@chakra-ui/icons");
10
10
  require("react");
11
11
  require("react-medium-image-zoom");
12
- const index$1 = require("./index-CVv755RW.js");
12
+ const index$1 = require("./index-CuIVcnIS.js");
13
13
  const index$4 = require("./index-ov4J7p3D.js");
14
14
  const FacebookIcon = (props) => {
15
15
  return /* @__PURE__ */ jsxRuntime.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", "aria-label": "Facebook", ...props, children: [
@@ -173,9 +173,8 @@ const LinkButton = ({
173
173
  );
174
174
  };
175
175
  const Logo = () => {
176
- const { metadata } = index.useSiteContext();
177
- const { logo } = metadata;
178
- return /* @__PURE__ */ jsxRuntime.jsx(react.Box, { display: "flex", h: { base: 10, md: 14 }, alignSelf: "center", overflow: "hidden", children: /* @__PURE__ */ jsxRuntime.jsx(index.Image, { src: logo, alt: "Logo", objectFit: "contain" }) });
176
+ const { logo } = index.useSiteContext();
177
+ return /* @__PURE__ */ jsxRuntime.jsx(react.Box, { display: "flex", h: { base: 10, md: 14 }, alignSelf: "center", overflow: "hidden", children: /* @__PURE__ */ jsxRuntime.jsx(index.Image, { src: logo.src, alt: logo.alt, objectFit: "contain" }) });
179
178
  };
180
179
  const StarSizeMap = {
181
180
  sm: "1rem",
@@ -7,10 +7,10 @@ const gatsby = require("gatsby");
7
7
  require("@mdx-js/react");
8
8
  require("react-i18next");
9
9
  require("./index-C6MG_f24.js");
10
- require("./index-CBRFCYhV.js");
10
+ require("./index-CMLDQbgR.js");
11
11
  require("@chakra-ui/icons");
12
12
  const index = require("./index-ma-iV7GU.js");
13
- const index$1 = require("./index-C3n63_nP.js");
13
+ const index$1 = require("./index-CAjUjAgI.js");
14
14
  const SiteContext = react.createContext(null);
15
15
  const SiteProvider = ({ children, ...context }) => {
16
16
  const value = react.useMemo(() => context, []);
@@ -0,0 +1,198 @@
1
+ import { i as isRelativePath } from "./index-CQC6DRGf.mjs";
2
+ import { c as isStrapiPageContext, b as isStrapiPageData, i as isStrapiContent, a as isStrapiRichText } from "./index-CoNbTY7l.mjs";
3
+ const DUMMY_PAGE_TYPE = "DUMMY";
4
+ const NavigationSlug = {
5
+ HEADER: "header-navigation",
6
+ FOOTER: "footer-navigation"
7
+ };
8
+ function isValidPath(value) {
9
+ return typeof value === "string" && (value === "" || isRelativePath(value));
10
+ }
11
+ function isValidType(value) {
12
+ return typeof value === "string" && value.toUpperCase() !== DUMMY_PAGE_TYPE;
13
+ }
14
+ function isValidTitle(value) {
15
+ return typeof value === "string" && value.toUpperCase() !== DUMMY_PAGE_TYPE;
16
+ }
17
+ function transformNavItems(items) {
18
+ if (!items || !items.length) {
19
+ return [];
20
+ }
21
+ const transformed = [];
22
+ items.forEach((item) => {
23
+ var _a;
24
+ if (item && isValidTitle(item.title) && isValidType(item.type) && isValidPath(item.path)) {
25
+ const isNavGroup = (_a = item.items) == null ? void 0 : _a.length;
26
+ transformed.push({
27
+ label: item.title,
28
+ slug: isNavGroup ? "" : item.path.slice(1),
29
+ ...isNavGroup && { children: transformNavItems(item.items) }
30
+ });
31
+ }
32
+ });
33
+ return transformed;
34
+ }
35
+ function transformSiteNavigation(strapiNavigation) {
36
+ const siteNavigation = {
37
+ header: {},
38
+ footer: {}
39
+ };
40
+ if (!strapiNavigation) {
41
+ return siteNavigation;
42
+ }
43
+ const groups = strapiNavigation.items;
44
+ for (const group of groups ?? []) {
45
+ const { slug, locale, items } = group ?? {};
46
+ if (locale && slug === NavigationSlug.HEADER) {
47
+ siteNavigation.header[locale] = transformNavItems(items ?? []);
48
+ }
49
+ if (locale && slug === NavigationSlug.FOOTER) {
50
+ siteNavigation.footer[locale] = transformNavItems(items ?? []);
51
+ }
52
+ }
53
+ return siteNavigation;
54
+ }
55
+ function getNavigation(fallback, strapiNavigation) {
56
+ const siteNavigation = {
57
+ header: fallback.header,
58
+ footer: fallback.footer
59
+ };
60
+ if (!strapiNavigation) {
61
+ return siteNavigation;
62
+ }
63
+ const navigation = transformSiteNavigation(strapiNavigation);
64
+ siteNavigation.header = { ...siteNavigation.header, ...navigation.header };
65
+ siteNavigation.footer = { ...siteNavigation.footer, ...navigation.footer };
66
+ return siteNavigation;
67
+ }
68
+ function extractAuthor(author) {
69
+ if (author == null ? void 0 : author.name) {
70
+ return { name: author.name };
71
+ }
72
+ return null;
73
+ }
74
+ function extractGame(content) {
75
+ var _a, _b;
76
+ if (content) {
77
+ const gameInfo = content.find(
78
+ (component) => (component == null ? void 0 : component.__typename) === "STRAPI__COMPONENT_CONTENT_GAME_INFO"
79
+ );
80
+ const gameDemo = content.find(
81
+ (component) => (component == null ? void 0 : component.__typename) === "STRAPI__COMPONENT_CONTENT_GAME_DEMO"
82
+ );
83
+ const name = (gameDemo == null ? void 0 : gameDemo.name) ?? ((_a = gameInfo == null ? void 0 : gameInfo.general) == null ? void 0 : _a.NAME);
84
+ const genre = (_b = gameInfo == null ? void 0 : gameInfo.general) == null ? void 0 : _b.TYPE;
85
+ if (name) {
86
+ return {
87
+ name,
88
+ ...genre ? { genre } : {}
89
+ };
90
+ }
91
+ }
92
+ return null;
93
+ }
94
+ function parseReviewHeading(content) {
95
+ try {
96
+ const firstComponent = content ? content[0] : null;
97
+ const firstRichText = isStrapiRichText(firstComponent) ? firstComponent.data.content : null;
98
+ if (!firstRichText) {
99
+ return null;
100
+ }
101
+ const [firstText, secondText = ""] = firstRichText.split("\n");
102
+ return {
103
+ title: firstText.startsWith("#") ? firstText.slice(1).trim() : firstText.trim(),
104
+ description: secondText.trim()
105
+ };
106
+ } catch (_) {
107
+ return null;
108
+ }
109
+ }
110
+ function extractReview(content, seo, createdAt, updatedAt) {
111
+ if (content) {
112
+ const articleInfo = content.find(
113
+ (component) => (component == null ? void 0 : component.__typename) === "STRAPI__COMPONENT_CONTENT_ARTICLE_INFO"
114
+ );
115
+ const maybeHeading = parseReviewHeading(content);
116
+ const title = (articleInfo == null ? void 0 : articleInfo.title) || (maybeHeading == null ? void 0 : maybeHeading.title) || (seo == null ? void 0 : seo.metaTitle);
117
+ const description = (articleInfo == null ? void 0 : articleInfo.description) || (maybeHeading == null ? void 0 : maybeHeading.description) || (seo == null ? void 0 : seo.metaDescription);
118
+ if (title && description && createdAt)
119
+ return {
120
+ title,
121
+ description,
122
+ publishedAt: createdAt,
123
+ updatedAt: updatedAt || createdAt
124
+ };
125
+ }
126
+ return null;
127
+ }
128
+ function extractSeoData(pageData, pageContext) {
129
+ const result = {
130
+ locale: null,
131
+ meta: { title: null, description: null },
132
+ canonicalUrl: null,
133
+ hrefLangs: [],
134
+ structuredData: null
135
+ };
136
+ if (isStrapiPageContext(pageContext)) {
137
+ result.hrefLangs = pageContext.hrefLangs ?? [];
138
+ }
139
+ if (isStrapiPageData(pageData)) {
140
+ const { locale, seo, canonicalUrl, author, content, createdAt, updatedAt } = pageData ?? {};
141
+ const { metaTitle, metaDescription } = seo ?? {};
142
+ result.locale = locale ?? null;
143
+ result.canonicalUrl = canonicalUrl ?? null;
144
+ result.meta = { title: metaTitle ?? null, description: metaDescription ?? null };
145
+ const structuredDataContent = {};
146
+ if (isStrapiContent(content)) {
147
+ const review = extractReview(content, seo ?? null, createdAt ?? null, updatedAt ?? null);
148
+ const game = extractGame(content);
149
+ if (review && game) {
150
+ structuredDataContent.review = review;
151
+ structuredDataContent.game = game;
152
+ const reviewAuthor = extractAuthor(author ?? null);
153
+ if (reviewAuthor) {
154
+ structuredDataContent.author = reviewAuthor;
155
+ }
156
+ }
157
+ }
158
+ result.structuredData = structuredDataContent ? {
159
+ format: "json-ld",
160
+ entity: "game-review",
161
+ content: structuredDataContent
162
+ } : null;
163
+ }
164
+ return result;
165
+ }
166
+ function getSiteName(url) {
167
+ if (!url) {
168
+ return "";
169
+ }
170
+ return url.replace(/^https?:\/\//, "");
171
+ }
172
+ function getLocale(defaultLocaleCode, locales) {
173
+ let locale = { code: "en", name: "Default" };
174
+ if (defaultLocaleCode && (locales == null ? void 0 : locales.length)) {
175
+ const foundLocale = locales.find(({ code }) => code === defaultLocaleCode);
176
+ if (foundLocale) {
177
+ locale = foundLocale;
178
+ }
179
+ }
180
+ return locale;
181
+ }
182
+ function getLocales(defaultLocaleCode, locales) {
183
+ if (!locales) {
184
+ return [];
185
+ }
186
+ return [...locales].sort((a, b) => {
187
+ if (a.code === defaultLocaleCode) return -1;
188
+ if (b.code === defaultLocaleCode) return 1;
189
+ return 0;
190
+ });
191
+ }
192
+ export {
193
+ getLocale as a,
194
+ getLocales as b,
195
+ getNavigation as c,
196
+ extractSeoData as e,
197
+ getSiteName as g
198
+ };