gatsby-attainlabs-cms 1.0.33 → 1.0.35

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.
@@ -0,0 +1,28 @@
1
+ exports.onClientEntry = (_, pluginOptions) => {
2
+ const { brand } = pluginOptions;
3
+
4
+ if (brand === "LendDirect") {
5
+ import("@fontsource/open-sans/300.css");
6
+ import("@fontsource/open-sans/400.css");
7
+ import("@fontsource/open-sans/500.css");
8
+ import("@fontsource/open-sans/600.css");
9
+ import("@fontsource/open-sans/700.css");
10
+ import("@fontsource/open-sans/800.css");
11
+ import("slick-carousel/slick/slick.css");
12
+ import("slick-carousel/slick/slick-theme.css");
13
+ }
14
+ if (brand === "Heights Finance") {
15
+ import("@fontsource/montserrat/300.css");
16
+ import("@fontsource/montserrat/400.css");
17
+ import("@fontsource/montserrat/500.css");
18
+ import("@fontsource/montserrat/600.css");
19
+ import("@fontsource/montserrat/700.css");
20
+ import("@fontsource/montserrat/800.css");
21
+ import("@fontsource/montserrat/300-italic.css");
22
+ import("@fontsource/montserrat/400-italic.css");
23
+ import("@fontsource/montserrat/500-italic.css");
24
+ import("@fontsource/montserrat/600-italic.css");
25
+ import("@fontsource/montserrat/700-italic.css");
26
+ import("@fontsource/montserrat/800-italic.css");
27
+ }
28
+ };
package/gatsby-node.js CHANGED
@@ -4,6 +4,7 @@ const path = require("path");
4
4
  const prettier = require("prettier");
5
5
  const fse = require("fs-extra");
6
6
  const crypto = require("crypto");
7
+ const { graphql } = require("gatsby");
7
8
 
8
9
  const brands = {
9
10
  LendDirect: "lenddirect",
@@ -283,8 +284,16 @@ exports.sourceNodes = async (
283
284
  pluginOptions
284
285
  ) => {
285
286
  const { createNode } = actions;
286
- const { trustpilotApiKey, brand } = pluginOptions;
287
+ const { trustpilotApiKey, brand, environment } = pluginOptions;
287
288
  const apiKey = process.env.TRUSTPILOT_API_KEY || trustpilotApiKey;
289
+
290
+ if (environment === "dev") {
291
+ console.log(
292
+ "ℹ️ [gatsby-attainlabs-cms] Running in 'dev' environment mode. Skipping source node creation."
293
+ );
294
+ return;
295
+ }
296
+
288
297
  console.log(
289
298
  `ℹ️ [gatsby-attainlabs-cms] Fetching Trustpilot data for brand: ${brand}`
290
299
  );
@@ -428,7 +437,7 @@ exports.createPages = async ({ actions, store }, pluginOptions) => {
428
437
  const siteRoot = store.getState().program.directory;
429
438
  if (environment === "dev") {
430
439
  console.log(
431
- "ℹ️ [gatsby-attainlabs-cms] Running in 'dev' environment mode. Skipping component sync."
440
+ "ℹ️ [gatsby-attainlabs-cms] Running in 'dev' environment mode. Skipping page creation."
432
441
  );
433
442
  return;
434
443
  }
@@ -448,6 +457,79 @@ exports.createPages = async ({ actions, store }, pluginOptions) => {
448
457
  `https://attain-finance-cms-default-rtdb.firebaseio.com/cms/brands/${brands[brand]}/pages.json`
449
458
  );
450
459
 
460
+ const blogData = graphql(`
461
+ query {
462
+ allBlogs {
463
+ edges {
464
+ node {
465
+ blocks {
466
+ content {
467
+ props {
468
+ content {
469
+ props {
470
+ text
471
+ image {
472
+ desktop {
473
+ url
474
+ }
475
+ }
476
+ }
477
+ # type
478
+ }
479
+ }
480
+ }
481
+ root {
482
+ props {
483
+ author
484
+ datePublished
485
+ pageUrl
486
+ }
487
+ }
488
+ }
489
+ }
490
+ }
491
+ }
492
+ }
493
+ `);
494
+ const postsPerPage = 5;
495
+ const blogs = blogData.allBlogs.edges;
496
+ const numPages = Math.ceil(blogs.length / postsPerPage);
497
+
498
+ Array.from({ length: numPages }).forEach((_, i) => {
499
+ createPage({
500
+ path: i === 0 ? `/blogs/` : `/blogs/${i + 1}/`,
501
+ component: path.resolve(
502
+ path.join(siteRoot, "src/cms/pages", "index.tsx")
503
+ ),
504
+ // path.join(siteRoot, "src/cms/pages", `${folderPath}.tsx`);
505
+ context: {
506
+ limit: postsPerPage,
507
+ skip: i * postsPerPage,
508
+ numPages,
509
+ currentPage: i + 1,
510
+ },
511
+ });
512
+ });
513
+
514
+ // Create individual blog pages
515
+ // let count = 0;
516
+ // let page = 1;
517
+ // blogs.forEach(({ node }: any) => {
518
+ // count++;
519
+ // if (count > postsPerPage) {
520
+ // page++;
521
+ // count = 1;
522
+ // }
523
+ // createPage({
524
+ // path: `/blogs/${page > 1 ? `${page}/` : ""}${node.slug}/`,
525
+ // component: path.resolve("./src/templates/blogPage.tsx"),
526
+ // context: {
527
+ // ...node,
528
+ // page,
529
+ // },
530
+ // });
531
+ // });
532
+
451
533
  const firebaseJson = await firebaseData.json();
452
534
 
453
535
  async function processPage(page, parentPath = "") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-attainlabs-cms",
3
- "version": "1.0.33",
3
+ "version": "1.0.35",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,6 +15,8 @@
15
15
  "gatsby": "^5.0.0 || ^4.0.0"
16
16
  },
17
17
  "dependencies": {
18
+ "@fontsource/montserrat": "^5.2.8",
19
+ "@fontsource/open-sans": "^5.2.7",
18
20
  "dotenv": "^17.2.1",
19
21
  "gatsby-background-image": "^1.6.0",
20
22
  "gatsby-plugin-image": "^3.15.0",