From 4fb0aae042b89b996bcc09ac37ef4e50e55c27f2 Mon Sep 17 00:00:00 2001 From: Kevin Kandlbinder Date: Fri, 24 Sep 2021 15:13:11 +0200 Subject: [PATCH] Migrate all images to Gatsby Image --- gatsby-config.js | 14 ++++++++++++++ package.json | 1 + src/pages/friends.js | 18 ++++++++++-------- src/pages/friends.module.scss | 12 ++++++++++++ src/pages/index.js | 18 +++++++----------- src/pages/projects.js | 17 +++++++---------- src/pages/projects.module.scss | 11 +++++++++++ src/pages/social.js | 14 +++++++++----- src/pages/social.module.scss | 13 +++++++++++++ src/templates/project.js | 13 +++++++------ yarn.lock | 10 +++++++++- 11 files changed, 100 insertions(+), 41 deletions(-) diff --git a/gatsby-config.js b/gatsby-config.js index 340a59f..4059d1b 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -26,6 +26,20 @@ module.exports = { `gatsby-plugin-sharp`, `gatsby-transformer-sharp`, `gatsby-transformer-json`, + { + resolve: `gatsby-plugin-remote-images`, + options: { + nodeType: 'SocialsJson', + imagePath: 'image', + }, + }, + { + resolve: `gatsby-plugin-remote-images`, + options: { + nodeType: 'FriendsJson', + imagePath: 'imageURL', + }, + }, { resolve: `gatsby-source-filesystem`, options: { diff --git a/package.json b/package.json index 5809225..e4df3da 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "gatsby-plugin-offline": "4.14.0", "gatsby-plugin-react-helmet": "4.14.0", "gatsby-plugin-react-i18next": "1.1.1", + "gatsby-plugin-remote-images": "^3.0.0", "gatsby-plugin-robots-txt": "1.6.10", "gatsby-plugin-sass": "4.14.0", "gatsby-plugin-sharp": "^3.14.0", diff --git a/src/pages/friends.js b/src/pages/friends.js index 96d917e..9f88de8 100644 --- a/src/pages/friends.js +++ b/src/pages/friends.js @@ -5,6 +5,7 @@ import { graphql } from "gatsby"; import PropTypes from "prop-types"; import * as styles from "./friends.module.scss"; +import { GatsbyImage, getImage } from "gatsby-plugin-image"; export const query = graphql` query AllFriendsQuery($language: String!) { @@ -13,7 +14,11 @@ export const query = graphql` name profession url - imageURL + localImage { + childImageSharp { + gatsbyImageData(height: 300, width: 300, placeholder: BLURRED) + } + } } } locales: allLocale(filter: { language: { eq: $language } }) { @@ -62,12 +67,6 @@ const FriendsPage = ({ data }) => { >
{ "#image" } > +
+ +
{ friend.name + "#name" } - > + > {friend.name} { className={ projectStyles.projectCardImage } - style={{ - backgroundImage: - "url(" + - project.image.childImageSharp - .resize.src + - ")", - }} > +
+ +
{ >
+
+ +
{ >
+
+ +
{social.platformName} diff --git a/src/pages/social.module.scss b/src/pages/social.module.scss index 6e0c952..c4412b2 100644 --- a/src/pages/social.module.scss +++ b/src/pages/social.module.scss @@ -8,6 +8,7 @@ @include cardGeneric; display: flex; flex-direction: column; + position: relative; .socialImage { width: 300px; @@ -19,14 +20,26 @@ flex-direction: column-reverse; text-shadow: 0 0 10px black, 0 0 10px black, 0 0 20px black; color: white; + position: relative; + + .socialBg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 0; + } .socialName { font-size: 2em; margin-top: -5px; + z-index: 100; } .socialUsername { margin-top: auto; + z-index: 100; } } } diff --git a/src/templates/project.js b/src/templates/project.js index 2d7683d..a15b023 100644 --- a/src/templates/project.js +++ b/src/templates/project.js @@ -6,6 +6,7 @@ import PropTypes from "prop-types"; import * as styles from "./project.module.scss"; import { MDXRenderer } from "gatsby-plugin-mdx"; +import { GatsbyImage } from "gatsby-plugin-image"; export const query = graphql` query GetProject($urlname: String!, $lang: String!, $language: String!) { @@ -21,7 +22,9 @@ export const query = graphql` website } image { - publicURL + childImageSharp { + gatsbyImageData(placeholder: BLURRED, layout: FULL_WIDTH) + } } shortDescription } @@ -65,11 +68,9 @@ const ProjectTemplate = ({ data }) => {
+ > + +

diff --git a/yarn.lock b/yarn.lock index 1e8eb1d..cf77cf7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5750,6 +5750,14 @@ gatsby-plugin-react-i18next@1.1.1: optionalDependencies: react-helmet "^6.1.0" +gatsby-plugin-remote-images@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/gatsby-plugin-remote-images/-/gatsby-plugin-remote-images-3.0.0.tgz#63bbba949527eafddef755e0d8891e5ad2c59db9" + integrity sha512-pJ2QSHM7SfJvKA+dbCpULNv9ha3DuqF4kKyuLTVDYBUbb3QWBNorXMTazshZsoLwMyER16CS3GIARsLOUkmsaQ== + dependencies: + gatsby-source-filesystem "^3.4.0" + lodash "^4.17.15" + gatsby-plugin-robots-txt@1.6.10: version "1.6.10" resolved "https://registry.yarnpkg.com/gatsby-plugin-robots-txt/-/gatsby-plugin-robots-txt-1.6.10.tgz#b178efe3da65718a39d1acd2e5768f687b205cf0" @@ -5894,7 +5902,7 @@ gatsby-recipes@^0.25.0: xstate "^4.9.1" yoga-layout-prebuilt "^1.9.6" -gatsby-source-filesystem@^3.14.0: +gatsby-source-filesystem@^3.14.0, gatsby-source-filesystem@^3.4.0: version "3.14.0" resolved "https://registry.yarnpkg.com/gatsby-source-filesystem/-/gatsby-source-filesystem-3.14.0.tgz#ae2b930091a932b33270cb9cc2d9caaf0abc1742" integrity sha512-Gg5GGxiWXhjapWMYdXOGk7zp+ajYowS+xNmaDUkL1gH+IQLvE18XbvKh00B/HiFaHm4azJfS2QRrRI/mPTZX+w==