From fa7945371b5efd6b8a81ac5261ad56fbeea18d88 Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Mon, 25 Jul 2022 22:20:44 +0100 Subject: [PATCH 01/13] migrate blog starter to Head API --- starters/blog/gatsby-config.js | 1 - starters/blog/gatsby-ssr.js | 9 +++ starters/blog/package.json | 2 - starters/blog/src/components/seo.js | 63 +++++--------------- starters/blog/src/pages/404.js | 3 +- starters/blog/src/pages/index.js | 4 +- starters/blog/src/pages/using-typescript.tsx | 3 +- starters/blog/src/templates/blog-post.js | 15 +++-- 8 files changed, 42 insertions(+), 58 deletions(-) create mode 100644 starters/blog/gatsby-ssr.js diff --git a/starters/blog/gatsby-config.js b/starters/blog/gatsby-config.js index 0c25b5c259a92..799682b0d9180 100644 --- a/starters/blog/gatsby-config.js +++ b/starters/blog/gatsby-config.js @@ -124,7 +124,6 @@ module.exports = { icon: `src/images/gatsby-icon.png`, // This path is relative to the root of the site. }, }, - `gatsby-plugin-react-helmet`, // this (optional) plugin enables Progressive Web App + Offline functionality // To learn more, visit: https://gatsby.dev/offline // `gatsby-plugin-offline`, diff --git a/starters/blog/gatsby-ssr.js b/starters/blog/gatsby-ssr.js new file mode 100644 index 0000000000000..86652d1166438 --- /dev/null +++ b/starters/blog/gatsby-ssr.js @@ -0,0 +1,9 @@ +/** + * Implement Gatsby's SSR (Server Side Rendering) APIs in this file. + * + * See: https://www.gatsbyjs.com/docs/ssr-apis/ + */ + + exports.onRenderBody = ({ setHtmlAttributes }) => { + setHtmlAttributes({ lang: `en` }) +} diff --git a/starters/blog/package.json b/starters/blog/package.json index 77fc11a00342c..140a4af9e90c3 100644 --- a/starters/blog/package.json +++ b/starters/blog/package.json @@ -15,7 +15,6 @@ "gatsby-plugin-image": "^2.19.0", "gatsby-plugin-manifest": "^4.19.0", "gatsby-plugin-offline": "^5.19.0", - "gatsby-plugin-react-helmet": "^5.19.0", "gatsby-plugin-sharp": "^4.19.0", "gatsby-remark-copy-linked-files": "^5.19.0", "gatsby-remark-images": "^6.19.0", @@ -28,7 +27,6 @@ "prismjs": "^1.28.0", "react": "^18.1.0", "react-dom": "^18.1.0", - "react-helmet": "^6.1.0", "typeface-merriweather": "0.0.72", "typeface-montserrat": "0.0.75" }, diff --git a/starters/blog/src/components/seo.js b/starters/blog/src/components/seo.js index 40fe5ea2d4308..481a85a877042 100644 --- a/starters/blog/src/components/seo.js +++ b/starters/blog/src/components/seo.js @@ -7,10 +7,9 @@ import * as React from "react" import PropTypes from "prop-types" -import { Helmet } from "react-helmet" import { useStaticQuery, graphql } from "gatsby" -const Seo = ({ description, lang, meta, title }) => { +const Seo = ({ description, lang, title, children }) => { const { site } = useStaticQuery( graphql` query { @@ -31,60 +30,30 @@ const Seo = ({ description, lang, meta, title }) => { const defaultTitle = site.siteMetadata?.title return ( - + <> + {defaultTitle ? `${title} | ${defaultTitle}` : title} + + + + + + + + + {children} + ) } Seo.defaultProps = { - lang: `en`, - meta: [], description: ``, } Seo.propTypes = { description: PropTypes.string, - lang: PropTypes.string, - meta: PropTypes.arrayOf(PropTypes.object), title: PropTypes.string.isRequired, } diff --git a/starters/blog/src/pages/404.js b/starters/blog/src/pages/404.js index 1df09ff33c45d..4eeb14ce4c8f1 100644 --- a/starters/blog/src/pages/404.js +++ b/starters/blog/src/pages/404.js @@ -9,13 +9,14 @@ const NotFoundPage = ({ data, location }) => { return ( -

404: Not Found

You just hit a route that doesn't exist... the sadness.

) } +export const Head = () => + export default NotFoundPage export const pageQuery = graphql` diff --git a/starters/blog/src/pages/index.js b/starters/blog/src/pages/index.js index 0e1cb233effa7..b8393b38a52a3 100644 --- a/starters/blog/src/pages/index.js +++ b/starters/blog/src/pages/index.js @@ -12,7 +12,6 @@ const BlogIndex = ({ data, location }) => { if (posts.length === 0) { return ( -

No blog posts found. Add markdown posts to "content/blog" (or the @@ -25,7 +24,6 @@ const BlogIndex = ({ data, location }) => { return ( -

    {posts.map(post => { @@ -65,6 +63,8 @@ const BlogIndex = ({ data, location }) => { export default BlogIndex +export const Head = () => + export const pageQuery = graphql` query { site { diff --git a/starters/blog/src/pages/using-typescript.tsx b/starters/blog/src/pages/using-typescript.tsx index fedd7c898d5ef..9a5f6bb294d95 100644 --- a/starters/blog/src/pages/using-typescript.tsx +++ b/starters/blog/src/pages/using-typescript.tsx @@ -17,7 +17,6 @@ const UsingTypescript: React.FC> = ({ location, }) => ( -

    Gatsby supports TypeScript by default!

    This means that you can create and write .ts/.tsx files for your @@ -43,6 +42,8 @@ const UsingTypescript: React.FC> = ({ ) +export const Head = () => + export default UsingTypescript export const query = graphql` diff --git a/starters/blog/src/templates/blog-post.js b/starters/blog/src/templates/blog-post.js index 5794890ba3e27..fc55510f4d3d2 100644 --- a/starters/blog/src/templates/blog-post.js +++ b/starters/blog/src/templates/blog-post.js @@ -12,10 +12,6 @@ const BlogPostTemplate = ({ data, location }) => { return ( -

    { ) } +export const Head = ({ data }) => { + const post = data.markdownRemark + + return ( + + ) +} + export default BlogPostTemplate export const pageQuery = graphql` From ee153357ddc5fa6fc0431a510fed12dce6bf93d4 Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Mon, 25 Jul 2022 22:21:23 +0100 Subject: [PATCH 02/13] migrate default starter to Head API --- starters/default/gatsby-config.js | 1 - starters/default/gatsby-ssr.js | 4 +- starters/default/package.json | 6 +- starters/default/src/components/seo.js | 60 ++++--------------- starters/default/src/pages/404.js | 3 +- starters/default/src/pages/index.js | 2 + starters/default/src/pages/page-2.js | 3 +- starters/default/src/pages/using-ssr.js | 3 +- .../default/src/pages/using-typescript.tsx | 3 +- starters/default/src/templates/using-dsg.js | 3 +- 10 files changed, 30 insertions(+), 58 deletions(-) diff --git a/starters/default/gatsby-config.js b/starters/default/gatsby-config.js index 9678eccb1dc19..0d70c8ccde116 100644 --- a/starters/default/gatsby-config.js +++ b/starters/default/gatsby-config.js @@ -6,7 +6,6 @@ module.exports = { siteUrl: `https://gatsbystarterdefaultsource.gatsbyjs.io/`, }, plugins: [ - `gatsby-plugin-react-helmet`, `gatsby-plugin-image`, { resolve: `gatsby-source-filesystem`, diff --git a/starters/default/gatsby-ssr.js b/starters/default/gatsby-ssr.js index 01d83255f4f2c..86652d1166438 100644 --- a/starters/default/gatsby-ssr.js +++ b/starters/default/gatsby-ssr.js @@ -4,4 +4,6 @@ * See: https://www.gatsbyjs.com/docs/ssr-apis/ */ -// You can delete this file if you're not using it + exports.onRenderBody = ({ setHtmlAttributes }) => { + setHtmlAttributes({ lang: `en` }) +} diff --git a/starters/default/package.json b/starters/default/package.json index 5a6b703d9f0c1..8078efd7b2683 100644 --- a/starters/default/package.json +++ b/starters/default/package.json @@ -5,19 +5,17 @@ "version": "0.1.0", "author": "Kyle Mathews ", "dependencies": { - "gatsby": "^4.19.2", + "gatsby": "4.20.0-next.4-dev-1658769684300", "gatsby-plugin-gatsby-cloud": "^4.19.0", "gatsby-plugin-image": "^2.19.0", "gatsby-plugin-manifest": "^4.19.0", "gatsby-plugin-offline": "^5.19.0", - "gatsby-plugin-react-helmet": "^5.19.0", "gatsby-plugin-sharp": "^4.19.0", "gatsby-source-filesystem": "^4.19.0", "gatsby-transformer-sharp": "^4.19.0", "prop-types": "^15.8.1", "react": "^18.1.0", - "react-dom": "^18.1.0", - "react-helmet": "^6.1.0" + "react-dom": "^18.1.0" }, "devDependencies": { "prettier": "^2.7.1" diff --git a/starters/default/src/components/seo.js b/starters/default/src/components/seo.js index d2dad201a9c28..7d334fbf98262 100644 --- a/starters/default/src/components/seo.js +++ b/starters/default/src/components/seo.js @@ -7,10 +7,9 @@ import * as React from "react" import PropTypes from "prop-types" -import { Helmet } from "react-helmet" import { useStaticQuery, graphql } from "gatsby" -function Seo({ description, lang, meta, title }) { +function Seo({ description, title, children }) { const { site } = useStaticQuery( graphql` query { @@ -29,60 +28,27 @@ function Seo({ description, lang, meta, title }) { const defaultTitle = site.siteMetadata?.title return ( - + <> + {defaultTitle ? `${title} | ${defaultTitle}` : title} + + + + + + + + + {children} + ) } Seo.defaultProps = { - lang: `en`, - meta: [], description: ``, } Seo.propTypes = { description: PropTypes.string, - lang: PropTypes.string, - meta: PropTypes.arrayOf(PropTypes.object), title: PropTypes.string.isRequired, } diff --git a/starters/default/src/pages/404.js b/starters/default/src/pages/404.js index b98b1ba58f303..bd7de997c1ba0 100644 --- a/starters/default/src/pages/404.js +++ b/starters/default/src/pages/404.js @@ -5,10 +5,11 @@ import Seo from "../components/seo" const NotFoundPage = () => ( -

    404: Not Found

    You just hit a route that doesn't exist... the sadness.

    ) +export const Head = () => + export default NotFoundPage diff --git a/starters/default/src/pages/index.js b/starters/default/src/pages/index.js index c02863ee9093f..707496b07ae97 100644 --- a/starters/default/src/pages/index.js +++ b/starters/default/src/pages/index.js @@ -119,4 +119,6 @@ const IndexPage = () => ( ) +export const Head = () => + export default IndexPage diff --git a/starters/default/src/pages/page-2.js b/starters/default/src/pages/page-2.js index 74b96e08c0ff8..aecc925549730 100644 --- a/starters/default/src/pages/page-2.js +++ b/starters/default/src/pages/page-2.js @@ -6,11 +6,12 @@ import Seo from "../components/seo" const SecondPage = () => ( -

    Hi from the second page

    Welcome to page 2

    Go back to the homepage
    ) +export const Head = () => + export default SecondPage diff --git a/starters/default/src/pages/using-ssr.js b/starters/default/src/pages/using-ssr.js index 6bbcff16eefd1..f89080d14662c 100644 --- a/starters/default/src/pages/using-ssr.js +++ b/starters/default/src/pages/using-ssr.js @@ -7,7 +7,6 @@ import Seo from "../components/seo" const UsingSSR = ({ serverData }) => { return ( -

    This page is rendered server-side

    @@ -33,6 +32,8 @@ const UsingSSR = ({ serverData }) => { ) } +export const Head = () => + export default UsingSSR export async function getServerData() { diff --git a/starters/default/src/pages/using-typescript.tsx b/starters/default/src/pages/using-typescript.tsx index 8018c1c905cbd..b1124065ed95d 100644 --- a/starters/default/src/pages/using-typescript.tsx +++ b/starters/default/src/pages/using-typescript.tsx @@ -16,7 +16,6 @@ const UsingTypescript: React.FC> = ({ location, }) => ( -

    Gatsby supports TypeScript by default

    @@ -44,6 +43,8 @@ const UsingTypescript: React.FC> = ({
    ) +export const Head = () => + export default UsingTypescript export const query = graphql` diff --git a/starters/default/src/templates/using-dsg.js b/starters/default/src/templates/using-dsg.js index f2306afec4ddd..9a84c728815c9 100644 --- a/starters/default/src/templates/using-dsg.js +++ b/starters/default/src/templates/using-dsg.js @@ -6,7 +6,6 @@ import Seo from "../components/seo" const UsingDSG = () => ( -

    Hello from a DSG Page

    @@ -22,4 +21,6 @@ const UsingDSG = () => (
    ) +export const Head = () => + export default UsingDSG From 95778d64b5061eb99683b46e703823e9b49c3271 Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Mon, 25 Jul 2022 22:21:51 +0100 Subject: [PATCH 03/13] migrate wordpress starter to Head API --- .../gatsby-config.js | 3 - .../gatsby-ssr.js | 9 +++ .../package.json | 2 - .../src/components/seo.js | 64 +++++-------------- .../src/pages/404.js | 4 +- .../src/templates/Page.js | 6 +- .../src/templates/Post.js | 6 +- .../src/templates/blog-post-archive.js | 6 +- 8 files changed, 40 insertions(+), 60 deletions(-) create mode 100644 starters/gatsby-starter-wordpress-blog/gatsby-ssr.js diff --git a/starters/gatsby-starter-wordpress-blog/gatsby-config.js b/starters/gatsby-starter-wordpress-blog/gatsby-config.js index 9f71aecf17353..bc7f644210eb1 100644 --- a/starters/gatsby-starter-wordpress-blog/gatsby-config.js +++ b/starters/gatsby-starter-wordpress-blog/gatsby-config.js @@ -54,9 +54,6 @@ module.exports = { }, }, - // See https://www.gatsbyjs.com/plugins/gatsby-plugin-react-helmet/?=gatsby-plugin-react-helmet - `gatsby-plugin-react-helmet`, - /** * this (optional) plugin enables Progressive Web App + Offline functionality * To learn more, visit: https://gatsby.dev/offline diff --git a/starters/gatsby-starter-wordpress-blog/gatsby-ssr.js b/starters/gatsby-starter-wordpress-blog/gatsby-ssr.js new file mode 100644 index 0000000000000..5500b627a86c4 --- /dev/null +++ b/starters/gatsby-starter-wordpress-blog/gatsby-ssr.js @@ -0,0 +1,9 @@ +/** + * Implement Gatsby's SSR (Server Side Rendering) APIs in this file. + * + * See: https://www.gatsbyjs.com/docs/ssr-apis/ + */ + +exports.onRenderBody = ({ setHtmlAttributes }) => { + setHtmlAttributes({ lang: `en` }) +} diff --git a/starters/gatsby-starter-wordpress-blog/package.json b/starters/gatsby-starter-wordpress-blog/package.json index 70b875b306511..f4e633257db44 100644 --- a/starters/gatsby-starter-wordpress-blog/package.json +++ b/starters/gatsby-starter-wordpress-blog/package.json @@ -14,7 +14,6 @@ "gatsby-plugin-image": "^2.19.0", "gatsby-plugin-manifest": "^4.19.0", "gatsby-plugin-offline": "^5.19.0", - "gatsby-plugin-react-helmet": "^5.19.0", "gatsby-plugin-sharp": "^4.19.0", "gatsby-source-wordpress": "^6.19.0", "gatsby-transformer-sharp": "^4.19.0", @@ -22,7 +21,6 @@ "lodash": "^4.17.21", "react": "^16.12.0", "react-dom": "^16.12.0", - "react-helmet": "^5.2.1", "typeface-merriweather": "0.0.72", "typeface-montserrat": "0.0.75" }, diff --git a/starters/gatsby-starter-wordpress-blog/src/components/seo.js b/starters/gatsby-starter-wordpress-blog/src/components/seo.js index 1a8798c5f25b6..83631bb9b9a93 100644 --- a/starters/gatsby-starter-wordpress-blog/src/components/seo.js +++ b/starters/gatsby-starter-wordpress-blog/src/components/seo.js @@ -7,10 +7,9 @@ import React from "react" import PropTypes from "prop-types" -import { Helmet } from "react-helmet" import { useStaticQuery, graphql } from "gatsby" -const SEO = ({ description, lang, meta, title }) => { +const SEO = ({ description, title, children }) => { const { wp, wpUser } = useStaticQuery( graphql` query { @@ -32,61 +31,32 @@ const SEO = ({ description, lang, meta, title }) => { const metaDescription = description || wp.generalSettings?.description const defaultTitle = wp.generalSettings?.title - return ( - + {defaultTitle ? `${title} | ${defaultTitle}` : title} + + + + + + + + + {children} + ) + } SEO.defaultProps = { - lang: `en`, - meta: [], description: ``, } SEO.propTypes = { description: PropTypes.string, - lang: PropTypes.string, - meta: PropTypes.arrayOf(PropTypes.object), title: PropTypes.string.isRequired, } diff --git a/starters/gatsby-starter-wordpress-blog/src/pages/404.js b/starters/gatsby-starter-wordpress-blog/src/pages/404.js index 606eacb497e89..2864b9eac65b0 100644 --- a/starters/gatsby-starter-wordpress-blog/src/pages/404.js +++ b/starters/gatsby-starter-wordpress-blog/src/pages/404.js @@ -9,13 +9,15 @@ const NotFoundPage = ({ data, location }) => { return ( - +

    404: Not Found

    You just hit a route that doesn't exist... the sadness.

    ) } +const Head = () => + export default NotFoundPage export const pageQuery = graphql` diff --git a/starters/gatsby-starter-wordpress-blog/src/templates/Page.js b/starters/gatsby-starter-wordpress-blog/src/templates/Page.js index 9a92889661181..a8125bf91545b 100644 --- a/starters/gatsby-starter-wordpress-blog/src/templates/Page.js +++ b/starters/gatsby-starter-wordpress-blog/src/templates/Page.js @@ -19,8 +19,6 @@ const PageTemplate = ({ data: { previous, next, post } }) => { return ( - -
    { ) } +export const Head = ({ data: { post } }) => ( + +) + export default PageTemplate export const pageQuery = graphql` diff --git a/starters/gatsby-starter-wordpress-blog/src/templates/Post.js b/starters/gatsby-starter-wordpress-blog/src/templates/Post.js index f11b1ad28a5dc..3f926988ad65d 100644 --- a/starters/gatsby-starter-wordpress-blog/src/templates/Post.js +++ b/starters/gatsby-starter-wordpress-blog/src/templates/Post.js @@ -19,8 +19,6 @@ const BlogPostTemplate = ({ data: { previous, next, post } }) => { return ( - -
    { ) } +export const Head = ({ data: { post } }) => ( + +) + export default BlogPostTemplate export const pageQuery = graphql` diff --git a/starters/gatsby-starter-wordpress-blog/src/templates/blog-post-archive.js b/starters/gatsby-starter-wordpress-blog/src/templates/blog-post-archive.js index 42e5bcf217ced..b7128b4c9dac4 100644 --- a/starters/gatsby-starter-wordpress-blog/src/templates/blog-post-archive.js +++ b/starters/gatsby-starter-wordpress-blog/src/templates/blog-post-archive.js @@ -15,7 +15,6 @@ const BlogIndex = ({ if (!posts.length) { return ( -

    No blog posts found. Add posts to your WordPress site and they'll @@ -27,10 +26,9 @@ const BlogIndex = ({ return ( - - +

      {posts.map(post => { const title = post.title @@ -68,6 +66,8 @@ const BlogIndex = ({ ) } +export const Head = () => + export default BlogIndex export const pageQuery = graphql` From cfe43496ae4c5809f78b342aa3e89712c0d510a5 Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Mon, 25 Jul 2022 22:29:00 +0100 Subject: [PATCH 04/13] use correct version --- starters/default/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starters/default/package.json b/starters/default/package.json index 8078efd7b2683..ac4385564e084 100644 --- a/starters/default/package.json +++ b/starters/default/package.json @@ -5,7 +5,7 @@ "version": "0.1.0", "author": "Kyle Mathews ", "dependencies": { - "gatsby": "4.20.0-next.4-dev-1658769684300", + "gatsby": "^4.19.2", "gatsby-plugin-gatsby-cloud": "^4.19.0", "gatsby-plugin-image": "^2.19.0", "gatsby-plugin-manifest": "^4.19.0", From d0570c3491d536c04c74e57676ce8d997798d57c Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Tue, 26 Jul 2022 11:16:37 +0100 Subject: [PATCH 05/13] Update starters/blog/src/components/seo.js Co-authored-by: Lennart --- starters/blog/src/components/seo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starters/blog/src/components/seo.js b/starters/blog/src/components/seo.js index 481a85a877042..0f1cfe10096ab 100644 --- a/starters/blog/src/components/seo.js +++ b/starters/blog/src/components/seo.js @@ -31,7 +31,7 @@ const Seo = ({ description, lang, title, children }) => { return ( <> - {defaultTitle ? `${title} | ${defaultTitle}` : title} + {defaultTitle ? `${title} | ${defaultTitle}` : title} From 4c7b6c905c16620698b087cb5e94048ccf65706e Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Tue, 26 Jul 2022 11:16:43 +0100 Subject: [PATCH 06/13] Update starters/default/src/components/seo.js Co-authored-by: Lennart --- starters/default/src/components/seo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starters/default/src/components/seo.js b/starters/default/src/components/seo.js index 7d334fbf98262..b336df2076819 100644 --- a/starters/default/src/components/seo.js +++ b/starters/default/src/components/seo.js @@ -29,7 +29,7 @@ function Seo({ description, title, children }) { return ( <> - {defaultTitle ? `${title} | ${defaultTitle}` : title} + {defaultTitle ? `${title} | ${defaultTitle}` : title} From 4cbc42213beb198c46c239dd8ee31b8392b8df9f Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Tue, 26 Jul 2022 11:24:49 +0100 Subject: [PATCH 07/13] change destructuring --- starters/blog/src/templates/blog-post.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/starters/blog/src/templates/blog-post.js b/starters/blog/src/templates/blog-post.js index fc55510f4d3d2..6dd726811da44 100644 --- a/starters/blog/src/templates/blog-post.js +++ b/starters/blog/src/templates/blog-post.js @@ -5,10 +5,11 @@ import Bio from "../components/bio" import Layout from "../components/layout" import Seo from "../components/seo" -const BlogPostTemplate = ({ data, location }) => { - const post = data.markdownRemark +const BlogPostTemplate = ({ + data: { previous, next, markdownRemark: post }, + location, +}) => { const siteTitle = data.site.siteMetadata?.title || `Title` - const { previous, next } = data return ( From 36994978213bb14f328ea6d772e4b5cd845aea23 Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Tue, 26 Jul 2022 11:50:03 +0100 Subject: [PATCH 08/13] format --- starters/blog/gatsby-ssr.js | 2 +- starters/default/gatsby-ssr.js | 2 +- .../src/components/seo.js | 28 ++++++++----------- .../src/pages/404.js | 1 - .../src/templates/blog-post-archive.js | 1 - 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/starters/blog/gatsby-ssr.js b/starters/blog/gatsby-ssr.js index 86652d1166438..5500b627a86c4 100644 --- a/starters/blog/gatsby-ssr.js +++ b/starters/blog/gatsby-ssr.js @@ -4,6 +4,6 @@ * See: https://www.gatsbyjs.com/docs/ssr-apis/ */ - exports.onRenderBody = ({ setHtmlAttributes }) => { +exports.onRenderBody = ({ setHtmlAttributes }) => { setHtmlAttributes({ lang: `en` }) } diff --git a/starters/default/gatsby-ssr.js b/starters/default/gatsby-ssr.js index 86652d1166438..5500b627a86c4 100644 --- a/starters/default/gatsby-ssr.js +++ b/starters/default/gatsby-ssr.js @@ -4,6 +4,6 @@ * See: https://www.gatsbyjs.com/docs/ssr-apis/ */ - exports.onRenderBody = ({ setHtmlAttributes }) => { +exports.onRenderBody = ({ setHtmlAttributes }) => { setHtmlAttributes({ lang: `en` }) } diff --git a/starters/gatsby-starter-wordpress-blog/src/components/seo.js b/starters/gatsby-starter-wordpress-blog/src/components/seo.js index 83631bb9b9a93..457bad6c34ec5 100644 --- a/starters/gatsby-starter-wordpress-blog/src/components/seo.js +++ b/starters/gatsby-starter-wordpress-blog/src/components/seo.js @@ -31,24 +31,20 @@ const SEO = ({ description, title, children }) => { const metaDescription = description || wp.generalSettings?.description const defaultTitle = wp.generalSettings?.title - return( + return ( <> - {defaultTitle ? `${title} | ${defaultTitle}` : title} - - - - - - - - - {children} - + {defaultTitle ? `${title} | ${defaultTitle}` : title} + + + + + + + + + {children} + ) - } SEO.defaultProps = { diff --git a/starters/gatsby-starter-wordpress-blog/src/pages/404.js b/starters/gatsby-starter-wordpress-blog/src/pages/404.js index 2864b9eac65b0..2db590a94c12b 100644 --- a/starters/gatsby-starter-wordpress-blog/src/pages/404.js +++ b/starters/gatsby-starter-wordpress-blog/src/pages/404.js @@ -9,7 +9,6 @@ const NotFoundPage = ({ data, location }) => { return ( -

      404: Not Found

      You just hit a route that doesn't exist... the sadness.

      diff --git a/starters/gatsby-starter-wordpress-blog/src/templates/blog-post-archive.js b/starters/gatsby-starter-wordpress-blog/src/templates/blog-post-archive.js index b7128b4c9dac4..d59cc66b9aa00 100644 --- a/starters/gatsby-starter-wordpress-blog/src/templates/blog-post-archive.js +++ b/starters/gatsby-starter-wordpress-blog/src/templates/blog-post-archive.js @@ -28,7 +28,6 @@ const BlogIndex = ({ -
        {posts.map(post => { const title = post.title From eb404962c119c665285bbf0f721e5f44f3e074c3 Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Tue, 26 Jul 2022 12:06:01 +0100 Subject: [PATCH 09/13] use types in TS pages --- starters/blog/src/pages/using-typescript.tsx | 4 ++-- starters/default/src/pages/using-typescript.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/starters/blog/src/pages/using-typescript.tsx b/starters/blog/src/pages/using-typescript.tsx index 9a5f6bb294d95..bdec46c05091f 100644 --- a/starters/blog/src/pages/using-typescript.tsx +++ b/starters/blog/src/pages/using-typescript.tsx @@ -1,6 +1,6 @@ // If you don't want to use TypeScript you can delete this file! import * as React from "react" -import { PageProps, Link, graphql } from "gatsby" +import { PageProps, Link, graphql, HeadFC } from "gatsby" import Layout from "../components/layout" import Seo from "../components/seo" @@ -42,7 +42,7 @@ const UsingTypescript: React.FC> = ({ ) -export const Head = () => +export const Head: HeadFC = () => export default UsingTypescript diff --git a/starters/default/src/pages/using-typescript.tsx b/starters/default/src/pages/using-typescript.tsx index b1124065ed95d..3f174786ca6a0 100644 --- a/starters/default/src/pages/using-typescript.tsx +++ b/starters/default/src/pages/using-typescript.tsx @@ -1,6 +1,6 @@ // If you don't want to use TypeScript you can delete this file! import * as React from "react" -import { PageProps, Link, graphql } from "gatsby" +import { PageProps, Link, graphql, HeadFC } from "gatsby" import Layout from "../components/layout" import Seo from "../components/seo" @@ -43,7 +43,7 @@ const UsingTypescript: React.FC> = ({ ) -export const Head = () => +export const Head: HeadFC = () => export default UsingTypescript From 5c981af674f36c380e0d71b8750b98fb227648e3 Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Tue, 26 Jul 2022 13:00:03 +0100 Subject: [PATCH 10/13] update lock files --- starters/blog/package-lock.json | 29 --------------- .../package-lock.json | 37 ------------------- 2 files changed, 66 deletions(-) diff --git a/starters/blog/package-lock.json b/starters/blog/package-lock.json index b3911ec27866a..cbe836992743e 100644 --- a/starters/blog/package-lock.json +++ b/starters/blog/package-lock.json @@ -7643,14 +7643,6 @@ "lodash": "^4.17.21" } }, - "gatsby-plugin-react-helmet": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/gatsby-plugin-react-helmet/-/gatsby-plugin-react-helmet-5.19.0.tgz", - "integrity": "sha512-XXrJYfHqoaUe57oAF+/ljPHncrvYk0UonES3aUwynbWsR8UXhQpdbwqIOYZPGQgPsc1X55Kzdo+/3pU1gA9ajQ==", - "requires": { - "@babel/runtime": "^7.15.4" - } - }, "gatsby-plugin-sharp": { "version": "4.19.0", "resolved": "https://registry.npmjs.org/gatsby-plugin-sharp/-/gatsby-plugin-sharp-4.19.0.tgz", @@ -12159,22 +12151,6 @@ "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.9.tgz", "integrity": "sha512-nQTTcUu+ATDbrSD1BZHr5kgSD4oF8OFjxun8uAaL8RwPBacGBNPf/yAuVVdx17N8XNzRDMrZ9XcKZHCjPW+9ew==" }, - "react-fast-compare": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.0.tgz", - "integrity": "sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA==" - }, - "react-helmet": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/react-helmet/-/react-helmet-6.1.0.tgz", - "integrity": "sha512-4uMzEY9nlDlgxr61NL3XbKRy1hEkXmKNXhjbAIOVw5vcFrsdYbH2FEwcNyWvWinl103nXgzYNlns9ca+8kFiWw==", - "requires": { - "object-assign": "^4.1.1", - "prop-types": "^15.7.2", - "react-fast-compare": "^3.1.1", - "react-side-effect": "^2.1.0" - } - }, "react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", @@ -12190,11 +12166,6 @@ "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.9.0.tgz", "integrity": "sha512-Gvzk7OZpiqKSkxsQvO/mbTN1poglhmAV7gR/DdIrRrSMXraRQQlfikRJOr3Nb9GTMPC5kof948Zy6jJZIFtDvQ==" }, - "react-side-effect": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/react-side-effect/-/react-side-effect-2.1.1.tgz", - "integrity": "sha512-2FoTQzRNTncBVtnzxFOk2mCpcfxQpenBMbk5kSVBg5UcPqV9fRbgY2zhb7GTWWOlpFmAxhClBDlIq8Rsubz1yQ==" - }, "read": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/read/-/read-1.0.7.tgz", diff --git a/starters/gatsby-starter-wordpress-blog/package-lock.json b/starters/gatsby-starter-wordpress-blog/package-lock.json index 2b1cd439cb09b..cec99d30d67e6 100644 --- a/starters/gatsby-starter-wordpress-blog/package-lock.json +++ b/starters/gatsby-starter-wordpress-blog/package-lock.json @@ -10284,14 +10284,6 @@ "lodash": "^4.17.21" } }, - "gatsby-plugin-react-helmet": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/gatsby-plugin-react-helmet/-/gatsby-plugin-react-helmet-5.19.0.tgz", - "integrity": "sha512-XXrJYfHqoaUe57oAF+/ljPHncrvYk0UonES3aUwynbWsR8UXhQpdbwqIOYZPGQgPsc1X55Kzdo+/3pU1gA9ajQ==", - "requires": { - "@babel/runtime": "^7.15.4" - } - }, "gatsby-plugin-sharp": { "version": "4.19.0", "resolved": "https://registry.npmjs.org/gatsby-plugin-sharp/-/gatsby-plugin-sharp-4.19.0.tgz", @@ -14713,22 +14705,6 @@ "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.9.tgz", "integrity": "sha512-nQTTcUu+ATDbrSD1BZHr5kgSD4oF8OFjxun8uAaL8RwPBacGBNPf/yAuVVdx17N8XNzRDMrZ9XcKZHCjPW+9ew==" }, - "react-fast-compare": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-2.0.4.tgz", - "integrity": "sha512-suNP+J1VU1MWFKcyt7RtjiSWUjvidmQSlqu+eHslq+342xCbGTYmC0mEhPCOHxlW0CywylOC1u2DFAT+bv4dBw==" - }, - "react-helmet": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/react-helmet/-/react-helmet-5.2.1.tgz", - "integrity": "sha512-CnwD822LU8NDBnjCpZ4ySh8L6HYyngViTZLfBBb3NjtrpN8m49clH8hidHouq20I51Y6TpCTISCBbqiY5GamwA==", - "requires": { - "object-assign": "^4.1.1", - "prop-types": "^15.5.4", - "react-fast-compare": "^2.0.2", - "react-side-effect": "^1.1.0" - } - }, "react-is": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", @@ -14767,14 +14743,6 @@ "resolved": "https://registry.npmjs.org/react-resize-aware/-/react-resize-aware-3.1.1.tgz", "integrity": "sha512-M8IyVLBN8D6tEUss+bxQlWte3ZYtNEGhg7rBxtCVG8yEBjUlZwUo5EFLq6tnvTZXcgAbCLjsQn+NCoTJKumRYg==" }, - "react-side-effect": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/react-side-effect/-/react-side-effect-1.2.0.tgz", - "integrity": "sha512-v1ht1aHg5k/thv56DRcjw+WtojuuDHFUgGfc+bFHOWsF4ZK6C2V57DO0Or0GPsg6+LSTE0M6Ry/gfzhzSwbc5w==", - "requires": { - "shallowequal": "^1.0.1" - } - }, "react-spring": { "version": "8.0.27", "resolved": "https://registry.npmjs.org/react-spring/-/react-spring-8.0.27.tgz", @@ -15465,11 +15433,6 @@ "resolved": "https://registry.npmjs.org/shallow-compare/-/shallow-compare-1.2.2.tgz", "integrity": "sha512-LUMFi+RppPlrHzbqmFnINTrazo0lPNwhcgzuAXVVcfy/mqPDrQmHAyz5bvV0gDAuRFrk804V0HpQ6u9sZ0tBeg==" }, - "shallowequal": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/shallowequal/-/shallowequal-1.1.0.tgz", - "integrity": "sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==" - }, "sharp": { "version": "0.30.7", "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.30.7.tgz", From 52dd2455af0ea28c9e1c97f5fe83086a0a130413 Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Tue, 26 Jul 2022 13:06:17 +0100 Subject: [PATCH 11/13] update lock file --- starters/default/package-lock.json | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/starters/default/package-lock.json b/starters/default/package-lock.json index 0824c25c6b1aa..c09fc3ed98f83 100644 --- a/starters/default/package-lock.json +++ b/starters/default/package-lock.json @@ -7469,14 +7469,6 @@ "lodash": "^4.17.21" } }, - "gatsby-plugin-react-helmet": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/gatsby-plugin-react-helmet/-/gatsby-plugin-react-helmet-5.19.0.tgz", - "integrity": "sha512-XXrJYfHqoaUe57oAF+/ljPHncrvYk0UonES3aUwynbWsR8UXhQpdbwqIOYZPGQgPsc1X55Kzdo+/3pU1gA9ajQ==", - "requires": { - "@babel/runtime": "^7.15.4" - } - }, "gatsby-plugin-sharp": { "version": "4.19.0", "resolved": "https://registry.npmjs.org/gatsby-plugin-sharp/-/gatsby-plugin-sharp-4.19.0.tgz", @@ -11360,22 +11352,6 @@ "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.9.tgz", "integrity": "sha512-nQTTcUu+ATDbrSD1BZHr5kgSD4oF8OFjxun8uAaL8RwPBacGBNPf/yAuVVdx17N8XNzRDMrZ9XcKZHCjPW+9ew==" }, - "react-fast-compare": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.0.tgz", - "integrity": "sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA==" - }, - "react-helmet": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/react-helmet/-/react-helmet-6.1.0.tgz", - "integrity": "sha512-4uMzEY9nlDlgxr61NL3XbKRy1hEkXmKNXhjbAIOVw5vcFrsdYbH2FEwcNyWvWinl103nXgzYNlns9ca+8kFiWw==", - "requires": { - "object-assign": "^4.1.1", - "prop-types": "^15.7.2", - "react-fast-compare": "^3.1.1", - "react-side-effect": "^2.1.0" - } - }, "react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", @@ -11391,11 +11367,6 @@ "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.9.0.tgz", "integrity": "sha512-Gvzk7OZpiqKSkxsQvO/mbTN1poglhmAV7gR/DdIrRrSMXraRQQlfikRJOr3Nb9GTMPC5kof948Zy6jJZIFtDvQ==" }, - "react-side-effect": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/react-side-effect/-/react-side-effect-2.1.1.tgz", - "integrity": "sha512-2FoTQzRNTncBVtnzxFOk2mCpcfxQpenBMbk5kSVBg5UcPqV9fRbgY2zhb7GTWWOlpFmAxhClBDlIq8Rsubz1yQ==" - }, "read": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/read/-/read-1.0.7.tgz", From 440482aca25ac5268bac72ba3a92dc3f957cb72d Mon Sep 17 00:00:00 2001 From: Jude Agboola Date: Tue, 26 Jul 2022 13:40:04 +0100 Subject: [PATCH 12/13] change destructuring --- starters/blog/src/templates/blog-post.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/starters/blog/src/templates/blog-post.js b/starters/blog/src/templates/blog-post.js index 6dd726811da44..05bf7980a46b5 100644 --- a/starters/blog/src/templates/blog-post.js +++ b/starters/blog/src/templates/blog-post.js @@ -61,9 +61,7 @@ const BlogPostTemplate = ({ ) } -export const Head = ({ data }) => { - const post = data.markdownRemark - +export const Head = ({ data: { markdownRemark: post } }) => { return ( Date: Tue, 26 Jul 2022 15:52:51 +0100 Subject: [PATCH 13/13] fix variable reference --- starters/blog/src/templates/blog-post.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/starters/blog/src/templates/blog-post.js b/starters/blog/src/templates/blog-post.js index 05bf7980a46b5..ce425ce18f954 100644 --- a/starters/blog/src/templates/blog-post.js +++ b/starters/blog/src/templates/blog-post.js @@ -6,10 +6,10 @@ import Layout from "../components/layout" import Seo from "../components/seo" const BlogPostTemplate = ({ - data: { previous, next, markdownRemark: post }, + data: { previous, next, site, markdownRemark: post }, location, }) => { - const siteTitle = data.site.siteMetadata?.title || `Title` + const siteTitle = site.siteMetadata?.title || `Title` return (