gatsby

React hooks in Gatsby: Invalid hook call

十年热恋 提交于 2019-12-23 12:55:00
问题 Trying to implement a custom hook from a react example: https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state, but I get the following error: ERROR: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons: 1. You might have mismatching versions of React and the renderer (such as React DOM) 2. You might be breaking the Rules of Hooks 3. You might have more than one copy of React in the

Access JSON chunk exported from Gatsby Static Query

拜拜、爱过 提交于 2019-12-23 06:06:11
问题 I have a React Component in a Gatsby app that is using the useStaticQuery hook to pull in data from the GraphQL layer. This component gets used in my application, but it also gets used as part of a JavaScript embed/widget that is created in a separate Webpack configuration. I don't want the widget to depend on Gatsby, so I've shimmed the relevant bits of Gatsby, but I still need to pass in data to the shim I've created for useStaticQuery . I found that my Gatsby app is generating a file at

Gatsby failing production build

浪尽此生 提交于 2019-12-23 05:26:29
问题 Recently, Gatsby started failing to build a production version of the site. Development version builds fine. It seems to be some Babel issue but I can't figure out what it is. I've upgraded everything, deleted the node_modules folder and yarn.lock but after building everything afresh again it fails the same way. I'm not particularly familiar with the inner workings Babel so I'm guessing this is something to do with the Babel settings shipped with Gatsby? ERROR #98123 WEBPACK Generating

Gatsby: Using GraphQL Query on Custom Post Type with Custom Taxonomy

社会主义新天地 提交于 2019-12-23 02:47:09
问题 I am using Gatsby to deliver a front end to WordPress and querying data with GraphQL. I have a post with a Custom Post Type and a Custom Taxonomy. However when I query on the CPT, I can get the number of the Custom Taxonomy but no don't know how to retrieve the corresponding names. Below is my query; { wordpressWpPortfolio { title slug id portfolio_categories } } And this is what is returned; { "data": { "wordpressWpPortfolio": { "title": "Test Portfolio 1", "slug": "test-portfolio-1", "id":

Facebook not recognizing some Gatsby React Helmet Meta Tags on Netlify

允我心安 提交于 2019-12-23 02:33:02
问题 Some, but not all, of my Gatsby React Helmet Meta Tags seems to be getting lost by facebook. Here is the code: <Helmet> <title>Code Championship | Code is Sport</title> <meta name="description" content="Code is Sport. Competitive coding competitions for elementary, middle, and high school students." /> <meta name="keywords" content="code, championship, competition, minnesota" /> <meta property="og:url" content="https://www.codechampionship.com" /> <meta property="og:title" content="Code

How to create routes with params in gatsbyjs

∥☆過路亽.° 提交于 2019-12-22 05:03:37
问题 I want to create a route that uses a slug as a parameter in my gatsby generated website. I have a list of projects that sit on the route /projects/<slug> . Usually with react router I would create a route like so: <Route exact path='/projects/:project' component={Projects} /> It seems in gatsby, I have to create a new file under the ./pages directory and that creates a new route. I have a page called projects where I try do a look up on the route param but only seem to get the 404 page. // .

Programmatically create Gatsby pages from Contentful data

廉价感情. 提交于 2019-12-22 04:42:57
问题 I am looking for help with GatsbyJS and Contentful. The docs aren't quite giving me enough info. I am looking to programmatically create pages based on contentful data. In this case, the data type is a retail "Store" with a gatsby page at /retail_store_name The index.js for each store is basically a couple of react components with props passed in e.g. shop name and google place ID. Add data to contentful. Here is my example data model: { "name": "Store" "displayField": "shopName", "fields": [

How do you pass variables to pageQuery

不想你离开。 提交于 2019-12-21 07:06:39
问题 I have this page in Gatsby: import React from 'react' import Link from 'gatsby-link' import IntroPartial from '../partials/themes/intro' export default class ThemeTemplate extends React.Component { render(){ const theme = this.props.pathContext.theme console.dir(this.data) return ( <div> <h1>{theme.name}</h1> <IntroPartial theme={theme} /> </div> ) } } export const pageQuery = graphql` query ThemeQuery($theme: String){ allMarkdownRemark( filter: { frontmatter: { themes: { in: [$theme] } } } )

Styled Component styles are disabled in Chrome DevTools

本秂侑毒 提交于 2019-12-21 03:25:11
问题 I am working on a static page that uses React, Gatsby, and styled-components. When styling a page, my development workflow usually heavily involves Chrome DevTools, tweaking styles there until I have something that I like, and then implementing them in the code. When using styled-components, however, all of the styles/rules that appear in DevTools for each rendered element are grey, italicized, and disabled. I can override them by adding styles in element.style {} , but that can be a pain,

Pass string to a GraphQL StaticQuery in Gatsby

寵の児 提交于 2019-12-20 06:34:08
问题 I am trying to understand how StaticQuery works in a Gatsby/GraphQL workflow, and as a trial I want to build an article header with a background image. The image is defined in frontmatter of the markdown file I am building from ( frontmatter.feature ). I know the nature of StaticQuery is... well... static, so I cannot pass dynamic variables to a query. But that's not what I am doing - I think. Here's my example: articleHeader(frontmatter) { if (frontmatter.feature) { return ( <StaticQuery