Skip to content

Commit 0d35fb1

Browse files
author
Vivek Vishal
authored
Update gatsby-node.js
Signed-off-by: Vivek Vishal <vishalvivek488@gmail.com>
1 parent f277e2b commit 0d35fb1

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

gatsby-node.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
const path = require("path");
9+
const fs = require("fs");
910
const slugify = require("./src/utils/slugify");
1011
const { paginate } = require("gatsby-awesome-pagination");
1112
const { createFilePath } = require("gatsby-source-filesystem");
@@ -793,20 +794,26 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
793794
{ suffix: "", file: "index.js" },
794795
{ suffix: "/guidance", file: "guidance.js" },
795796
{ suffix: "/code", file: "code.js" },
797+
798+
796799
];
797800

798801
components.forEach((name) => {
799802
pageTypes.forEach(({ suffix, file }) => {
800-
const path = `/projects/sistent/components/${name}${suffix}`;
803+
const pagePath = `/projects/sistent/components/${name}${suffix}`;
801804
const componentPath = `./src/sections/Projects/Sistent/components/${name}/${file}`;
805+
if (fs.existsSync(path.resolve(componentPath))) {
802806
try {
803807
createPage({
804-
path,
808+
path: pagePath,
805809
component: require.resolve(componentPath),
806810
});
807811
} catch (error) {
808-
console.error(`Error creating page for ${path}:`, error);
809-
}
812+
console.error(`Error creating page for "${pagePath}":`, error);
813+
}
814+
} else {
815+
console.warn(`Skipping creating page "${pagePath}" - file not found: "${componentPath}"`);
816+
}
810817
});
811818
});
812819
};
@@ -1101,7 +1108,7 @@ exports.createSchemaCustomization = ({ actions }) => {
11011108
createTypes(typeDefs);
11021109
};
11031110

1104-
const fs = require("fs");
1111+
11051112

11061113
exports.onPostBuild = async ({ graphql, reporter }) => {
11071114
const result = await graphql(`

0 commit comments

Comments
 (0)