gatsby

“Error running command: Build script returned non-zero exit code” when deploying Gatsby JS site to Netlify

☆樱花仙子☆ 提交于 2019-12-10 19:12:29
问题 I recently came across Gatsby JS (https://github.com/gatsbyjs/gatsby) and decided to build my portfolio site on top of the generator. So I forked their starter site (gatsby-starter-default) and built my portfolio with it (https://github.com/ArchieHicklin/Archie) Locally (using ' gatsby develop ') it runs fine - but when I deploy to Netlify with ' gatsby build ' I get this error: 11:30:58 AM: Build started 11:30:59 AM: Fetching cached dependencies 11:30:59 AM: Expected build cache - but failed

GraphQL request error - Unknown argument 'slug'

夙愿已清 提交于 2019-12-10 15:29:41
问题 I am trying to link my index.js page to an article template to display the data from a middleware Drupal site using a slug and createPages . I have the data displaying correctly on my index.js page and my createPages seems to not have any errors after changing the file path to ./src/templates/article.js . I am running into this GraphQL error while compiling: error GraphQL Error There was an error while compiling your site's GraphQL queries. Error: RelayParser: Encountered 1 error(s): -

Define specific cache control header for selected file only

巧了我就是萌 提交于 2019-12-10 11:44:50
问题 I'm setting up a Nginx sever (version 1.17.1) for Gatsby following up the recommendation at https://www.gatsbyjs.org/docs/caching/. The snippet below is the portion my server {} block attempting implementing the recommended caching configuration; location ~* \.(?:html)$ { add_header Cache-Control "public, max-age=0, must-revalidate"; } location /static { add_header Cache-Control "public, max-age=31536000, immutable"; } location ~* \.(?:css|js)$ { add_header Cache-Control "public, max-age

How to handle Contentful content data in Gatsby

不羁岁月 提交于 2019-12-10 04:10:32
问题 I'm interested in using Gatsby to build a Netlify static site using content from Contentful Netlify has this nice gettting started Gatsby guide: ​​https://www.netlify.com/blog/2016/02/24/a-step-by-step-guide-gatsby-on-netlify But I'm a bit unsure of how to bring Contentful into the mix. Do I need to write scripts to convert my Contentful content into Gatsby 'markdown'? Any ideas, ideas, links appreciated! 回答1: Since this question was posted, an official Contentful plugin's been added to

gatsby-image: difference between childImageSharp vs imageSharp

故事扮演 提交于 2019-12-10 02:11:47
问题 I'm using gatsby-image to handle automatically handle different image sizes. It works great. However, in the docs of gatsby-image, one example uses imageSharp in graphql to get different image sizes, while another example uses childImageSharp . I was curious what the difference between the two are? I assume it has to do with either gatsby-transformer-sharp or gatsby-plugin-sharp , but the docs for those plugins don't have any info on that either. 回答1: It's been a while since this question was

How to handle internationalization/localization with Gatsby JS?

ぐ巨炮叔叔 提交于 2019-12-10 01:33:04
问题 I would like to publish my static site in various locals around the world with localized content. How does one accomplish this? 回答1: There's a community plugin gatsby-plugin-i18n that you could "use […] with react-intl, i18next, or any other i18n library. This plugin do not translate messages, it just creates routes for each language, and you can use different layouts for each language if you want to." (quoting the plugin README). Its first release is dated 30th of August 2017, so maybe you

GraphQL queries for Gatsby - Contentful setup with a flexible content model

妖精的绣舞 提交于 2019-12-09 07:20:10
问题 I have a gatsby site with the contentful plugin and graphql queries (setup is working). [EDIT] My gatsby setup pulls data dynamically using the pageCreate feature. And populates my template component, the root graphql query of which I've shared below. I can create multiple pages using the setup if the pages on contentful follow the structure given in the below query. [/EDIT] My question is about a limitation I seemed to have come across or just don't know enough grpahql to understand this yet

Gatsby.js - proxy to express server

妖精的绣舞 提交于 2019-12-08 10:37:43
问题 I want to setup proxy for my simple express server. I have added cors policy and everything works perfect when I call api like this: fetch('http://localhost:3000/tasks') But when i setup proxy in gatsby.config.js like this: proxy: { prefix: '/', url: 'http://localhost:3000' }, and call: fetch('/tasks) I'm getting this error: Unhandled Rejection (SyntaxError): Unexpected token < in JSON at position 0 How to setup properly proxy in gatsby.js ?? 回答1: I don't think you can use root as proxy. In

Retrieve file contents during Gatsby build

非 Y 不嫁゛ 提交于 2019-12-08 04:36:23
问题 I need to pull in the contents of a program source file for display in a page generated by Gatsby. I've got everything wired up to the point where I should be able to call // my-fancy-template.tsx import { readFileSync } from "fs"; // ... const fileContents = readFileSync("./my/relative/file/path.cs"); However, on running either gatsby develop or gatsby build , I'm getting the following error This dependency was not found: ⠀ * fs in ./src/templates/my-fancy-template.tsx ⠀ To install it, you

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

纵饮孤独 提交于 2019-12-07 23:47:28
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": "5caf7182-c9f5-53d9-94da-b49cfbdc6d7f", "portfolio_categories": [ 5 ] } } } However, there are no other