Skip to content

Commit e33a175

Browse files
committed
feat: standardize sistent component layouts and refactor to MDX
Migrated all Sistent components to dynamic MDX routing. Standardized component header layouts by moving descriptions to frontmatter. Cleaned up legacy content.js and deprecated code. Signed-off-by: Rishi Raj <rishiraj438gt@gmail.com>
1 parent b7bc06b commit e33a175

File tree

251 files changed

+15217
-25303
lines changed

Some content is hidden

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

251 files changed

+15217
-25303
lines changed

gatsby-node.js

Lines changed: 49 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -242,23 +242,19 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
242242
sistentComponents: allMdx(
243243
filter: {
244244
fields: { collection: { eq: "sistent" } }
245-
frontmatter: { published: { eq: true } }
246245
}
247246
) {
248-
nodes {
249-
frontmatter {
250-
name
251-
title
252-
description
253-
component
254-
pages
255-
}
256-
fields {
257-
slug
258-
collection
259-
}
260-
internal {
261-
contentFilePath
247+
group(field: { fields: { componentName: SELECT } }) {
248+
fieldValue
249+
nodes {
250+
fields {
251+
slug
252+
componentName
253+
pageType
254+
}
255+
internal {
256+
contentFilePath
257+
}
262258
}
263259
}
264260
}
@@ -563,43 +559,26 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
563559
});
564560

565561
// Create Sistent component pages dynamically from MDX
566-
const sistentComponents = res.data.sistentComponents.nodes;
567-
568-
sistentComponents.forEach((node) => {
569-
const componentName = node.frontmatter.component;
570-
const pages = node.frontmatter.pages || ["overview"];
571-
572-
const pageTypes = [
573-
{ suffix: "", file: "index.js", pageType: "overview" },
574-
{ suffix: "/guidance", file: "guidance.js", pageType: "guidance" },
575-
{ suffix: "/code", file: "code.js", pageType: "code" },
576-
];
577-
578-
pageTypes.forEach(({ suffix, file, pageType }) => {
579-
// Only create pages that exist in frontmatter
580-
if (pages.includes(pageType)) {
581-
const pagePath = `/projects/sistent/components/${componentName}${suffix}`;
582-
const componentPath = `./src/sections/Projects/Sistent/components/${componentName}/${file}`;
583-
584-
if (fs.existsSync(path.resolve(componentPath))) {
585-
try {
586-
createPage({
587-
path: pagePath,
588-
component: require.resolve(componentPath),
589-
context: {
590-
slug: `/sistent/components/${componentName}`,
591-
componentName: componentName,
592-
},
593-
});
594-
} catch (error) {
595-
console.error(`Error creating page for "${pagePath}":`, error);
596-
}
597-
} else {
598-
console.info(
599-
`Skipping creating page "${pagePath}" - file not found: "${componentPath}"`
600-
);
601-
}
602-
}
562+
// Use grouping to identify which sub-pages (Tabs) exist for each component
563+
const sistentGroups = res.data.sistentComponents.group;
564+
const sistentTemplate = path.resolve("src/templates/sistent-component.js");
565+
566+
sistentGroups.forEach((group) => {
567+
const componentName = group.fieldValue;
568+
// content-learn uses different fields, sistent uses componentName.
569+
570+
const availablePages = group.nodes.map(node => node.fields.pageType);
571+
572+
group.nodes.forEach((node) => {
573+
createPage({
574+
path: node.fields.slug,
575+
component: `${sistentTemplate}?__contentFilePath=${node.internal.contentFilePath}`,
576+
context: {
577+
slug: node.fields.slug,
578+
componentName: componentName,
579+
availablePages: availablePages
580+
}
581+
});
603582
});
604583
});
605584
};
@@ -688,13 +667,11 @@ exports.onCreateNode = ({ node, actions, getNode }) => {
688667
const parent = getNode(node.parent);
689668
let collection = parent.sourceInstanceName;
690669

691-
// --- CHANGED: Consolidated Source Logic ---
692670
// If the source is "collections", we determine the actual collection
693671
// from the parent directory name (e.g., "blog", "news", etc.)
694672
if (collection === "collections") {
695673
collection = parent.relativeDirectory.split("/")[0];
696674
}
697-
// ------------------------------------------
698675

699676
createNodeField({
700677
name: "collection",
@@ -742,7 +719,24 @@ exports.onCreateNode = ({ node, actions, getNode }) => {
742719
case "sistent": {
743720
// For sistent components, create slug from directory structure
744721
const componentSlug = parent.relativeDirectory.split("/").pop();
745-
slug = `/sistent/components/${componentSlug}`;
722+
const fileName = parent.name;
723+
const suffix = fileName === "index" ? "" : `/${fileName}`;
724+
725+
slug = `/projects/sistent/components/${componentSlug}${suffix}`;
726+
727+
createNodeField({
728+
name: "componentName",
729+
node,
730+
value: componentSlug,
731+
});
732+
733+
// "index" -> "overview", others match filename
734+
const pageType = fileName === "index" ? "overview" : fileName;
735+
createNodeField({
736+
name: "pageType",
737+
node,
738+
value: pageType,
739+
});
746740
break;
747741
}
748742
default:
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import React, { useState } from "react";
2+
import { Accordion, AccordionSummary, AccordionDetails, Typography } from "@sistent/sistent";
3+
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
4+
5+
const ControlledAccordion = () => {
6+
const [expanded, setExpanded] = useState("panel1");
7+
8+
const handleChange = (panel) => (event, isExpanded) => {
9+
setExpanded(isExpanded ? panel : false);
10+
};
11+
12+
return (
13+
<div style={{ width: "100%" }}>
14+
<Accordion expanded={expanded === "panel1"} onChange={handleChange("panel1")}>
15+
<AccordionSummary
16+
expandIcon={<ExpandMoreIcon />}
17+
aria-controls="panel1bh-content"
18+
id="panel1bh-header"
19+
>
20+
<Typography>
21+
General settings
22+
</Typography>
23+
</AccordionSummary>
24+
<AccordionDetails>
25+
<Typography>
26+
Controlled accordions manage their expanded state through React, allowing only one panel to be open at a time. This creates a cleaner, more focused user experience by preventing multiple sections from being visible simultaneously.
27+
</Typography>
28+
</AccordionDetails>
29+
</Accordion>
30+
<Accordion expanded={expanded === "panel2"} onChange={handleChange("panel2")}>
31+
<AccordionSummary
32+
expandIcon={<ExpandMoreIcon />}
33+
aria-controls="panel2bh-content"
34+
id="panel2bh-header"
35+
>
36+
<Typography>Users</Typography>
37+
</AccordionSummary>
38+
<AccordionDetails>
39+
<Typography>
40+
When expanding this panel, the previously opened panel automatically collapses. This behavior is ideal for settings pages, configuration panels, and any interface where you want users to focus on one section at a time.
41+
</Typography>
42+
</AccordionDetails>
43+
</Accordion>
44+
<Accordion expanded={expanded === "panel3"} onChange={handleChange("panel3")}>
45+
<AccordionSummary
46+
expandIcon={<ExpandMoreIcon />}
47+
aria-controls="panel3bh-content"
48+
id="panel3bh-header"
49+
>
50+
<Typography>
51+
Advanced settings
52+
</Typography>
53+
</AccordionSummary>
54+
<AccordionDetails>
55+
<Typography>
56+
Accordions help organize complex information into digestible sections. They reduce cognitive load by hiding content until users actively choose to reveal it, making interfaces feel less overwhelming and more navigable.
57+
</Typography>
58+
</AccordionDetails>
59+
</Accordion>
60+
</div>
61+
);
62+
};
63+
64+
export default ControlledAccordion;

0 commit comments

Comments
 (0)