Skip to content

Commit f52448a

Browse files
matiasperrone-exomatiasperronesmarcet
authored
Update Gatsby v5.15 and React v18.3 (#73)
* Add needed changes (WIP) * Fix config to support null frontmatter * Add extra updates on config to fix building issues * Replace Netlify CMS with the Decap CMS as is the new name * Add needed plugins * Build works now * Change missing wdget for new local ones * Add missing dependency "shortid" * Fix config * Fix missing names * Add fixes for FileRelationWidgetControl * Upgrade to Gatsby v5 * Add env variables in config * Add env variables in config * Undo last commit * Add missing previous dependency * Add missing previous plugins * Update node and yarn versions * Changed from class components to function components * Revert graphQL query to previous one * Bumped Gatsby to ^5.15.0 * Add seo image fixes * Code fix * Add minor fix * Convert BlogIndexPage to function component * Fix class attribute to className * Fix error in onsubmit functionality * Remove incorrect "publicURL" image attribute * Update Index Page “indexPage” --------- Co-authored-by: Matias Perrone <github@matiasperrone.com> Co-authored-by: sebastian marcet <smarcet@gmail.com>
1 parent 9f739ed commit f52448a

34 files changed

+11628
-17250
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ static/admin/*.bundle.*
99
yarn-error.log
1010
# Developer environment
1111
.idea/
12+
.env*

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
12.20.1
1+
20.18.1

gatsby-browser.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

gatsby-config.js

Lines changed: 68 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -7,68 +7,6 @@ module.exports = {
77
plugins: [
88
"gatsby-plugin-react-helmet",
99
"gatsby-plugin-sass",
10-
{
11-
resolve: `gatsby-plugin-feed`,
12-
options: {
13-
query: `
14-
{
15-
site {
16-
siteMetadata {
17-
url
18-
site_url: url
19-
}
20-
}
21-
}
22-
`,
23-
feeds: [
24-
{
25-
serialize: ({ query: { site, allMarkdownRemark } }) => {
26-
return allMarkdownRemark.edges.map(edge => {
27-
return Object.assign({}, edge.node.frontmatter, {
28-
description: edge.node.frontmatter.seo ? edge.node.frontmatter.seo.description : null,
29-
date: edge.node.frontmatter.date,
30-
url: edge.node.frontmatter.seo ? edge.node.frontmatter.seo.url : null,
31-
guid: edge.node.frontmatter.seo ? edge.node.frontmatter.seo.url : null,
32-
custom_elements: [{ "content:encoded": edge.node.html }],
33-
})
34-
})
35-
},
36-
query: `
37-
{
38-
allMarkdownRemark(
39-
sort: { order: DESC, fields: [frontmatter___date] },
40-
filter: { frontmatter: { templateKey: { eq: "blog-post" } } }
41-
) {
42-
edges {
43-
node {
44-
html
45-
fields { slug }
46-
frontmatter {
47-
title
48-
date
49-
seo {
50-
description
51-
url
52-
}
53-
}
54-
}
55-
}
56-
}
57-
}
58-
`,
59-
output: "/rss.xml",
60-
title: "Ironic Bare Metal RSS Feed",
61-
// optional configuration to insert feed reference in pages:
62-
// if `string` is used, it will be used to create RegExp and then test if pathname of
63-
// current page satisfied this regular expression;
64-
// if not provided or `undefined`, all pages will have feed reference inserted
65-
match: "^/blog/",
66-
// optional configuration to specify external rss feed, such as feedburner
67-
// link: "https://feeds.feedburner.com/gatsby/blog",
68-
},
69-
],
70-
},
71-
},
7210
{
7311
// keep as first gatsby-source-filesystem plugin for gatsby image support
7412
resolve: "gatsby-source-filesystem",
@@ -87,8 +25,15 @@ module.exports = {
8725
{
8826
resolve: "gatsby-source-filesystem",
8927
options: {
90-
path: `${__dirname}/src/img`,
91-
name: "images",
28+
name: `content`,
29+
path: `${__dirname}/src/content`,
30+
},
31+
},
32+
{
33+
resolve: "gatsby-source-filesystem",
34+
options: {
35+
path: `${__dirname}/src/pages`,
36+
name: "pages",
9237
},
9338
},
9439
"gatsby-plugin-sharp",
@@ -97,18 +42,9 @@ module.exports = {
9742
resolve: "gatsby-transformer-remark",
9843
options: {
9944
plugins: [
100-
{
101-
resolve: "gatsby-remark-relative-images",
102-
options: {
103-
name: "uploads",
104-
},
105-
},
10645
{
10746
resolve: "gatsby-remark-images",
10847
options: {
109-
// It's important to specify the maxWidth (in pixels) of
110-
// the content container as this plugin uses this as the
111-
// base for generating different widths of each image.
11248
maxWidth: 2048,
11349
linkImagesToOriginal: false,
11450
},
@@ -129,11 +65,65 @@ module.exports = {
12965
],
13066
},
13167
},
68+
{
69+
resolve: `gatsby-plugin-feed`,
70+
options: {
71+
query: `
72+
{
73+
site {
74+
siteMetadata {
75+
title
76+
description
77+
url
78+
site_url: url
79+
}
80+
}
81+
}
82+
`,
83+
feeds: [
84+
{
85+
serialize: ({ query: { site, allMarkdownRemark } }) => {
86+
return allMarkdownRemark.nodes.map(node => {
87+
return Object.assign({}, node.frontmatter, {
88+
description: node.excerpt,
89+
date: node.frontmatter.date,
90+
url: site.siteMetadata.url + node.fields.slug,
91+
guid: site.siteMetadata.url + node.fields.slug,
92+
custom_elements: [{ "content:encoded": node.html }],
93+
})
94+
})
95+
},
96+
query: `
97+
{
98+
allMarkdownRemark(
99+
sort: { frontmatter: { date: DESC } },
100+
) {
101+
nodes {
102+
excerpt
103+
html
104+
fields {
105+
slug
106+
}
107+
frontmatter {
108+
title
109+
date
110+
}
111+
}
112+
}
113+
}
114+
`,
115+
output: "/rss.xml",
116+
title: "Ironic Bare Metal RSS Feed",
117+
match: "^/blog/",
118+
},
119+
],
120+
},
121+
},
132122
{
133123
resolve: `gatsby-plugin-google-analytics`,
134124
options: {
135125
// The property ID; the tracking code won't be generated without it
136-
trackingId: "",
126+
trackingId: "UA-PLACEHOLDER",
137127
// Defines where to place the tracking script - `true` in the head and `false` in the body
138128
head: true,
139129
// Setting this parameter is optional
@@ -147,7 +137,7 @@ module.exports = {
147137
options: {
148138
// You can add multiple tracking ids and a pageview event will be fired for all of them.
149139
trackingIds: [
150-
"", // Google Analytics / GA
140+
"GA_MEASUREMENT_ID", // Google Analytics / GA
151141
],
152142
// This object gets passed directly to the gtag config command
153143
// This config will be shared across all trackingIds
@@ -181,11 +171,11 @@ module.exports = {
181171
{
182172
resolve: `gatsby-plugin-offline`,
183173
options: {
184-
precachePages: [``, `/blog/*`],
174+
precachePages: [`/`, `/blog/*`],
185175
},
186176
},
187177
{
188-
resolve: "gatsby-plugin-netlify-cms",
178+
resolve: "gatsby-plugin-decap-cms",
189179
options: {
190180
modulePath: `${__dirname}/src/cms/cms.js`,
191181
},
@@ -199,12 +189,7 @@ module.exports = {
199189
},
200190
}, // must be after other CSS plugins
201191
{
202-
resolve: "gatsby-plugin-netlify", // make sure to keep it last in the array,
203-
options: {
204-
enableIdentityWidget: true,
205-
htmlTitle: `Ironic | Content Manager`,
206-
includeRobots: false,
207-
},
192+
resolve: "gatsby-plugin-netlify", // make sure to keep it last in the array
208193
},
209194
],
210195
};

gatsby-node.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
11
const _ = require('lodash')
2-
const axios = require('axios')
32
const path = require('path')
43
const { createFilePath } = require('gatsby-source-filesystem')
5-
const { fmImagesToRelative } = require('gatsby-remark-relative-images')
4+
5+
exports.createSchemaCustomization = ({ actions }) => {
6+
const { createTypes } = actions
7+
8+
const typeDefs = `
9+
type MarkdownRemarkFrontmatter {
10+
category: [BlogCategory]
11+
author: String
12+
templateKey: String
13+
date: Date @dateformat
14+
title: String
15+
subTitle: String
16+
company: String
17+
}
18+
19+
type BlogCategory {
20+
label: String
21+
id: String
22+
}
23+
`
24+
25+
createTypes(typeDefs)
26+
}
627

728
exports.createPages = ({ actions, graphql }) => {
829
const { createPage } = actions
@@ -36,7 +57,7 @@ exports.createPages = ({ actions, graphql }) => {
3657
const posts = result.data.allMarkdownRemark.edges
3758

3859
posts.forEach(edge => {
39-
const id = edge.node.id
60+
const id = edge.node.id
4061
createPage({
4162
path: edge.node.fields.slug.replace('/pages', ''),
4263
category: edge.node.frontmatter.category,
@@ -76,7 +97,7 @@ exports.createPages = ({ actions, graphql }) => {
7697

7798
// author pages:
7899
let authors = []
79-
// Iterate through each post, putting all found authors into `authors`
100+
// Iterate through each post, putting all found authors into `authors`
80101
posts.forEach(edge => {
81102
if (_.get(edge, `node.frontmatter.author`)) {
82103
authors = authors.concat(edge.node.frontmatter.author)
@@ -102,7 +123,6 @@ exports.createPages = ({ actions, graphql }) => {
102123

103124
exports.onCreateNode = ({ node, actions, getNode }) => {
104125
const { createNodeField } = actions
105-
fmImagesToRelative(node) // convert image paths for gatsby images
106126

107127
if (node.internal.type === `MarkdownRemark`) {
108128
const value = createFilePath({ node, getNode })

netlify.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
publish = "public"
33
command = "npm run build"
44
[build.environment]
5-
NODE_VERSION = "12.20.1"
6-
YARN_VERSION = "1.13.0"
5+
NODE_VERSION = "20.18.1"
6+
YARN_VERSION = "v1.22.22"
77
YARN_FLAGS = "--no-ignore-optional"
88
PYTHON_VERSION = "3.10"

0 commit comments

Comments
 (0)