-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Refactor/gatsby node modularization #7622
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
Open
Manishnemade12
wants to merge
11
commits into
layer5io:master
Choose a base branch
from
Manishnemade12:refactor/gatsby-node-modularization-issue-5
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9c118eb
fix(smi-table): memoize rows and localize collapse state
Manishnemade12 8d494bd
fix(smi-table): use single shared tooltip instance
Manishnemade12 b6e4110
refactor(node-api): modularize gatsby-node page creators
Manishnemade12 536c075
revert(smi-table): clean up unused imports and variables
Manishnemade12 6d797da
Merge branch 'master' into refactor/gatsby-node-modularization-issue-5
Manishnemade12 dab2c4f
Merge branch 'master' into refactor/gatsby-node-modularization-issue-5
Manishnemade12 e4fef14
Merge branch 'master' into refactor/gatsby-node-modularization-issue-5
CodexRaunak 1562b12
Merge branch 'master' into refactor/gatsby-node-modularization-issue-5
Manishnemade12 4b2fce5
Update src/node-api/createKanvasLabPages.js
Manishnemade12 5a572b3
refactor(gatsby-node): streamline page handlers
Manishnemade12 0572e46
Merge branch 'master' into refactor/gatsby-node-modularization-issue-5
Manishnemade12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| const slugify = require("../utils/slugify"); | ||
|
|
||
| const createBlogPages = async ({ | ||
| graphql, | ||
| createPage, | ||
| reporter, | ||
| isCollectionEnabled, | ||
| blogPostTemplate, | ||
| blogCategoryListTemplate, | ||
| blogTagListTemplate, | ||
| }) => { | ||
| if (!isCollectionEnabled("blog")) { | ||
| return; | ||
| } | ||
|
|
||
| const result = await graphql(` | ||
| { | ||
| blogPosts: allMdx( | ||
|
Manishnemade12 marked this conversation as resolved.
|
||
| filter: { | ||
| fields: { collection: { eq: "blog" } } | ||
| frontmatter: { published: { eq: true } } | ||
| } | ||
| ) { | ||
| nodes { | ||
| fields { | ||
| slug | ||
| } | ||
| internal { | ||
| contentFilePath | ||
| } | ||
| } | ||
| } | ||
| blogTags: allMdx( | ||
| filter: { | ||
| fields: { collection: { eq: "blog" } } | ||
| frontmatter: { published: { eq: true } } | ||
| } | ||
| ) { | ||
| group(field: { frontmatter: { tags: SELECT } }) { | ||
| fieldValue | ||
| } | ||
| } | ||
| blogCategory: allMdx( | ||
| filter: { | ||
| fields: { collection: { eq: "blog" } } | ||
| frontmatter: { published: { eq: true } } | ||
| } | ||
| ) { | ||
| group(field: { frontmatter: { category: SELECT } }) { | ||
| fieldValue | ||
| } | ||
| } | ||
| } | ||
| `); | ||
|
|
||
| if (result.errors) { | ||
| reporter.panicOnBuild("Error while running GraphQL query for blog pages."); | ||
| return; | ||
| } | ||
|
|
||
| const blogs = result.data.blogPosts.nodes; | ||
| const blogCategory = result.data.blogCategory.group; | ||
| const blogTags = result.data.blogTags.group; | ||
|
|
||
| blogs.forEach((blog) => { | ||
| createPage({ | ||
| path: blog.fields.slug, | ||
| component: `${blogPostTemplate}?__contentFilePath=${blog.internal.contentFilePath}`, | ||
| context: { | ||
| slug: blog.fields.slug, | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| blogCategory.forEach((category) => { | ||
| createPage({ | ||
| path: `/blog/category/${slugify(category.fieldValue)}`, | ||
| component: blogCategoryListTemplate, | ||
| context: { | ||
| category: category.fieldValue, | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| blogTags.forEach((tag) => { | ||
| createPage({ | ||
| path: `/blog/tag/${slugify(tag.fieldValue)}`, | ||
| component: blogTagListTemplate, | ||
| context: { | ||
| tag: tag.fieldValue, | ||
| }, | ||
| }); | ||
| }); | ||
| }; | ||
|
|
||
| module.exports = createBlogPages; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| const createKanvasLabPages = async ({ graphql, createPage, reporter, labTemplate }) => { | ||
| const result = await graphql(` | ||
| { | ||
| labs: allMdx( | ||
| filter: { fields: { collection: { eq: "kanvas-labs" } } } | ||
| ) { | ||
| nodes { | ||
| fields { | ||
| slug | ||
| } | ||
| internal { | ||
| contentFilePath | ||
| } | ||
| } | ||
| } | ||
| } | ||
| `); | ||
|
|
||
| if (result.errors) { | ||
| const graphqlError = new Error( | ||
| result.errors.map((error) => error.message || String(error)).join("\n") | ||
| ); | ||
| reporter.panicOnBuild( | ||
| "Error while running GraphQL query for Kanvas labs pages.", | ||
| graphqlError | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| const labs = result.data.labs.nodes; | ||
|
|
||
| labs.forEach((lab) => { | ||
| createPage({ | ||
| path: lab.fields.slug, | ||
| component: `${labTemplate}?__contentFilePath=${lab.internal.contentFilePath}`, | ||
| context: { | ||
| slug: lab.fields.slug, | ||
| }, | ||
| }); | ||
| }); | ||
| }; | ||
|
|
||
| module.exports = createKanvasLabPages; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.