@anywayseo/tools 3.1.0 → 3.1.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.
@@ -204,25 +204,29 @@ function getValidSource(source) {
204
204
  console.warn('Invalid or missing GATSBY_SITE_SOURCE. Defaulting to "local".');
205
205
  return "local";
206
206
  }
207
+ const DUMMY_PAGE_TYPE = "DUMMY";
207
208
  function isValidPath(value) {
208
209
  return typeof value === "string" && (value === "" || value.startsWith("/"));
209
210
  }
211
+ function isValidType(value) {
212
+ return typeof value === "string" && value !== DUMMY_PAGE_TYPE;
213
+ }
210
214
  function transformNavItems(items, parentPath = "") {
211
215
  if (!items || !items.length) {
212
216
  return [];
213
217
  }
214
218
  const transformed = [];
215
- items.forEach(({ type, title, path: itemPath, items: itemItems }) => {
216
- if (type === "DUMMY" || !title || !isValidPath(itemPath)) {
217
- return;
218
- }
219
- let path = `${parentPath}${itemPath}`;
220
- let children = [];
221
- if (itemItems == null ? void 0 : itemItems.length) {
222
- path = "";
223
- children = transformNavItems(itemItems, path);
219
+ items.forEach((item) => {
220
+ var _a;
221
+ if (item && item.title && isValidType(item.type) && isValidPath(item.path)) {
222
+ let path = `${parentPath}${item.path}`;
223
+ let children = [];
224
+ if ((_a = item.items) == null ? void 0 : _a.length) {
225
+ path = "";
226
+ children = transformNavItems(item.items, path);
227
+ }
228
+ transformed.push({ label: item.title, path, children });
224
229
  }
225
- transformed.push({ label: title, path, children });
226
230
  });
227
231
  return transformed;
228
232
  }
@@ -205,25 +205,29 @@ function getValidSource(source) {
205
205
  console.warn('Invalid or missing GATSBY_SITE_SOURCE. Defaulting to "local".');
206
206
  return "local";
207
207
  }
208
+ const DUMMY_PAGE_TYPE = "DUMMY";
208
209
  function isValidPath(value) {
209
210
  return typeof value === "string" && (value === "" || value.startsWith("/"));
210
211
  }
212
+ function isValidType(value) {
213
+ return typeof value === "string" && value !== DUMMY_PAGE_TYPE;
214
+ }
211
215
  function transformNavItems(items, parentPath = "") {
212
216
  if (!items || !items.length) {
213
217
  return [];
214
218
  }
215
219
  const transformed = [];
216
- items.forEach(({ type, title, path: itemPath, items: itemItems }) => {
217
- if (type === "DUMMY" || !title || !isValidPath(itemPath)) {
218
- return;
219
- }
220
- let path = `${parentPath}${itemPath}`;
221
- let children = [];
222
- if (itemItems == null ? void 0 : itemItems.length) {
223
- path = "";
224
- children = transformNavItems(itemItems, path);
220
+ items.forEach((item) => {
221
+ var _a;
222
+ if (item && item.title && isValidType(item.type) && isValidPath(item.path)) {
223
+ let path = `${parentPath}${item.path}`;
224
+ let children = [];
225
+ if ((_a = item.items) == null ? void 0 : _a.length) {
226
+ path = "";
227
+ children = transformNavItems(item.items, path);
228
+ }
229
+ transformed.push({ label: item.title, path, children });
225
230
  }
226
- transformed.push({ label: title, path, children });
227
231
  });
228
232
  return transformed;
229
233
  }
package/dist/index.cjs CHANGED
@@ -6,7 +6,7 @@ const i18n$1 = require("./index-Biz1dDqA.js");
6
6
  const index$2 = require("./index-d3V0A4lN.js");
7
7
  const index$3 = require("./index-BhsXlbd8.js");
8
8
  const index$4 = require("./index-Cte2-g6s.js");
9
- const index$5 = require("./index-oKYQNMo-.js");
9
+ const index$5 = require("./index-D2JqGE4u.js");
10
10
  const i18n = require("i18next");
11
11
  exports.Author = index.Author;
12
12
  exports.AuthorCard = index.AuthorCard;
package/dist/index.mjs CHANGED
@@ -4,7 +4,7 @@ import { a as a2, G as G2, r } from "./index-DoBCANwf.mjs";
4
4
  import { M } from "./index-Bx3B21Dh.mjs";
5
5
  import { S as S2, u as u2 } from "./index-BNb-P8a6.mjs";
6
6
  import { A as A2, f as f2, b as b2, c as c2, a as a3, g as g2, p, r as r2, t } from "./index-25M8hPOF.mjs";
7
- import { e as e2, b as b3, g as g3, a as a4, t as t2 } from "./index-BOOm0MsP.mjs";
7
+ import { e as e2, b as b3, g as g3, a as a4, t as t2 } from "./index-CHnNtadm.mjs";
8
8
  import { default as default2 } from "i18next";
9
9
  export {
10
10
  A2 as Animation,
@@ -1,14 +1,16 @@
1
1
  export interface IStrapiNavigation {
2
+ readonly items: ReadonlyArray<IStrapiNavigationGroup | null> | null;
3
+ }
4
+ export interface IStrapiNavigationGroup {
2
5
  readonly name: string | null;
3
6
  readonly slug: string | null;
4
7
  readonly items: ReadonlyArray<IStrapiNavigationItem | null> | null;
5
8
  }
6
9
  export interface IStrapiNavigationItem {
7
- readonly id: number | null;
8
- readonly type: 'DUMMY' | 'WRAPPER' | 'INTERNAL' | 'EXTERNAL' | null;
10
+ readonly type: string | null;
9
11
  readonly title: string | null;
10
12
  readonly slug: string | null;
11
13
  readonly path: string | null;
12
14
  readonly menuAttached: boolean | null;
13
- readonly items: IStrapiNavigationItem[];
15
+ readonly items: ReadonlyArray<IStrapiNavigationItem | null> | null;
14
16
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const index = require("../index-Cte2-g6s.js");
4
- const index$1 = require("../index-oKYQNMo-.js");
4
+ const index$1 = require("../index-D2JqGE4u.js");
5
5
  exports.Animation = index.Animation;
6
6
  exports.formatDate = index.formatDate;
7
7
  exports.formatNumber = index.formatNumber;
@@ -1,5 +1,5 @@
1
1
  import { A, f, b, c, a, g, p, r, t } from "../index-25M8hPOF.mjs";
2
- import { e, b as b2, g as g2, a as a2, t as t2 } from "../index-BOOm0MsP.mjs";
2
+ import { e, b as b2, g as g2, a as a2, t as t2 } from "../index-CHnNtadm.mjs";
3
3
  export {
4
4
  A as Animation,
5
5
  e as extractTheme,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@anywayseo/tools",
3
3
  "description": "Shared UI Components and Modules",
4
- "version": "3.1.0",
4
+ "version": "3.1.1",
5
5
  "keywords": [
6
6
  "react",
7
7
  "ui",