Skip to content

Commit 7fe09be

Browse files
Merge branch 'master' into blog-images
2 parents 90a7cae + 0a52db8 commit 7fe09be

File tree

239 files changed

+18905
-25498
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

239 files changed

+18905
-25498
lines changed

gatsby-node.js

Lines changed: 62 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ const {
1515
getExcludedCollections,
1616
isFullSiteBuild,
1717
} = require("./src/utils/build-collections");
18-
const {
19-
componentsData,
20-
} = require("./src/sections/Projects/Sistent/components/content");
2118

2219
const shouldBuildFullSite = isFullSiteBuild();
2320
const excludedCollections = new Set(
@@ -358,6 +355,25 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
358355
}
359356
}
360357
}
358+
sistentComponents: allMdx(
359+
filter: {
360+
fields: { collection: { eq: "sistent" } }
361+
}
362+
) {
363+
group(field: { fields: { componentName: SELECT } }) {
364+
fieldValue
365+
nodes {
366+
fields {
367+
slug
368+
componentName
369+
pageType
370+
}
371+
internal {
372+
contentFilePath
373+
}
374+
}
375+
}
376+
}
361377
}
362378
`);
363379

@@ -712,39 +728,29 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
712728
}
713729
});
714730

715-
const components = componentsData.map((component) =>
716-
component.src.replace("/", ""),
717-
);
718-
const createComponentPages = (createPage, components) => {
719-
const pageTypes = [
720-
{ suffix: "", file: "index.js" },
721-
{ suffix: "/guidance", file: "guidance.js" },
722-
{ suffix: "/code", file: "code.js" },
723-
];
731+
// Create Sistent component pages dynamically from MDX
732+
// Use grouping to identify which sub-pages (Tabs) exist for each component
733+
const sistentGroups = res.data.sistentComponents.group;
734+
const sistentTemplate = path.resolve("src/templates/sistent-component.js");
724735

725-
components.forEach((name) => {
726-
pageTypes.forEach(({ suffix, file }) => {
727-
const pagePath = `/projects/sistent/components/${name}${suffix}`;
728-
const componentPath = `./src/sections/Projects/Sistent/components/${name}/${file}`;
729-
if (fs.existsSync(path.resolve(componentPath))) {
730-
try {
731-
createPage({
732-
path: pagePath,
733-
component: require.resolve(componentPath),
734-
});
735-
} catch (error) {
736-
console.error(`Error creating page for "${pagePath}":`, error);
737-
}
738-
} else {
739-
console.info(
740-
`Skipping creating page "${pagePath}" - file not found: "${componentPath}"`,
741-
);
742-
}
736+
sistentGroups.forEach((group) => {
737+
const componentName = group.fieldValue;
738+
// content-learn uses different fields, sistent uses componentName.
739+
740+
const availablePages = group.nodes.map((node) => node.fields.pageType);
741+
742+
group.nodes.forEach((node) => {
743+
createPage({
744+
path: node.fields.slug,
745+
component: `${sistentTemplate}?__contentFilePath=${node.internal.contentFilePath}`,
746+
context: {
747+
slug: node.fields.slug,
748+
componentName: componentName,
749+
availablePages: availablePages,
750+
},
743751
});
744752
});
745-
};
746-
747-
createComponentPages(createPage, components);
753+
});
748754
};
749755

750756
// slug starts and ends with '/' so parts[0] and parts[-1] will be empty
@@ -831,13 +837,11 @@ exports.onCreateNode = ({ node, actions, getNode }) => {
831837
const parent = getNode(node.parent);
832838
let collection = parent.sourceInstanceName;
833839

834-
// --- CHANGED: Consolidated Source Logic ---
835840
// If the source is "collections", we determine the actual collection
836841
// from the parent directory name (e.g., "blog", "news", etc.)
837842
if (collection === "collections") {
838843
collection = parent.relativeDirectory.split("/")[0];
839844
}
840-
// ------------------------------------------
841845

842846
createNodeField({
843847
name: "collection",
@@ -900,6 +904,29 @@ exports.onCreateNode = ({ node, actions, getNode }) => {
900904
if (node.frontmatter.title)
901905
slug = `/community/events/${slugify(node.frontmatter.title)}`;
902906
break;
907+
case "sistent": {
908+
// For sistent components, create slug from directory structure
909+
const componentSlug = parent.relativeDirectory.split("/").pop();
910+
const fileName = parent.name;
911+
const suffix = fileName === "index" ? "" : `/${fileName}`;
912+
913+
slug = `/projects/sistent/components/${componentSlug}${suffix}`;
914+
915+
createNodeField({
916+
name: "componentName",
917+
node,
918+
value: componentSlug,
919+
});
920+
921+
// "index" -> "overview", others match filename
922+
const pageType = fileName === "index" ? "overview" : fileName;
923+
createNodeField({
924+
name: "pageType",
925+
node,
926+
value: pageType,
927+
});
928+
break;
929+
}
903930
default:
904931
slug = `/${collection}/${slugify(node.frontmatter.title)}`;
905932
}
Lines changed: 74 additions & 0 deletions
Loading
Lines changed: 74 additions & 0 deletions
Loading
Lines changed: 74 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)