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

Move Thumbprint README.mdx files to the www/src/pages folder #37

Closed
danoc opened this issue Jan 26, 2019 · 1 comment
Closed

Move Thumbprint README.mdx files to the www/src/pages folder #37

danoc opened this issue Jan 26, 2019 · 1 comment

Comments

@danoc
Copy link
Member

danoc commented Jan 26, 2019

The Thumbprint README.mdx files are the only ones that are not defined in www/src/pages. Instead, they are created dynamically in gatsby-node.js. This complicates our infrastructure and can be simplified now that we've fully adopted MDX.

The proposal is to move all of the README.mdx files into src/www/pages so that each page on the site is represented by a file in src/www/pages that maps to the URL.

This will allow us to delete this code:

exports.createPages = ({ actions, graphql }) => {
const { createPage } = actions;
return new Promise((resolve, reject) => {
resolve(
graphql(`
query ThumprintPages {
allComponentApi: allMdx(
filter: { frontmatter: { mdxType: { eq: "componentApi" } } }
) {
edges {
node {
frontmatter {
package
kit
url
platform
}
parent {
... on File {
absolutePath
relativeDirectory
}
}
}
}
}
# These are all of the kits. We use this to create pages for the ones that have
# design documentation.
allKits: allMdx(filter: { frontmatter: { mdxType: { eq: "kit" } } }) {
edges {
node {
frontmatter {
url
}
parent {
... on File {
relativePath
}
}
}
}
}
}
`).then(result => {
if (result.errors) {
reject(result.errors);
}
result.data.allKits.edges.forEach(({ node }) => {
const { url } = node.frontmatter;
if (url) {
createPage({
path: url,
component: path.resolve(
'./src/components/thumbprint-components/page/index.jsx',
),
context: {
// Example: `button/index.mdx`
kitPath: node.parent.relativePath,
isDesignGuidelinesPage: true,
},
});
}
});
// Create API documentation for Thumbprint components
result.data.allComponentApi.edges.forEach(({ node }) => {
const { frontmatter } = node;
createPage({
path: frontmatter.url,
component: path.resolve(
'./src/components/thumbprint-components/page/index.jsx',
),
context: {
isDesignGuidelinesPage: false,
// Example: `@thumbtack/thumbprint-react`
package: frontmatter.package,
// Example: `thumbprint-react/components/Button`
pathToReactComponentFolder:
frontmatter.platform === 'react'
? node.parent.relativeDirectory
: null,
// Example: `button/index.mdx`
kitPath: frontmatter.kit,
// Example: /components/button/react/
url: frontmatter.url,
},
});
});
return undefined;
}),
);
});
};

@danoc
Copy link
Member Author

danoc commented Feb 13, 2019

This is done!

@danoc danoc closed this as completed Feb 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant