Skip to content

Commit db96801

Browse files
removed hardcoded cases and implemented a new logic that create pages that exists
Signed-off-by: Rajesh-Nagarajan-11 <rajeshnagarajan36@gmail.com>
1 parent 4a040eb commit db96801

1 file changed

Lines changed: 15 additions & 29 deletions

File tree

gatsby-node.js

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -802,39 +802,25 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
802802
{ suffix: "/code", file: "code.js" },
803803
];
804804

805+
// Process each component
805806
components.forEach((name) => {
806-
// Skip guidance and code pages for icons component
807-
if (name === "icons") {
808-
const pagePath = `/projects/sistent/components/${name}`;
809-
const componentPath = `./src/sections/Projects/Sistent/components/${name}/index.js`;
810-
if (fs.existsSync(path.resolve(componentPath))) {
811-
try {
812-
createPage({
813-
path: pagePath,
814-
component: require.resolve(componentPath),
815-
});
816-
} catch (error) {
817-
console.error(`Error creating page for "${pagePath}":`, error);
818-
}
819-
}
820-
return;
821-
}
807+
// First check which file types exist for this component
808+
const availableFiles = pageTypes.filter(({ file }) => {
809+
const componentPath = `./src/sections/Projects/Sistent/components/${name}/${file}`;
810+
return fs.existsSync(path.resolve(componentPath));
811+
});
822812

823-
// For all other components, process all page types
824-
pageTypes.forEach(({ suffix, file }) => {
813+
// Only create pages for files that actually exist
814+
availableFiles.forEach(({ suffix, file }) => {
825815
const pagePath = `/projects/sistent/components/${name}${suffix}`;
826816
const componentPath = `./src/sections/Projects/Sistent/components/${name}/${file}`;
827-
if (fs.existsSync(path.resolve(componentPath))) {
828-
try {
829-
createPage({
830-
path: pagePath,
831-
component: require.resolve(componentPath),
832-
});
833-
} catch (error) {
834-
console.error(`Error creating page for "${pagePath}":`, error);
835-
}
836-
} else {
837-
console.info(`Skipping creating page "${pagePath}" - file not found: "${componentPath}"`);
817+
try {
818+
createPage({
819+
path: pagePath,
820+
component: require.resolve(componentPath),
821+
});
822+
} catch (error) {
823+
console.error(`Error creating page for "${pagePath}":`, error);
838824
}
839825
});
840826
});

0 commit comments

Comments
 (0)