Skip to content

Commit

Permalink
Merge pull request #6084 from Vidit-Kushwaha/feat/dynamic-imports
Browse files Browse the repository at this point in the history
Dynamic Imports of Component in Sistent documentation
  • Loading branch information
sudhanshutech authored Nov 21, 2024
2 parents 57ede4e + e60b965 commit e315363
Show file tree
Hide file tree
Showing 45 changed files with 328 additions and 391 deletions.
192 changes: 122 additions & 70 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,84 +389,99 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
const resourcePostTemplate = path.resolve("src/templates/resource-single.js");
const integrationTemplate = path.resolve("src/templates/integrations.js");

const res = await graphql(`{
allPosts: allMdx(filter: {frontmatter: {published: {eq: true}}}) {
nodes {
frontmatter {
program
programSlug
}
fields {
collection
slug
}
}
}
blogTags: allMdx(
filter: {fields: {collection: {eq: "blog"}}, frontmatter: {published: {eq: true}}}
) {
group(field: {frontmatter: {tags: SELECT}}) {
nodes {
id
const res = await graphql(`
{
allPosts: allMdx(filter: { frontmatter: { published: { eq: true } } }) {
nodes {
frontmatter {
program
programSlug
}
fields {
collection
slug
}
}
}
fieldValue
}
}
blogCategory: allMdx(
filter: {fields: {collection: {eq: "blog"}}, frontmatter: {published: {eq: true}}}
) {
group(field: {frontmatter: {category: SELECT}}) {
nodes {
id
blogTags: allMdx(
filter: {
fields: { collection: { eq: "blog" } }
frontmatter: { published: { eq: true } }
}
) {
group(field: { frontmatter: { tags: SELECT } }) {
nodes {
id
}
fieldValue
}
}
fieldValue
}
}
memberBio: allMdx(
filter: {fields: {collection: {eq: "members"}}, frontmatter: {published: {eq: true}, executive_bio: {eq: true}}}
) {
nodes {
frontmatter {
name
blogCategory: allMdx(
filter: {
fields: { collection: { eq: "blog" } }
frontmatter: { published: { eq: true } }
}
) {
group(field: { frontmatter: { category: SELECT } }) {
nodes {
id
}
fieldValue
}
}
fields {
slug
collection
memberBio: allMdx(
filter: {
fields: { collection: { eq: "members" } }
frontmatter: { published: { eq: true }, executive_bio: { eq: true } }
}
) {
nodes {
frontmatter {
name
}
fields {
slug
collection
}
}
}
}
}
singleWorkshop: allMdx(
filter: {fields: {collection: {eq: "service-mesh-workshops"}}}
) {
nodes {
fields {
slug
collection
singleWorkshop: allMdx(
filter: { fields: { collection: { eq: "service-mesh-workshops" } } }
) {
nodes {
fields {
slug
collection
}
}
}
}
}
labs: allMdx(filter: {fields: {collection: {eq: "service-mesh-labs"}}}) {
nodes {
fields {
slug
collection
labs: allMdx(
filter: { fields: { collection: { eq: "service-mesh-labs" } } }
) {
nodes {
fields {
slug
collection
}
}
}
}
}
learncontent: allMdx(filter: {fields: {collection: {eq: "content-learn"}}}) {
nodes {
fields {
learnpath
slug
course
section
chapter
pageType
collection
learncontent: allMdx(
filter: { fields: { collection: { eq: "content-learn" } } }
) {
nodes {
fields {
learnpath
slug
course
section
chapter
pageType
collection
}
}
}
}
}
}`);
`);

// handle errors
if (res.errors) {
Expand Down Expand Up @@ -707,6 +722,43 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
}
}
});

const components = [
"button",
"text-input",
"modal",
"paper",
"popper",
"text-field",
"link",
"container",
"button-group",
];

const createComponentPages = (createPage, components) => {
const pageTypes = [
{ suffix: "", file: "index.js" },
{ suffix: "/guidance", file: "guidance.js" },
{ suffix: "/code", file: "code.js" },
];

components.forEach((name) => {
pageTypes.forEach(({ suffix, file }) => {
const path = `/projects/sistent/components/${name}${suffix}`;
const componentPath = `./src/sections/Projects/Sistent/components/${name}/${file}`;
try {
createPage({
path,
component: require.resolve(componentPath),
});
} catch (error) {
console.error(`Error creating page for ${path}:`, error);
}
});
});
};

createComponentPages(createPage, components);
};

// slug starts and ends with '/' so parts[0] and parts[-1] will be empty
Expand Down
8 changes: 0 additions & 8 deletions src/pages/projects/sistent/components/button-group/code.js

This file was deleted.

This file was deleted.

8 changes: 0 additions & 8 deletions src/pages/projects/sistent/components/button-group/index.js

This file was deleted.

8 changes: 0 additions & 8 deletions src/pages/projects/sistent/components/button/code.js

This file was deleted.

8 changes: 0 additions & 8 deletions src/pages/projects/sistent/components/button/guidance.js

This file was deleted.

8 changes: 0 additions & 8 deletions src/pages/projects/sistent/components/button/index.js

This file was deleted.

8 changes: 0 additions & 8 deletions src/pages/projects/sistent/components/container/code.js

This file was deleted.

8 changes: 0 additions & 8 deletions src/pages/projects/sistent/components/container/guidance.js

This file was deleted.

8 changes: 0 additions & 8 deletions src/pages/projects/sistent/components/container/index.js

This file was deleted.

8 changes: 0 additions & 8 deletions src/pages/projects/sistent/components/link/code.js

This file was deleted.

8 changes: 0 additions & 8 deletions src/pages/projects/sistent/components/link/guidance.js

This file was deleted.

8 changes: 0 additions & 8 deletions src/pages/projects/sistent/components/link/index.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/pages/projects/sistent/components/modal/code.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/pages/projects/sistent/components/modal/guidance.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/pages/projects/sistent/components/modal/index.js

This file was deleted.

8 changes: 0 additions & 8 deletions src/pages/projects/sistent/components/paper/code.js

This file was deleted.

8 changes: 0 additions & 8 deletions src/pages/projects/sistent/components/paper/guidance.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/pages/projects/sistent/components/paper/index.js

This file was deleted.

8 changes: 0 additions & 8 deletions src/pages/projects/sistent/components/popper/code.js

This file was deleted.

Loading

0 comments on commit e315363

Please sign in to comment.