Skip to content

Refactor: Upgrade to Gatsby V5 and React 18 #47

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

Open
wants to merge 5 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions gatsby-browser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/**
* Implement Gatsby's Browser APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/browser-apis/
*/
import React from "react"
import { Layout } from "./src/components"

// You can delete this file if you're not using it
const wrapPageElement = ({ element, props }) => {
return <Layout {...props}>{element}</Layout>
}

export { wrapPageElement }
16 changes: 11 additions & 5 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
author: `@reactcebu`,
},
plugins: [
`gatsby-plugin-react-helmet`,
"gatsby-plugin-image",
{
resolve: `gatsby-source-filesystem`,
options: {
Expand All @@ -16,7 +16,16 @@ module.exports = {
},
},
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
{
resolve: `gatsby-plugin-sharp`,
options: {
defaults: {
placeholder: "blurred",
quality: 100,
},
},
},
"gatsby-transformer-sharp",
{
resolve: `gatsby-plugin-manifest`,
options: {
Expand All @@ -39,9 +48,6 @@ module.exports = {
},
},
},
// this (optional) plugin enables Progressive Web App + Offline functionality
// To learn more, visit: https://gatsby.dev/offline
// `gatsby-plugin-offline`,
],

// for avoiding CORS while developing Netlify Functions locally
Expand Down
27 changes: 12 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,20 @@
"@types/body-scroll-lock": "^2.6.1",
"@types/styled-components": "^5.1.1",
"axios": "^0.19.2",
"babel-plugin-styled-components": "^1.10.7",
"babel-plugin-styled-components": "^2.1.4",
"body-scroll-lock": "^3.1.5",
"gatsby": "^2.23.12",
"gatsby-image": "^2.4.9",
"gatsby-plugin-manifest": "^2.4.14",
"gatsby-plugin-offline": "^3.2.13",
"gatsby-plugin-react-helmet": "^3.3.6",
"gatsby-plugin-sharp": "^2.6.14",
"gatsby-plugin-styled-components": "^3.3.10",
"gatsby": "^5.8.0",
"gatsby-plugin-image": "^3.4.0",
"gatsby-plugin-manifest": "^5.8.0",
"gatsby-plugin-sharp": "^5.8.0",
"gatsby-plugin-styled-components": "^6.12.0",
"gatsby-plugin-web-font-loader": "^1.0.4",
"gatsby-source-filesystem": "^2.3.14",
"gatsby-transformer-sharp": "^2.5.7",
"gatsby-source-filesystem": "^5.12.1",
"gatsby-transformer-sharp": "^5.8.0",
"prop-types": "^15.7.2",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-helmet": "^6.1.0",
"styled-components": "^5.1.1"
"react": "^18.2.0",
"react-dom": "^18.2.0",
"styled-components": "^6.1.0"
},
"devDependencies": {
"@types/aws-lambda": "^8.10.61",
Expand All @@ -46,7 +43,7 @@
"start:lambda": "netlify-lambda serve src/lambda",
"develop": "gatsby clean && gatsby develop",
"build:app": "npm run clean && gatsby build",
"build:lambda": "netlify-lambda build src/lambda",
"build:lambda": "NODE_OPTIONS='--openssl-legacy-provider' netlify-lambda build src/lambda",
"build": "run-p build:**",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\"",
"serve": "gatsby serve",
Expand Down
14 changes: 0 additions & 14 deletions src/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ import {
Container,
FooterContainer,
MainFooter,
Top,
Center,
Link,
List,
ListItem,
} from "./Footer.styles"

import React from "react"
import { graphql, useStaticQuery } from "gatsby"

interface ComponentProps {
siteTitle?: string
Expand Down Expand Up @@ -68,17 +65,6 @@ const icons = [
export const Footer: React.FC<ComponentProps> = ({
siteTitle,
}: ComponentProps) => {
const data = useStaticQuery(graphql`
query {
logo: file(relativePath: { eq: "logo.png" }) {
childImageSharp {
fluid(maxWidth: 300) {
...GatsbyImageSharpFluid
}
}
}
}
`)
return (
<MainFooter>
<FooterContainer>
Expand Down
18 changes: 3 additions & 15 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
StyledBurger,
StyledButton,
} from "./Header.styles"
import { Link, graphql, useStaticQuery } from "gatsby"
import { Link } from "gatsby"

import Img from "gatsby-image"
import { StaticImage } from "gatsby-plugin-image"
import React, { useEffect, useRef, useState } from "react"
import {
disableBodyScroll,
Expand All @@ -22,18 +22,6 @@ interface ComponentProps {
export const Header: React.FC<ComponentProps> = ({
siteTitle,
}: ComponentProps) => {
const data = useStaticQuery(graphql`
query {
logo: file(relativePath: { eq: "logo.png" }) {
childImageSharp {
fluid(maxWidth: 300) {
...GatsbyImageSharpFluid
}
}
}
}
`)

const navRef = useRef(null)

const [showMenu, setShowMenu] = useState<boolean>(false)
Expand All @@ -53,7 +41,7 @@ export const Header: React.FC<ComponentProps> = ({
return (
<HeaderStyled>
<LinkStyled to="/">
<Img fluid={data.logo.childImageSharp.fluid} alt={siteTitle} />
<StaticImage src="../../assets/images/logo.png" alt={siteTitle} />
</LinkStyled>

<StyledBurger
Expand Down
6 changes: 1 addition & 5 deletions src/components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* See: https://www.gatsbyjs.org/docs/use-static-query/
*/

import { Footer, GlobalStyles, Header, SEO } from "../index"
import { Footer, GlobalStyles, Header } from "../index"
import { graphql, useStaticQuery } from "gatsby"

import PropTypes from "prop-types"
Expand All @@ -27,10 +27,6 @@ export const Layout = ({ children }) => {
return (
<LayoutContainer>
<GlobalStyles />
<SEO
title="Reactors Homepage"
description="A community for developers by developers"
/>
<Header siteTitle={data.site.siteMetadata.title} />
<LayoutContainerMain>{children}</LayoutContainerMain>
<Footer />
Expand Down
103 changes: 0 additions & 103 deletions src/components/SEO/SEO.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/SEO/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ export { Header } from "./Header"
export { Footer } from "./Footer"
export { Layout } from "./Layout"
export { GlobalStyles } from "./GlobalStyles"
export { SEO } from "./SEO"
export { Newsletter } from "./Newsletter"
export { Button } from "./Button"
16 changes: 12 additions & 4 deletions src/pages/404.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import React from "react"

import { Layout } from "../components/Layout"

const NotFoundPage = () => (
<Layout>
<>
<h1>NOT FOUND</h1>
<p>You just hit a route that doesn&#39;t exist... the sadness.</p>
</Layout>
</>
)

export const Head = () => (
<>
<title>Reactors Homepage</title>
<meta
name="description"
content="A community for developers by developers"
/>
</>
)

export default NotFoundPage
22 changes: 17 additions & 5 deletions src/pages/about.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import React from "react"
import { Layout } from "../components"
import FirstMeetup from "../assets/images/react-cebu-first-meetup.jpg"
import styled from "styled-components"
import { StaticImage } from "gatsby-plugin-image"

const AboutPage = () => {
return (
<Layout>
<>
<Section>
<h2>React Cebu — a community for developers by developers</h2>
<br />
<br />

<img src={FirstMeetup} alt="React Cebu First Meetup" />
<StaticImage
alt="First meetup"
src="../assets/images/react-cebu-first-meetup.jpg"
/>

<br />
<br />
Expand Down Expand Up @@ -43,10 +45,20 @@ const AboutPage = () => {
<a href={"mailto: [email protected]"}>[email protected]</a>
</p>
</Section>
</Layout>
</>
)
}

export const Head = () => (
<>
<title>Reactors Homepage</title>
<meta
name="description"
content="A community for developers by developers"
/>
</>
)

const Section = styled.section`
display: block;
max-width: 1440px;
Expand Down
Loading