Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Imports of Component in Sistent documentation #6084

Merged
merged 4 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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