Skip to content

Commit 89a2c99

Browse files
committed
Consolidate gatsby-source-filesystem configuration and streamline source logic in gatsby-node.js
Signed-off-by: Lee Calcote <lee.calcote@layer5.io>
1 parent 1abfd78 commit 89a2c99

2 files changed

Lines changed: 18 additions & 92 deletions

File tree

gatsby-config.js

Lines changed: 6 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -477,85 +477,22 @@ module.exports = {
477477
{
478478
resolve: "gatsby-source-filesystem",
479479
options: {
480-
name: "images",
481-
path: `${__dirname}/src/assets/images`,
482-
},
483-
},
484-
{
485-
resolve: "gatsby-source-filesystem",
486-
options: {
487-
path: `${__dirname}/src/collections/blog`,
488-
name: "blog",
489-
},
490-
},
491-
{
492-
resolve: "gatsby-source-filesystem",
493-
options: {
494-
path: `${__dirname}/src/collections/news`,
495-
name: "news",
496-
},
497-
},
498-
{
499-
resolve: "gatsby-source-filesystem",
500-
options: {
501-
path: `${__dirname}/src/collections/projects`,
502-
name: "projects",
503-
},
504-
},
505-
{
506-
resolve: "gatsby-source-filesystem",
507-
options: {
508-
path: `${__dirname}/src/collections/service-mesh-books`,
509-
name: "service-mesh-books",
510-
},
511-
},
512-
{
513-
resolve: "gatsby-source-filesystem",
514-
options: {
515-
path: `${__dirname}/src/collections/programs`,
516-
name: "programs",
517-
},
518-
},
519-
{
520-
resolve: "gatsby-source-filesystem",
521-
options: {
522-
path: `${__dirname}/src/collections/careers`,
523-
name: "careers",
524-
},
525-
},
526-
{
527-
resolve: "gatsby-source-filesystem",
528-
options: {
529-
path: `${__dirname}/src/collections/members`,
530-
name: "members",
480+
path: `${__dirname}/src/collections`,
481+
name: "collections",
531482
},
532483
},
533484
{
534485
resolve: "gatsby-source-filesystem",
535486
options: {
536-
path: `${__dirname}/src/collections/workshops`,
537-
name: "workshops",
538-
},
539-
},
540-
{
541-
resolve: "gatsby-source-filesystem",
542-
options: {
543-
path: `${__dirname}/src/collections/kanvas-labs`,
544-
name: "kanvas-labs",
545-
},
546-
},
547-
{
548-
resolve: "gatsby-source-filesystem",
549-
options: {
550-
path: `${__dirname}/src/collections/resources`,
551-
name: "resources",
487+
path: `${__dirname}/src/sections/Meshery/Meshery-platforms/supported-icons`,
488+
name: "integration-images",
552489
},
553490
},
554491
{
555492
resolve: "gatsby-source-filesystem",
556493
options: {
557-
path: `${__dirname}/src/collections/events`,
558-
name: "events",
494+
name: "images",
495+
path: `${__dirname}/src/assets/images`,
559496
},
560497
},
561498
{
@@ -565,27 +502,6 @@ module.exports = {
565502
name: "content-learn",
566503
},
567504
},
568-
{
569-
resolve: "gatsby-source-filesystem",
570-
options: {
571-
path: `${__dirname}/src/collections/integrations`,
572-
name: "integrations",
573-
},
574-
},
575-
{
576-
resolve: "gatsby-source-filesystem",
577-
options: {
578-
path: `${__dirname}/src/collections/use-cases`,
579-
name: "use-cases",
580-
},
581-
},
582-
{
583-
resolve: "gatsby-source-filesystem",
584-
options: {
585-
name: "integration-images",
586-
path: `${__dirname}/src/sections/Meshery/Meshery-platforms/supported-icons`,
587-
},
588-
},
589505
"gatsby-plugin-image",
590506
{
591507
resolve: "gatsby-plugin-sharp",

gatsby-node.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,17 @@ exports.onCreateNode = ({ node, actions, getNode }) => {
552552
}
553553

554554
const { createNodeField } = actions;
555-
const collection = getNode(node.parent).sourceInstanceName;
555+
const parent = getNode(node.parent);
556+
let collection = parent.sourceInstanceName;
557+
558+
// --- CHANGED: Consolidated Source Logic ---
559+
// If the source is "collections", we determine the actual collection
560+
// from the parent directory name (e.g., "blog", "news", etc.)
561+
if (collection === "collections") {
562+
collection = parent.relativeDirectory.split("/")[0];
563+
}
564+
// ------------------------------------------
565+
556566
createNodeField({
557567
name: "collection",
558568
node,
@@ -790,4 +800,4 @@ exports.onPostBuild = async ({ graphql, reporter }) => {
790800
// Optionally, write the result to a file for easier inspection
791801
const outputPath = path.resolve(__dirname, "public", "query-result.json");
792802
fs.writeFileSync(outputPath, JSON.stringify(result, null, 2));
793-
};
803+
};

0 commit comments

Comments
 (0)