|
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"); |
@@ -797,15 +798,19 @@ exports.createPages = async ({ actions, graphql, reporter }) => { |
797 | 798 |
|
798 | 799 | components.forEach((name) => { |
799 | 800 | pageTypes.forEach(({ suffix, file }) => { |
800 | | - const path = `/projects/sistent/components/${name}${suffix}`; |
| 801 | + const pagePath = `/projects/sistent/components/${name}${suffix}`; |
801 | 802 | const componentPath = `./src/sections/Projects/Sistent/components/${name}/${file}`; |
802 | | - try { |
803 | | - createPage({ |
804 | | - path, |
805 | | - component: require.resolve(componentPath), |
806 | | - }); |
807 | | - } catch (error) { |
808 | | - console.error(`Error creating page for ${path}:`, error); |
| 803 | + if (fs.existsSync(path.resolve(componentPath))) { |
| 804 | + try { |
| 805 | + createPage({ |
| 806 | + path: pagePath, |
| 807 | + component: require.resolve(componentPath), |
| 808 | + }); |
| 809 | + } catch (error) { |
| 810 | + console.error(`Error creating page for "${pagePath}":`, error); |
| 811 | + } |
| 812 | + } else { |
| 813 | + console.info(`Skipping creating page "${pagePath}" - file not found: "${componentPath}"`); |
809 | 814 | } |
810 | 815 | }); |
811 | 816 | }); |
@@ -1101,7 +1106,7 @@ exports.createSchemaCustomization = ({ actions }) => { |
1101 | 1106 | createTypes(typeDefs); |
1102 | 1107 | }; |
1103 | 1108 |
|
1104 | | -const fs = require("fs"); |
| 1109 | + |
1105 | 1110 |
|
1106 | 1111 | exports.onPostBuild = async ({ graphql, reporter }) => { |
1107 | 1112 | const result = await graphql(` |
|
0 commit comments