gatsby

GraphQL query works in Gatsby page but not inside class component

亡梦爱人 提交于 2020-06-09 02:02:03
问题 There have been a couple of similar questions, but none helped me really understand using a GraphQL inside a (class) component other than the ones in the pages folder. My project structure looks like that: -src --components ---aboutBody ----index.js --pages ---about.js I have a page component called about (Prismic single page type) and set up some components to "fill" this page (cleaned up for better readability). class AboutPage extends Component { render() { return ( <LayoutDefault>

How to show images in a GatsbyJS project?

对着背影说爱祢 提交于 2020-06-01 06:18:49
问题 How to show images? It can not be shown correctly below. In the src/components/Header.js file: <img src="../images/logo.png" style={{width:"112",height:"28"}} /> 回答1: Importing Assets Directly Into Files import React from "react" import logo from "./logo.png" // Tell Webpack this JS file uses this image console.log(logo) // /logo.84287d09.png function Header() { // Import result is the URL of your image return <img src={logo} alt="Logo" /> } export default Header The reason this is best is

Including local JS and CSS files using Gatsbyjs

假装没事ソ 提交于 2020-06-01 01:38:52
问题 I am completely new to the gatsbyjs ecosystem, and at the same time I am learning a bit of reactjs. I recently bought an html template and was trying to use it as a UI in a gatsbyjs application. The template has many css and js, whether proprietary or costumized, which implies that there are no plugins in gatsbyjs to replace them. That said, the only option I have left is to add them directly as a link and scripts tags in the gatsbyjs application. Following some of the tutorials I saw that

gatsby & graphql : filtering for a specific single image

爷,独闯天下 提交于 2020-05-30 03:58:16
问题 I don't really understand graphql or gatsby that well but I believe all my images are loaded into graphql by putting this in my gatsby-config.js { resolve: `gatsby-source-filesystem`, options: { name: `images`, path: path.join(__dirname, `src/assets/images`), }, }, I am then trying to query a specific image which I can do with query MyQuery { allImageSharp(filter: {id: {eq: "7acfccd5-4aef-532b-8889-9d844ae2068b"}}) { edges { node { sizes { sizes srcSet src aspectRatio } id } } } } And this

gatsby & graphql : filtering for a specific single image

一个人想着一个人 提交于 2020-05-30 03:54:50
问题 I don't really understand graphql or gatsby that well but I believe all my images are loaded into graphql by putting this in my gatsby-config.js { resolve: `gatsby-source-filesystem`, options: { name: `images`, path: path.join(__dirname, `src/assets/images`), }, }, I am then trying to query a specific image which I can do with query MyQuery { allImageSharp(filter: {id: {eq: "7acfccd5-4aef-532b-8889-9d844ae2068b"}}) { edges { node { sizes { sizes srcSet src aspectRatio } id } } } } And this

gatsby & graphql : filtering for a specific single image

天大地大妈咪最大 提交于 2020-05-30 03:54:09
问题 I don't really understand graphql or gatsby that well but I believe all my images are loaded into graphql by putting this in my gatsby-config.js { resolve: `gatsby-source-filesystem`, options: { name: `images`, path: path.join(__dirname, `src/assets/images`), }, }, I am then trying to query a specific image which I can do with query MyQuery { allImageSharp(filter: {id: {eq: "7acfccd5-4aef-532b-8889-9d844ae2068b"}}) { edges { node { sizes { sizes srcSet src aspectRatio } id } } } } And this

gatsby & graphql : filtering for a specific single image

放肆的年华 提交于 2020-05-30 03:53:28
问题 I don't really understand graphql or gatsby that well but I believe all my images are loaded into graphql by putting this in my gatsby-config.js { resolve: `gatsby-source-filesystem`, options: { name: `images`, path: path.join(__dirname, `src/assets/images`), }, }, I am then trying to query a specific image which I can do with query MyQuery { allImageSharp(filter: {id: {eq: "7acfccd5-4aef-532b-8889-9d844ae2068b"}}) { edges { node { sizes { sizes srcSet src aspectRatio } id } } } } And this

Accessing your Contentful space failed with gatsby-source-contentful

我的未来我决定 提交于 2020-05-29 06:49:48
问题 gatsby: 2.20.8 gatsbh-source-contentful: 2.2.5 I've verified my spaceId and accessToken are correct, and I've verified that these keys have access to my Contentful development environment. I've tried: Enabling GATSBY_CONTENTFUL_OFFLINE Deleting the .cache directory Deleting node_modules Setting environment to "master" and removing it completely Wrapping the env vars in template literals (suggested on an old github issue) I keep getting this error. Any ideas? ERROR Accessing your Contentful

Accessing your Contentful space failed with gatsby-source-contentful

天涯浪子 提交于 2020-05-29 06:49:07
问题 gatsby: 2.20.8 gatsbh-source-contentful: 2.2.5 I've verified my spaceId and accessToken are correct, and I've verified that these keys have access to my Contentful development environment. I've tried: Enabling GATSBY_CONTENTFUL_OFFLINE Deleting the .cache directory Deleting node_modules Setting environment to "master" and removing it completely Wrapping the env vars in template literals (suggested on an old github issue) I keep getting this error. Any ideas? ERROR Accessing your Contentful

How to properly implement a JSONP form post submission on a Gatsby site

给你一囗甜甜゛ 提交于 2020-05-28 06:57:11
问题 I've got a site, created with Gatsby. There is a form on one of the pages, and it needs to post to an endpoint that doesn't support CORS, but does support JSONP. I've written the event handler like this, using jsonp: const handleSumbit = async event => { event.preventDefault() jsonp( "https://go.pardot.com/form/id/code/", { timeout: 10000, params: { firstname: "fname", lastname: "lname", email: "an@email.com", company: "company", }, }, (err, data) => { console.log({ err }, { data }) } ) }