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

Gatsby v4 to v5 migration #1243

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 23 additions & 24 deletions gatsby-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as types from "./internal/gatsby/types";

export default {
pathPrefix: config.pathPrefix,
trailingSlash: 'always',
siteMetadata: {
url: config.url,
menu: config.menu,
Expand Down Expand Up @@ -63,30 +64,28 @@ export default {
(node.frontmatter?.slug || node.fields?.slug),
custom_elements: [{ "content:encoded": node.html }],
})),
query: `
{
allMarkdownRemark(
limit: 1000,
sort: { order: DESC, fields: [frontmatter___date] },
filter: { frontmatter: { template: { eq: "post" }, draft: { ne: true } } }
) {
edges {
node {
html
fields {
slug
}
frontmatter {
date
title
slug
description
}
}
}
}
}
`,
query: `{
allMarkdownRemark(
limit: 1000
sort: {frontmatter: {date: DESC}}
filter: {frontmatter: {template: {eq: "post"}, draft: {ne: true}}}
) {
edges {
node {
html
fields {
slug
}
frontmatter {
date
title
slug
description
}
}
}
}
}`,
output: "/rss.xml",
title: config.title,
},
Expand Down
24 changes: 10 additions & 14 deletions internal/gatsby/queries/categories-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,17 @@ interface CategoriesQueryResult {
}

const categoriesQuery = async (graphql: CreatePagesArgs["graphql"]) => {
const result = await graphql<CategoriesQueryResult>(`
{
allMarkdownRemark(
filter: {
frontmatter: { template: { eq: "post" }, draft: { ne: true } }
}
sort: { order: DESC, fields: [frontmatter___date] }
) {
group(field: frontmatter___category) {
fieldValue
totalCount
}
}
const result = await graphql<CategoriesQueryResult>(`{
allMarkdownRemark(
filter: {frontmatter: {template: {eq: "post"}, draft: {ne: true}}}
sort: {frontmatter: {date: DESC}}
) {
group(field: {frontmatter: {category: SELECT}}) {
fieldValue
totalCount
}
`);
}
}`);

return result?.data?.allMarkdownRemark?.group ?? [];
};
Expand Down
22 changes: 9 additions & 13 deletions internal/gatsby/queries/tags-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,16 @@ interface TagsQueryResult {
}

const tagsQuery = async (graphql: CreatePagesArgs["graphql"]) => {
const result = await graphql<TagsQueryResult>(`
{
allMarkdownRemark(
filter: {
frontmatter: { template: { eq: "post" }, draft: { ne: true } }
}
) {
group(field: frontmatter___tags) {
fieldValue
totalCount
}
}
const result = await graphql<TagsQueryResult>(`{
allMarkdownRemark(
filter: {frontmatter: {template: {eq: "post"}, draft: {ne: true}}}
) {
group(field: {frontmatter: {tags: SELECT}}) {
fieldValue
totalCount
}
`);
}
}`);

return result?.data?.allMarkdownRemark?.group || [];
};
Expand Down