Skip to content

Commit 692499e

Browse files
authored
BREAKING: v3 (#112)
1 parent c05f29d commit 692499e

File tree

116 files changed

+5533
-25752
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+5533
-25752
lines changed

.eslintignore

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ node_modules
33
packages/*/dist/**
44
packages/*/lib/**
55
packages/*/scripts/**
6+
packages/*/index.d.ts
67
starters
78
.github

MIGRATING.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Migration Guide
2+
3+
## Migrating from `gatsby-theme-blog` / `gatsby-theme-blog-core` / `gatsby-theme-blog-darkmode` v2 to v3
4+
5+
The 3.0 release includes breaking changes as the theme was upgraded to Gatsby v3, Theme UI v0.7, emotion v11, and migrated from `gatsby-image` to `gatsby-plugin-image`.
6+
7+
Before upgrading to 3.0 you'll want to update your core `gatsby` version to v3 as well: [Migrating from v2 to v3 documentation](https://www.gatsbyjs.com/docs/reference/release-notes/migrating-from-v2-to-v3/).
8+
9+
**All versions updated** - All versions (Gatsby plugins, third-party packages) were updated to their latest versions. This includes breaking changes like updating to emotion 11.
10+
11+
**Plugin Options** - The `mdx` option was replaced by `mdxOtherwiseConfigured`.
12+
13+
**Images** - `gatsby-image` and its queries (fluid/fixed) were replaced with the new `gatsby-plugin-image`. See [Migrating from gatsby-image to gatsby-plugin-image](https://www.gatsbyjs.com/docs/reference/release-notes/image-migration-guide/).
14+
15+
**Theme UI** - Theme UI was updated to v0.7. See [Theme UI's migration guide](https://theme-ui.com/migrating).
16+
17+
## Migrating from `gatsby-theme-notes` v2 to v3
18+
19+
Before upgrading to 3.0 you'll want to update your core `gatsby` version to v3 as well: [Migrating from v2 to v3 documentation](https://www.gatsbyjs.com/docs/reference/release-notes/migrating-from-v2-to-v3/).
20+
21+
**All versions updated** - All versions (Gatsby plugins, third-party packages) were updated to their latest versions. This includes breaking changes like updating to emotion 11.
22+
23+
**Plugin Options** - The `mdx` option was replaced by `mdxOtherwiseConfigured`.
24+
25+
**Theme UI** - Theme UI was updated to v0.7. See [Theme UI's migration guide](https://theme-ui.com/migrating).
26+
27+
## Migrating from `gatsby-theme-i18n` v1 to v2
28+
29+
Before upgrading to 3.0 you'll want to update your core `gatsby` version to v3 as well: [Migrating from v2 to v3 documentation](https://www.gatsbyjs.com/docs/reference/release-notes/migrating-from-v2-to-v3/).
30+
31+
**New peerDependencies** - `gatsby-plugin-react-helmet` and `react-helmet` are now `peerDependencies`. You'll need to install them yourself: `npm install gatsby-plugin-react-helmet react-helmet`. Also add `gatsby-plugin-react-helmet` to your `gatsby-config.js`.
32+
33+
## Migrating from `gatsby-theme-i18n-lingui` v1 to v2
34+
35+
Before upgrading to 3.0 you'll want to update your core `gatsby` version to v3 as well: [Migrating from v2 to v3 documentation](https://www.gatsbyjs.com/docs/reference/release-notes/migrating-from-v2-to-v3/).
36+
37+
**Update to lingui v3** - The theme now requires lingui v3. All lingui dependencies were updated from v2 to v3. See [lingui's migration guide](https://lingui.js.org/releases/migration-3.html). This also means that you have to install `@lingui/core` as a new `dependency` and change your configuration file. See the [README](https://github.com/gatsbyjs/themes/tree/master/packages/gatsby-theme-i18n-lingui) for more information.
38+
39+
## Migrating from `gatsby-theme-i18n-react-i18next` / `gatsby-theme-i18n-react-intl` v1 to v2
40+
41+
Before upgrading to 3.0 you'll want to update your core `gatsby` version to v3 as well: [Migrating from v2 to v3 documentation](https://www.gatsbyjs.com/docs/reference/release-notes/migrating-from-v2-to-v3/).
42+
43+
**Update to peerDependencies**. These updates to the `devDependencies` / `peerDependencies` were made:
44+
45+
- Update `i18next` from 19.x to 20.x
46+
- Update `react-intl` from 4.x to 5.x, so you'll have to use `react-intl` v5
47+
48+
## Migrating from `gatsby-theme-blog` v1 to v2
49+
50+
The 2.0 release includes breaking changes. Note that many of the changes are related to the default styling in the blog theme. If you have no interest in additional flexibility with styles the 1.6 release may be sufficient as it includes new features without the breaking changes.
51+
52+
Before upgrading to 2.0 you'll want to update your core `gatsby` version as well.
53+
54+
**Change in data structure** - Instead of querying for the `node` object inside the `edges` array, all queries now look for `nodes`. If you're shadowing files and accessing data directly you may need to account for this.
55+
56+
**Removal of darkmode toggle** - This theme no longer comes with a darkmode toggle. If you'd like to use the old one it is now available as a parallel theme you can install, [`gatsby-theme-blog-darkmode`](https://www.gatsbyjs.com/plugins/gatsby-theme-blog-darkmode/). Please see the README for further instructions.
57+
58+
### Style specific migration notes
59+
60+
With the new version of `gatsby-plugin-theme-ui` there are a number of changes to the way styles are passed and how they compose.
61+
62+
**Change in shadow structure** - When shadowing files in `gatsby-plugin-theme-ui` the directory can no longer be nested inside the `gatsby-theme-blog` directory. It needs to be at the root level. Additionally, all content needs to be shadowed via `index.js`. You can make use of files like `colors.js` but they will not shadow unless explicitly exported from `index.js`.
63+
64+
**Default deepmerge** - Any shadowed styles will deepmerge with the `gatsby-theme-blog` built-in styles automatically.
65+
66+
If your previous code look like this:
67+
68+
```javascript
69+
import merge from "deepmerge"
70+
import defaultThemeColors from "gatsby-theme-blog/src/gatsby-plugin-theme-ui/colors"
71+
72+
const darkBlue = `#007acc`
73+
const lightBlue = `#66E0FF`
74+
const blueGray = `#282c35`
75+
76+
const theme = merge(defaultThemeColors, {
77+
text: blueGray,
78+
primary: darkBlue,
79+
heading: blueGray,
80+
})
81+
82+
export default theme
83+
```
84+
85+
It should now look like this. Noting that the merge still occurs by default.
86+
87+
```javascript
88+
const darkBlue = `#007acc`
89+
const lightBlue = `#66E0FF`
90+
const blueGray = `#282c35`
91+
92+
const theme = {
93+
text: blueGray,
94+
primary: darkBlue,
95+
heading: blueGray,
96+
}
97+
98+
export default theme
99+
```
100+
101+
If you did not merge in the official theme styles and instead overrode them you can still do so. You'll want to remove the preset by passing the option in `gatsby-config.js`
102+
103+
```javascript
104+
module.exports = {
105+
plugins: [
106+
{
107+
resolve: `gatsby-theme-blog`,
108+
options: {
109+
preset: false,
110+
},
111+
},
112+
],
113+
}
114+
```
115+
116+
**No built in Typography.js** - [Typography.js](https://kyleamathews.github.io/typography.js/) is no longer part of the default styling. If you'd like to add it locally follow the [Theme UI docs](https://theme-ui.com/packages/typography/#extending-the-typographyjs-theme) or note the code snippet below. The original theme used `typography-theme-wordpress-2016` and also imported `typeface-montserrat` and `typeface-merriweather`.
117+
118+
Another thing to keep in mind if you're pulling in typography for local shadowing is that the order of merging is different. The most common issue is that the spacing underneath code blocks is off. To fix that, include the following code in `src/gatsby-plugin-theme-ui/index.js`.
119+
120+
```javascript
121+
import { toTheme } from "@theme-ui/typography"
122+
import wp2016 from "typography-theme-wordpress-2016"
123+
import { merge } from "theme-ui"
124+
125+
const theme = merge(toTheme(wp2016), {
126+
styles: {
127+
pre: {
128+
margin: `0 0 2 0`,
129+
},
130+
},
131+
})
132+
133+
export default theme
134+
```

packages/gatsby-theme-blog-core/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
The Gatsby blog core theme
88
</h1>
99

10-
A Gatsby theme for creating a blog child theme. It includes all of the data structures you need to get up and running building a blog and includes no additional theming or style opinions.
10+
A Gatsby theme for creating a blog child theme. It includes all the data structures you need to get up and running building a blog and includes no additional theming or style opinions. `gatsby-theme-blog` uses this theme under the hood.
1111

1212
## Installation
1313

@@ -134,4 +134,4 @@ The following are the defined blog post fields based on the node interface in th
134134

135135
There are some existing components that you can import and use. Reference the full path to do so, e.g. `gatsby-blog-theme-core/src/components/post`.
136136

137-
Also note that there are classNames on elements in these components allowing you to target them with styles.
137+
Also note that there are `classNames` on elements in these components allowing you to target them with styles in your CSS.

packages/gatsby-theme-blog-core/gatsby-config.js

100644100755
Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ const withDefaults = require(`./utils/default-options`)
22

33
module.exports = (themeOptions) => {
44
const options = withDefaults(themeOptions)
5-
const {
6-
mdxOtherwiseConfigured = false,
7-
mdx: legacyConfigureMdxFlag = true,
8-
} = themeOptions // keep mdx flag so we don't introduce a breaking change
5+
const { mdxOtherwiseConfigured = false } = themeOptions
96

107
return {
118
siteMetadata: {
@@ -25,25 +22,24 @@ module.exports = (themeOptions) => {
2522
],
2623
},
2724
plugins: [
28-
!mdxOtherwiseConfigured &&
29-
legacyConfigureMdxFlag && {
30-
resolve: `gatsby-plugin-mdx`,
31-
options: {
32-
extensions: [`.mdx`, `.md`],
33-
gatsbyRemarkPlugins: [
34-
{
35-
resolve: `gatsby-remark-images`,
36-
options: {
37-
maxWidth: options.imageMaxWidth,
38-
linkImagesToOriginal: false,
39-
},
25+
!mdxOtherwiseConfigured && {
26+
resolve: `gatsby-plugin-mdx`,
27+
options: {
28+
extensions: [`.mdx`, `.md`],
29+
gatsbyRemarkPlugins: [
30+
{
31+
resolve: `gatsby-remark-images`,
32+
options: {
33+
maxWidth: options.imageMaxWidth,
34+
linkImagesToOriginal: false,
4035
},
41-
{ resolve: `gatsby-remark-copy-linked-files` },
42-
{ resolve: `gatsby-remark-smartypants` },
43-
],
44-
remarkPlugins: [require(`remark-slug`)],
45-
},
36+
},
37+
{ resolve: `gatsby-remark-copy-linked-files` },
38+
{ resolve: `gatsby-remark-smartypants` },
39+
],
40+
remarkPlugins: [require(`remark-slug`)],
4641
},
42+
},
4743
{
4844
resolve: `gatsby-source-filesystem`,
4945
options: {
@@ -58,6 +54,7 @@ module.exports = (themeOptions) => {
5854
name: options.assetPath || `content/assets`,
5955
},
6056
},
57+
`gatsby-plugin-image`,
6158
`gatsby-transformer-sharp`,
6259
`gatsby-plugin-sharp`,
6360
].filter(Boolean),

packages/gatsby-theme-blog-core/gatsby-node.js

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const mdxResolverPassthrough = (fieldName) => async (
4949
exports.createSchemaCustomization = ({ actions, schema }, themeOptions) => {
5050
const { excerptLength } = withDefaults(themeOptions)
5151
const { createTypes } = actions
52-
createTypes(`interface BlogPost @nodeInterface {
52+
createTypes(`interface BlogPost implements Node {
5353
id: ID!
5454
title: String!
5555
body: String!
@@ -292,7 +292,7 @@ exports.createPages = async ({ graphql, actions, reporter }, themeOptions) => {
292292
)
293293

294294
if (result.errors) {
295-
reporter.panic(result.errors)
295+
reporter.panicOnBuild(result.errors)
296296
}
297297

298298
// Create Posts and Post pages.
Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "gatsby-theme-blog-core",
3-
"version": "2.1.0",
3+
"description": "The core theme for gatsby-theme-blog",
4+
"version": "3.0.0",
45
"main": "index.js",
56
"author": "christopherbiscardi <[email protected]> (@chrisbiscardi)",
67
"license": "MIT",
@@ -11,31 +12,25 @@
1112
},
1213
"homepage": "https://github.com/gatsbyjs/themes/tree/master/packages/gatsby-theme-blog-core#readme",
1314
"peerDependencies": {
14-
"@mdx-js/react": "^1.0.27",
15-
"gatsby": "^2.23.22",
16-
"react": "^16.8.6",
17-
"react-dom": "^16.8.6"
15+
"@mdx-js/react": "^1.6.22",
16+
"gatsby": "^3.0.0",
17+
"react": "^17.0.0",
18+
"react-dom": "^17.0.0"
1819
},
1920
"dependencies": {
20-
"@mdx-js/mdx": "^1.6.14",
21-
"gatsby-core-utils": "^1.3.13",
22-
"gatsby-plugin-mdx": "^1.2.28",
23-
"gatsby-plugin-sharp": "^2.6.21",
24-
"gatsby-remark-copy-linked-files": "^2.3.11",
25-
"gatsby-remark-images": "^3.3.20",
26-
"gatsby-remark-smartypants": "^2.3.10",
27-
"gatsby-source-filesystem": "^2.3.22",
28-
"gatsby-transformer-sharp": "^2.5.11",
21+
"@mdx-js/mdx": "^1.6.22",
22+
"gatsby-core-utils": "^2.2.0",
23+
"gatsby-plugin-image": "^1.2.1",
24+
"gatsby-plugin-mdx": "^2.2.0",
25+
"gatsby-plugin-sharp": "^3.2.1",
26+
"gatsby-remark-copy-linked-files": "^3.2.0",
27+
"gatsby-remark-images": "^4.2.0",
28+
"gatsby-remark-smartypants": "^3.2.0",
29+
"gatsby-source-filesystem": "^3.2.0",
30+
"gatsby-transformer-sharp": "^3.2.0",
2931
"remark-slug": "^5.1.2"
3032
},
31-
"devDependencies": {
32-
"@mdx-js/react": "^1.6.14",
33-
"gatsby": "^2.24.10",
34-
"prettier": "2.0.5",
35-
"react": "^16.12.0",
36-
"react-dom": "^16.12.0"
37-
},
3833
"engines": {
39-
"node": ">=10.13.0"
34+
"node": ">=12.13.0"
4035
}
4136
}

packages/gatsby-theme-blog-core/src/components/post-date.js

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react"
1+
import * as React from "react"
22

33
const PostDate = (props) => <p className="post-date" {...props} />
44

packages/gatsby-theme-blog-core/src/components/post-hero.js

100644100755
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import React from "react"
2-
import Image from "gatsby-image"
1+
import * as React from "react"
2+
import { GatsbyImage, getImage } from "gatsby-plugin-image"
33

44
const PostHero = ({ post }) => (
55
<>
66
{post?.image?.childImageSharp && (
7-
<Image
8-
fluid={post.image.childImageSharp.fluid}
7+
<GatsbyImage
8+
image={getImage(post.image)}
99
alt={post.imageAlt ? post.imageAlt : post.excerpt}
1010
className="post-hero"
1111
/>

packages/gatsby-theme-blog-core/src/components/post-link.js

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react"
1+
import * as React from "react"
22
import { Link } from "gatsby"
33

44
const PostLink = ({ title, slug, date, excerpt }) => (

packages/gatsby-theme-blog-core/src/components/post-list.js

100644100755
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import React from "react"
2-
1+
import * as React from "react"
32
import PostLink from "./post-link"
43

54
const PostList = ({ posts }) => (

packages/gatsby-theme-blog-core/src/components/post-title.js

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react"
1+
import * as React from "react"
22

33
const PostTitle = (props) => (
44
<h1 className="post-title" {...props}>

packages/gatsby-theme-blog-core/src/components/post.js

100644100755
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import React from "react"
2-
1+
import * as React from "react"
32
import { MDXRenderer } from "gatsby-plugin-mdx"
4-
53
import PostTitle from "./post-title"
64
import PostDate from "./post-date"
75
import PostHero from "./post-hero"

packages/gatsby-theme-blog-core/src/components/posts.js

100644100755
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import React from "react"
2-
1+
import * as React from "react"
32
import PostList from "./post-list"
43

54
const Posts = ({ data }) => {

packages/gatsby-theme-blog-core/src/templates/post-query.js

100644100755
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,15 @@ export const query = graphql`
2929
date(formatString: "MMMM DD, YYYY")
3030
image {
3131
childImageSharp {
32-
fluid(maxWidth: $maxWidth) {
33-
...GatsbyImageSharpFluid
34-
src
35-
}
32+
gatsbyImageData(width: $maxWidth)
3633
}
3734
}
3835
imageAlt
3936
imageCaptionText
4037
imageCaptionLink
4138
socialImage {
4239
childImageSharp {
43-
fluid {
44-
...GatsbyImageSharpFluid
45-
src
46-
}
40+
gatsbyImageData(width: 1600)
4741
}
4842
}
4943
}

0 commit comments

Comments
 (0)