@anywayseo/gatsby-plugin 2.6.0 → 2.7.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.
package/gatsby-node.js CHANGED
@@ -43,12 +43,12 @@ function createSchemaCustomization(args) {
43
43
  function sourceNodes(args, options) {
44
44
  return __awaiter(this, void 0, void 0, function* () {
45
45
  const { reporter } = args;
46
- const { strapiApiUrl, strapiAccessToken, pageSize, skipFileDownloads = false } = options;
46
+ const { strapiApiUrl, strapiAccessToken, pageSize, skipFileDownloads = false, retryNumber, retryDelay } = options;
47
47
  if (source === 'local') {
48
48
  reporter.warn('Local source mode enabled. Skipping Strapi source nodes.');
49
49
  }
50
50
  else {
51
- const strapiClient = new strapi_source_1.StrapiClient(strapiApiUrl, strapiAccessToken);
51
+ const strapiClient = new strapi_source_1.StrapiClient(reporter, strapiApiUrl, strapiAccessToken, retryNumber, retryDelay);
52
52
  yield (0, strapi_source_1.sourceStrapiContentNode)(args, strapiClient, { pageSize, skipFileDownloads });
53
53
  yield (0, strapi_source_1.sourceStrapiNavigationNode)(args, strapiClient);
54
54
  yield (0, strapi_source_1.sourceStrapiLocalizationNode)(args, strapiClient);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@anywayseo/gatsby-plugin",
3
3
  "description": "Shared config for Anywayseo sites",
4
- "version": "2.6.0",
4
+ "version": "2.7.0",
5
5
  "author": "zerg41",
6
6
  "license": "MIT",
7
7
  "publishConfig": {
package/types/index.d.ts CHANGED
@@ -4,6 +4,8 @@ export interface IPluginOptions extends IPluginRefOptions {
4
4
  source: string;
5
5
  strapiApiUrl?: string;
6
6
  strapiAccessToken?: string;
7
+ retryNumber?: number;
8
+ retryDelay?: number;
7
9
  pageSize?: number;
8
10
  skipFileDownloads?: boolean;
9
11
  }
@@ -52,7 +52,7 @@ function createMdxPages(_a, root_1) {
52
52
  const slug = frontmatter === null || frontmatter === void 0 ? void 0 : frontmatter.slug;
53
53
  const contentFilePath = internal.contentFilePath;
54
54
  if (slug && contentFilePath) {
55
- const existingPage = strapiPages.find((strapiPage) => (0, slug_1.normalizeSlug)(strapiPage === null || strapiPage === void 0 ? void 0 : strapiPage.slug) === (0, slug_1.normalizeSlug)(slug));
55
+ const existingPage = strapiPages.find((strapiPage) => (0, slug_1.isEqualSlug)(strapiPage === null || strapiPage === void 0 ? void 0 : strapiPage.slug, slug));
56
56
  if (!!existingPage) {
57
57
  reporter.warn(`Skipping MDX page creation: "${slug}" already exists`);
58
58
  return;
@@ -60,7 +60,7 @@ function createMdxPages(_a, root_1) {
60
60
  const mdxPageTemplate = (0, path_1.resolve)(root, `./src/templates/mdx-page.jsx`);
61
61
  const component = `${mdxPageTemplate}?__contentFilePath=${contentFilePath}`;
62
62
  actions.createPage({
63
- path: `/${(0, slug_1.normalizeSlug)(slug)}`,
63
+ path: (0, slug_1.buildPath)(slug),
64
64
  component,
65
65
  context: { slug },
66
66
  });
@@ -1,2 +1,4 @@
1
- export declare const DUMMY_PAGE_SLUG = "dummy";
2
- export declare function normalizeSlug(slug?: string | null): string;
1
+ export declare function buildPath(slug?: string | null, locale?: string | null, defaultLocale?: string | null): string;
2
+ export declare function isEqualSlug(a?: string | null, b?: string | null): boolean;
3
+ export declare function isEmptyPage(title?: string | null, slug?: string | null): boolean;
4
+ export declare function isDummyPage(slug?: string | null): boolean;
@@ -1,8 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DUMMY_PAGE_SLUG = void 0;
4
- exports.normalizeSlug = normalizeSlug;
5
- exports.DUMMY_PAGE_SLUG = 'dummy';
3
+ exports.buildPath = buildPath;
4
+ exports.isEqualSlug = isEqualSlug;
5
+ exports.isEmptyPage = isEmptyPage;
6
+ exports.isDummyPage = isDummyPage;
7
+ const INDEX_PAGE_SLUG = 'index';
8
+ const DUMMY_PAGE_SLUG = 'dummy';
6
9
  function normalizeSlug(slug) {
7
- return slug && slug !== 'index' ? slug : '';
10
+ if (!slug || slug === INDEX_PAGE_SLUG) {
11
+ return '';
12
+ }
13
+ return slug.toLowerCase();
14
+ }
15
+ function normalizeLocale(locale) {
16
+ return (locale !== null && locale !== void 0 ? locale : '').toLowerCase();
17
+ }
18
+ function buildPath(slug, locale, defaultLocale) {
19
+ const normalizedLocale = normalizeLocale(locale);
20
+ const normalizedDefaultLocale = normalizeLocale(defaultLocale);
21
+ const localePrefix = normalizedLocale === normalizedDefaultLocale ? '/' : `/${normalizedLocale}/`;
22
+ return `${localePrefix}${normalizeSlug(slug)}`;
23
+ }
24
+ function isEqualSlug(a, b) {
25
+ return normalizeSlug(a) === normalizeSlug(b);
26
+ }
27
+ function isEmptyPage(title, slug) {
28
+ return !title && !slug;
29
+ }
30
+ function isDummyPage(slug) {
31
+ return normalizeSlug(slug) === DUMMY_PAGE_SLUG;
8
32
  }
@@ -44,17 +44,17 @@ function createStrapiPages(_a, root_1) {
44
44
  reporter.info(`Found ${strapiPages.length} Strapi pages`);
45
45
  let pageCount = 0;
46
46
  strapiPages.forEach(({ id, slug, title, locale }) => {
47
- if (slug === slug_1.DUMMY_PAGE_SLUG) {
47
+ if ((0, slug_1.isDummyPage)(slug)) {
48
48
  reporter.warn('Skipping page creation: dummy page detected');
49
49
  return;
50
50
  }
51
- if (!title && !slug) {
51
+ if ((0, slug_1.isEmptyPage)(title, slug)) {
52
52
  reporter.warn('Skipping page creation: empty page detected');
53
53
  return;
54
54
  }
55
55
  const strapiPageTemplate = (0, path_1.resolve)(root, `./src/templates/strapi-page.tsx`);
56
56
  actions.createPage({
57
- path: `/${locale === defaultLocale ? '' : locale + '/'}${(0, slug_1.normalizeSlug)(slug)}`,
57
+ path: (0, slug_1.buildPath)(slug, locale, defaultLocale),
58
58
  component: strapiPageTemplate,
59
59
  context: { id },
60
60
  });
@@ -0,0 +1 @@
1
+ export declare const partner = "\n # === PARTNER DEFINITION ===\n type Partner {\n name: String!\n refLink: String\n }\n ";
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.partner = void 0;
4
+ exports.partner = `
5
+ # === PARTNER DEFINITION ===
6
+ type Partner {
7
+ name: String!
8
+ refLink: String
9
+ }
10
+ `;
@@ -1 +1 @@
1
- export declare const content = "\n # === COMPONENT DEFINITIONS ===\n union ContentComponent =\n STRAPI__COMPONENT_CONTENT_CONTACTS_PAGE\n | STRAPI__COMPONENT_CONTENT_COOKIE_POLICY_PAGE \n | STRAPI__COMPONENT_CONTENT_FAQ\n | STRAPI__COMPONENT_CONTENT_FEATURES\n | STRAPI__COMPONENT_CONTENT_GAME_CARDS\n | STRAPI__COMPONENT_CONTENT_GAME_CARD_TABS\n | STRAPI__COMPONENT_CONTENT_GAME_DEMO\n | STRAPI__COMPONENT_CONTENT_GAME_INFO\n | STRAPI__COMPONENT_CONTENT_HOW_TO\n | STRAPI__COMPONENT_CONTENT_LIST\n | STRAPI__COMPONENT_CONTENT_MEDIA\n | STRAPI__COMPONENT_CONTENT_PRIVACY_POLICY_PAGE\n | STRAPI__COMPONENT_CONTENT_PROS_CONS\n | STRAPI__COMPONENT_CONTENT_RICH_TEXT\n | STRAPI__COMPONENT_CONTENT_TABLE\n | STRAPI__COMPONENT_CONTENT_TERMS_CONDITIONS_PAGE\n | STRAPI__COMPONENT_CONTENT_TIP\n\n # === CONTACTS ===\n type STRAPI__COMPONENT_CONTENT_CONTACTS_PAGE @dontInfer {\n id: ID\n }\n\n # === COOKIE_POLICY ===\n type STRAPI__COMPONENT_CONTENT_COOKIE_POLICY_PAGE @dontInfer {\n id: ID\n }\n\n # === FAQ ===\n type STRAPI__COMPONENT_CONTENT_FAQ @dontInfer {\n items: [FaqItem!]\n }\n\n # === FEATURES ===\n type STRAPI__COMPONENT_CONTENT_FEATURES @dontInfer {\n items: [FeaturesItem!]\n }\n\n # === GAME CARDS ===\n type STRAPI__COMPONENT_CONTENT_GAME_CARDS @dontInfer {\n items: [GameCard!]\n order: String!\n randomSeed: Int\n cardHeight: String\n }\n\n # === GAME CARD TABS ===\n type STRAPI__COMPONENT_CONTENT_GAME_CARD_TABS @dontInfer {\n items: [GameCardTab!]\n }\n\n # === GAME_DEMO ===\n type STRAPI__COMPONENT_CONTENT_GAME_DEMO @dontInfer {\n name: String!\n src: String!\n href: String\n previewImage: Image!\n }\n\n # === GAME_INFO ===\n type STRAPI__COMPONENT_CONTENT_GAME_INFO @dontInfer {\n general: GameInfoGeneral\n features: GameInfoFeatures\n currency: CurrencyList\n }\n\n # === HOW_TO ===\n type STRAPI__COMPONENT_CONTENT_HOW_TO @dontInfer {\n steps: [HowToStep!]\n }\n\n # === LIST ===\n type STRAPI__COMPONENT_CONTENT_LIST @dontInfer {\n bullet: String\n content: JsonValue\n }\n\n # === MEDIA ===\n type STRAPI__COMPONENT_CONTENT_MEDIA @dontInfer {\n file: Image\n }\n\n # === PRIVACY_POLICY ===\n type STRAPI__COMPONENT_CONTENT_PRIVACY_POLICY_PAGE @dontInfer {\n contactsSlug: String\n }\n\n # === PROS_CONS ===\n type STRAPI__COMPONENT_CONTENT_PROS_CONS @dontInfer {\n pros: [ProsConsItem!]\n cons: [ProsConsItem!]\n }\n\n # === RICH_TEXT ===\n type STRAPI__COMPONENT_CONTENT_RICH_TEXT @dontInfer {\n content: RichTextContent\n }\n\n # === TABLE ===\n type STRAPI__COMPONENT_CONTENT_TABLE @dontInfer {\n columnNumber: Int!\n content: JsonValue\n caption: String\n striped: Boolean\n bordered: Boolean\n scrollable: Boolean\n }\n\n # === TERMS_CONDITIONS ===\n type STRAPI__COMPONENT_CONTENT_TERMS_CONDITIONS_PAGE @dontInfer {\n privacyPolicySlug: String\n }\n\n # === TIP ===\n type STRAPI__COMPONENT_CONTENT_TIP @dontInfer {\n tip: String!\n author: Author\n }\n ";
1
+ export declare const content = "\n # === COMPONENT DEFINITIONS ===\n union ContentComponent =\n STRAPI__COMPONENT_CONTENT_ACTION_BUTTON\n | STRAPI__COMPONENT_CONTENT_CONTACTS_PAGE\n | STRAPI__COMPONENT_CONTENT_COOKIE_POLICY_PAGE \n | STRAPI__COMPONENT_CONTENT_FAQ\n | STRAPI__COMPONENT_CONTENT_FEATURES\n | STRAPI__COMPONENT_CONTENT_GAME_CARDS\n | STRAPI__COMPONENT_CONTENT_GAME_CARD_TABS\n | STRAPI__COMPONENT_CONTENT_GAME_DEMO\n | STRAPI__COMPONENT_CONTENT_GAME_INFO\n | STRAPI__COMPONENT_CONTENT_HOW_TO\n | STRAPI__COMPONENT_CONTENT_INFORMER\n | STRAPI__COMPONENT_CONTENT_LIST\n | STRAPI__COMPONENT_CONTENT_MEDIA\n | STRAPI__COMPONENT_CONTENT_PRIVACY_POLICY_PAGE\n | STRAPI__COMPONENT_CONTENT_PROS_CONS\n | STRAPI__COMPONENT_CONTENT_RICH_TEXT\n | STRAPI__COMPONENT_CONTENT_TABLE\n | STRAPI__COMPONENT_CONTENT_TERMS_CONDITIONS_PAGE\n | STRAPI__COMPONENT_CONTENT_TIP\n\n # === ACTION_BUTTON ===\n type STRAPI__COMPONENT_CONTENT_ACTION_BUTTON @dontInfer {\n label: String!\n url: String!\n }\n\n # === CONTACTS ===\n type STRAPI__COMPONENT_CONTENT_CONTACTS_PAGE @dontInfer {\n id: ID\n }\n\n # === COOKIE_POLICY ===\n type STRAPI__COMPONENT_CONTENT_COOKIE_POLICY_PAGE @dontInfer {\n id: ID\n }\n\n # === FAQ ===\n type STRAPI__COMPONENT_CONTENT_FAQ @dontInfer {\n items: [FaqItem!]\n }\n\n # === FEATURES ===\n type STRAPI__COMPONENT_CONTENT_FEATURES @dontInfer {\n items: [FeaturesItem!]\n }\n\n # === GAME CARDS ===\n type STRAPI__COMPONENT_CONTENT_GAME_CARDS @dontInfer {\n items: [GameCard!]\n order: String!\n randomSeed: Int\n cardHeight: String\n }\n\n # === GAME CARD TABS ===\n type STRAPI__COMPONENT_CONTENT_GAME_CARD_TABS @dontInfer {\n items: [GameCardTab!]\n }\n\n # === GAME_DEMO ===\n type STRAPI__COMPONENT_CONTENT_GAME_DEMO @dontInfer {\n name: String!\n src: String\n href: String\n previewImage: Image!\n partner: Partner\n }\n\n # === GAME_INFO ===\n type STRAPI__COMPONENT_CONTENT_GAME_INFO @dontInfer {\n general: GameInfoGeneral\n features: GameInfoFeatures\n currency: CurrencyList\n }\n\n # === INFORMER ===\n type STRAPI__COMPONENT_CONTENT_INFORMER @dontInfer {\n type: String!\n text: String!\n author: Author\n }\n\n # === HOW_TO ===\n type STRAPI__COMPONENT_CONTENT_HOW_TO @dontInfer {\n steps: [HowToStep!]\n }\n\n # === LIST ===\n type STRAPI__COMPONENT_CONTENT_LIST @dontInfer {\n bullet: String\n content: JsonValue\n }\n\n # === MEDIA ===\n type STRAPI__COMPONENT_CONTENT_MEDIA @dontInfer {\n file: Image\n }\n\n # === PRIVACY_POLICY ===\n type STRAPI__COMPONENT_CONTENT_PRIVACY_POLICY_PAGE @dontInfer {\n contactsSlug: String\n }\n\n # === PROS_CONS ===\n type STRAPI__COMPONENT_CONTENT_PROS_CONS @dontInfer {\n pros: [ProsConsItem!]\n cons: [ProsConsItem!]\n }\n\n # === RICH_TEXT ===\n type STRAPI__COMPONENT_CONTENT_RICH_TEXT @dontInfer {\n content: RichTextContent\n }\n\n # === TABLE ===\n type STRAPI__COMPONENT_CONTENT_TABLE @dontInfer {\n columnNumber: Int!\n content: JsonValue\n caption: String\n striped: Boolean\n bordered: Boolean\n scrollable: Boolean\n }\n\n # === TERMS_CONDITIONS ===\n type STRAPI__COMPONENT_CONTENT_TERMS_CONDITIONS_PAGE @dontInfer {\n privacyPolicySlug: String\n }\n\n # === TIP ===\n type STRAPI__COMPONENT_CONTENT_TIP @dontInfer {\n tip: String!\n author: Author\n }\n ";
@@ -4,7 +4,8 @@ exports.content = void 0;
4
4
  exports.content = `
5
5
  # === COMPONENT DEFINITIONS ===
6
6
  union ContentComponent =
7
- STRAPI__COMPONENT_CONTENT_CONTACTS_PAGE
7
+ STRAPI__COMPONENT_CONTENT_ACTION_BUTTON
8
+ | STRAPI__COMPONENT_CONTENT_CONTACTS_PAGE
8
9
  | STRAPI__COMPONENT_CONTENT_COOKIE_POLICY_PAGE
9
10
  | STRAPI__COMPONENT_CONTENT_FAQ
10
11
  | STRAPI__COMPONENT_CONTENT_FEATURES
@@ -13,6 +14,7 @@ exports.content = `
13
14
  | STRAPI__COMPONENT_CONTENT_GAME_DEMO
14
15
  | STRAPI__COMPONENT_CONTENT_GAME_INFO
15
16
  | STRAPI__COMPONENT_CONTENT_HOW_TO
17
+ | STRAPI__COMPONENT_CONTENT_INFORMER
16
18
  | STRAPI__COMPONENT_CONTENT_LIST
17
19
  | STRAPI__COMPONENT_CONTENT_MEDIA
18
20
  | STRAPI__COMPONENT_CONTENT_PRIVACY_POLICY_PAGE
@@ -22,6 +24,12 @@ exports.content = `
22
24
  | STRAPI__COMPONENT_CONTENT_TERMS_CONDITIONS_PAGE
23
25
  | STRAPI__COMPONENT_CONTENT_TIP
24
26
 
27
+ # === ACTION_BUTTON ===
28
+ type STRAPI__COMPONENT_CONTENT_ACTION_BUTTON @dontInfer {
29
+ label: String!
30
+ url: String!
31
+ }
32
+
25
33
  # === CONTACTS ===
26
34
  type STRAPI__COMPONENT_CONTENT_CONTACTS_PAGE @dontInfer {
27
35
  id: ID
@@ -58,9 +66,10 @@ exports.content = `
58
66
  # === GAME_DEMO ===
59
67
  type STRAPI__COMPONENT_CONTENT_GAME_DEMO @dontInfer {
60
68
  name: String!
61
- src: String!
69
+ src: String
62
70
  href: String
63
71
  previewImage: Image!
72
+ partner: Partner
64
73
  }
65
74
 
66
75
  # === GAME_INFO ===
@@ -70,6 +79,13 @@ exports.content = `
70
79
  currency: CurrencyList
71
80
  }
72
81
 
82
+ # === INFORMER ===
83
+ type STRAPI__COMPONENT_CONTENT_INFORMER @dontInfer {
84
+ type: String!
85
+ text: String!
86
+ author: Author
87
+ }
88
+
73
89
  # === HOW_TO ===
74
90
  type STRAPI__COMPONENT_CONTENT_HOW_TO @dontInfer {
75
91
  steps: [HowToStep!]
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.typeDefs = void 0;
4
4
  const author_1 = require("./collections/author");
5
5
  const page_1 = require("./collections/page");
6
+ const partner_1 = require("./collections/partner");
6
7
  const base_1 = require("./components/base");
7
8
  const content_1 = require("./components/content");
8
9
  const shared_1 = require("./components/shared");
@@ -10,4 +11,4 @@ const primitives_1 = require("./primitives");
10
11
  const localization_1 = require("./single/localization");
11
12
  const navigation_1 = require("./single/navigation");
12
13
  const site_1 = require("./single/site");
13
- exports.typeDefs = [author_1.author, page_1.page, base_1.base, content_1.content, shared_1.shared, primitives_1.primitives, localization_1.localization, navigation_1.navigation, site_1.site].join('\n');
14
+ exports.typeDefs = [author_1.author, page_1.page, partner_1.partner, base_1.base, content_1.content, shared_1.shared, primitives_1.primitives, localization_1.localization, navigation_1.navigation, site_1.site].join('\n');
@@ -1,7 +1,12 @@
1
+ import type { Reporter } from 'gatsby';
1
2
  export declare class StrapiClient {
3
+ private reporter;
2
4
  private apiUrl;
3
5
  private accessToken;
4
- constructor(apiUrl?: string, accessToken?: string);
6
+ private retries;
7
+ private delay;
8
+ constructor(reporter: Reporter, apiUrl?: string, accessToken?: string, retries?: number, delay?: number);
9
+ private fetchWithRetry;
5
10
  fetch<T = any>(path: string): Promise<T>;
6
11
  getApiUrl(): string;
7
12
  }
@@ -11,15 +11,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.StrapiClient = void 0;
13
13
  class StrapiClient {
14
- constructor(apiUrl, accessToken) {
14
+ constructor(reporter, apiUrl, accessToken, retries = 3, delay = 1000) {
15
15
  if (!apiUrl || !accessToken) {
16
16
  throw new Error('Missing STRAPI_API_URL or STRAPI_TOKEN in environment variables.');
17
17
  }
18
+ this.reporter = reporter;
18
19
  this.apiUrl = apiUrl;
19
20
  this.accessToken = accessToken;
21
+ this.retries = retries;
22
+ this.delay = delay;
20
23
  }
21
- fetch(path) {
22
- return __awaiter(this, void 0, void 0, function* () {
24
+ fetchWithRetry(path_1) {
25
+ return __awaiter(this, arguments, void 0, function* (path, retries = this.retries, delay = this.delay) {
23
26
  try {
24
27
  const result = yield fetch(`${this.apiUrl}/api/${path}`, {
25
28
  headers: {
@@ -33,10 +36,20 @@ class StrapiClient {
33
36
  return data;
34
37
  }
35
38
  catch (error) {
36
- throw new Error(`Error occurred while fetching ${path}: ${error}`);
39
+ if (retries > 0) {
40
+ this.reporter.warn(`Fetch failed for ${path}. Retrying in ${delay}ms... (${retries} retries left)`);
41
+ yield new Promise((res) => setTimeout(res, delay));
42
+ return this.fetchWithRetry(path, retries - 1, delay * 2); // exponential backoff
43
+ }
44
+ throw new Error(`Error fetching ${path}: ${error}`);
37
45
  }
38
46
  });
39
47
  }
48
+ fetch(path) {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ return this.fetchWithRetry(path, this.retries, this.delay);
51
+ });
52
+ }
40
53
  getApiUrl() {
41
54
  return this.apiUrl;
42
55
  }
@@ -52,6 +52,9 @@ function sourceStrapiContentNode(args, strapiClient, config) {
52
52
  },
53
53
  content: {
54
54
  on: {
55
+ 'content.action-button': {
56
+ populate: '*',
57
+ },
55
58
  'content.contacts-page': {
56
59
  populate: '*',
57
60
  },
@@ -109,6 +112,9 @@ function sourceStrapiContentNode(args, strapiClient, config) {
109
112
  },
110
113
  },
111
114
  },
115
+ 'content.informer': {
116
+ populate: '*',
117
+ },
112
118
  'content.list': {
113
119
  populate: '*',
114
120
  },