Skip to content

Commit 375ac83

Browse files
refactor(gatsby-node): streamline page handlers
1 parent 4b2fce5 commit 375ac83

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

gatsby-node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
131131
graphql,
132132
createPage,
133133
reporter,
134+
sistentTemplate: path.resolve("src/templates/sistent-component.js"),
134135
});
135136

136137
const res = await graphql(`
@@ -663,7 +664,6 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
663664
}
664665
}
665666
});
666-
667667
};
668668

669669
// slug starts and ends with '/' so parts[0] and parts[-1] will be empty

src/node-api/createBlogPages.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ const createBlogPages = async ({
99
blogCategoryListTemplate,
1010
blogTagListTemplate,
1111
}) => {
12+
if (!isCollectionEnabled("blog")) {
13+
return;
14+
}
15+
1216
const result = await graphql(`
1317
{
1418
blogPosts: allMdx(
@@ -54,10 +58,6 @@ const createBlogPages = async ({
5458
return;
5559
}
5660

57-
if (!isCollectionEnabled("blog")) {
58-
return;
59-
}
60-
6161
const blogs = result.data.blogPosts.nodes;
6262
const blogCategory = result.data.blogCategory.group;
6363
const blogTags = result.data.blogTags.group;

src/node-api/createSistentComponentPages.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
const path = require("path");
2-
3-
const createSistentComponentPages = async ({ graphql, createPage, reporter }) => {
1+
const createSistentComponentPages = async ({
2+
graphql,
3+
createPage,
4+
reporter,
5+
sistentTemplate,
6+
}) => {
47
const result = await graphql(`
58
{
69
sistentComponents: allMdx(
7-
filter: {
8-
fields: { collection: { eq: "sistent" } }
9-
}
10+
filter: { fields: { collection: { eq: "sistent" } } }
1011
) {
1112
group(field: { fields: { componentName: SELECT } }) {
1213
fieldValue
@@ -32,7 +33,6 @@ const createSistentComponentPages = async ({ graphql, createPage, reporter }) =>
3233
return;
3334
}
3435

35-
const sistentTemplate = path.resolve("src/templates/sistent-component.js");
3636
const sistentGroups = result.data.sistentComponents.group;
3737

3838
sistentGroups.forEach((group) => {

0 commit comments

Comments
 (0)