|
6 | 6 | */ |
7 | 7 |
|
8 | 8 | const path = require("path"); |
| 9 | +const fs = require("fs"); |
9 | 10 | const slugify = require("./src/utils/slugify"); |
10 | 11 | const { paginate } = require("gatsby-awesome-pagination"); |
11 | 12 | const { createFilePath } = require("gatsby-source-filesystem"); |
@@ -793,20 +794,26 @@ exports.createPages = async ({ actions, graphql, reporter }) => { |
793 | 794 | { suffix: "", file: "index.js" }, |
794 | 795 | { suffix: "/guidance", file: "guidance.js" }, |
795 | 796 | { suffix: "/code", file: "code.js" }, |
| 797 | + |
| 798 | + |
796 | 799 | ]; |
797 | 800 |
|
798 | 801 | components.forEach((name) => { |
799 | 802 | pageTypes.forEach(({ suffix, file }) => { |
800 | | - const path = `/projects/sistent/components/${name}${suffix}`; |
| 803 | + const pagePath = `/projects/sistent/components/${name}${suffix}`; |
801 | 804 | const componentPath = `./src/sections/Projects/Sistent/components/${name}/${file}`; |
| 805 | + if (fs.existsSync(path.resolve(componentPath))) { |
802 | 806 | try { |
803 | 807 | createPage({ |
804 | | - path, |
| 808 | + path: pagePath, |
805 | 809 | component: require.resolve(componentPath), |
806 | 810 | }); |
807 | 811 | } 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 | + } |
810 | 817 | }); |
811 | 818 | }); |
812 | 819 | }; |
@@ -1101,7 +1108,7 @@ exports.createSchemaCustomization = ({ actions }) => { |
1101 | 1108 | createTypes(typeDefs); |
1102 | 1109 | }; |
1103 | 1110 |
|
1104 | | -const fs = require("fs"); |
| 1111 | + |
1105 | 1112 |
|
1106 | 1113 | exports.onPostBuild = async ({ graphql, reporter }) => { |
1107 | 1114 | const result = await graphql(` |
|
0 commit comments