gatsby

gatsby --version > -bash: gatsby: command not found

我怕爱的太早我们不能终老 提交于 2019-12-19 07:49:22
问题 I use mac and I installed gatsby-cli by: npm install --global gatsby-cli and 'npm root -g' command prints: /usr/local/lib/node_modules/npm/lib/node_modules npm successfully installed gatsby but, I cannot run gatsby command (gatsby --version, gatsby --help) Whenever I type and run "gatsby --version" it prints: -bash: gatsby: command not found Is there any way I can fix this problem?? 回答1: you have to update your config. You may have to follow few steps Set Config remove existing config npm

How to include jQuery in a Gatsby.js project?

半腔热情 提交于 2019-12-17 19:53:41
问题 I've been experimenting with gatsby.js for a while and everything is going well except for this issue, i cannot include jQuery scripts unto the app so that it loads after the gatsby app has been rendered, i've the included script tags unto the html.js file and loaded it but it seems that the code is executed before react renders the content unto the screen i've tried using simple-load-script as well to include it on the componentDidMount method on the html.js app. But with no luck, here is

Gatsby how to share React header between React components and previously generated static HTML content

最后都变了- 提交于 2019-12-14 02:48:26
问题 I am building a Gatsby site. The site consists of multiple React "page-components", all of which get wrapped in a React header component and a React footer component. I have some pre-existing static HTML (think things like Privacy Policy &c). I was planning to just publish them in the /public gatsby folder. But then the won't have the React header component and footer component. How can I publish my static HTML content AND give them the React header/footer? I imagine that if I "translate" my

How to enable flag for GATSBY_CONTENTFUL_OFFLINE=true?

纵然是瞬间 提交于 2019-12-14 02:25:07
问题 How to enable GATSBY_CONTENTFUL_OFFLINE=true in GatsbyJS to access content offline? The documentation suggests to export GATSBY_CONTENTFUL_OFFLINE=true . I have tried adding it in the config but still it doesn't work. Can anyone tell me where to add this export or else if the functionality actually works? 回答1: You would use export … in your .bashrc or similar. You're exporting a variable declaration from the shell script into your shell session, making it available as an environment variable.

Pull GraphQL data into gatsby-browser.js (or better solution, please)

浪子不回头ぞ 提交于 2019-12-14 00:33:02
问题 I am trying to run a GraphQL query inside replaceRouterComponent from within gatsby-browser.js (gatsby browser API). Whereas, I can access data from Contentful . This may not be the best solution and any advice on how I can achieve in another way would be appreciated too. Here is the issue - Inside of the component TripAdvisor.js I am mounting the scripts within componentDidMount , whereas the locationId is based on the data of this.props.tripAdvisorId pulled from the individual posts created

Unable to use const within a class in React

主宰稳场 提交于 2019-12-13 20:42:03
问题 I am following this tutorial https://nickymeuleman.netlify.com/blog/gatsby-pagination#navigate-to-previousnext-page Everything is working fine, but I am unable to add const within the class. I am using VSC to code up the site, it just doesn't seem to like it. This is the class I am trying to place the consts within. As I am new to React I am bit lost on finding a solution without using a plugin. export default class PostList extends React.Component { render() { const posts = this.props.data

String interpolation in graphQL query

一笑奈何 提交于 2019-12-13 17:30:26
问题 I am new to Gatsby and its graphQL query system to retrieve assets. I have a working component Image that fetches an image and displays it. I want to have the name of the image customizable but I can't figure out how to dit. Here is the working component: const Image = () => ( <StaticQuery query={graphql` query { // fetching the image gatsby-astronaut.png placeholderImage: file(relativePath: { eq: "gatsby-astronaut.png" }) { childImageSharp { fluid(maxWidth: 300) { ...GatsbyImageSharpFluid }

Clarification on Gatsby page load network request

霸气de小男生 提交于 2019-12-13 16:08:56
问题 I am learning how Gatsby works and have got a website with 2 pages, both having hyperlinks to each other. Since gatsby compiles a website to static pages with javascript bundles, I would expect html link click event to trigger page request to the server to load the second page. However, I do not see such a request. The website behaves like single-page application loaded from the first page. Link click does not cause network page request for the second page. At the same time, I can see that

Gatsby cannot find fs despite npm install

牧云@^-^@ 提交于 2019-12-13 14:06:48
问题 I'm on: Ubuntu 16.04 Gatsby CLI version: 2.7.14 Gatsby version: 2.13.21 Node v10.16.0 NPM 6.10.1 I'm following the Gatsby tutorial "7. Programmatically create pages from data". I can't solve this error: This dependency was not found: ⠀ * fs in ./node_modules/electron/index.js, ⠀ To install it, you can run: npm install --save fs I've run npm install --save fs already, and then tried it again. But the same error occurs. Permissions for the directory are set as a+rwx and everything has been

Can't resize react-chartjs-2 doughnut chart

喜夏-厌秋 提交于 2019-12-13 13:25:07
问题 I am trying to make a doughnut chart with react and gatsbyjs. The chart works fine but I can not get it to use the full width of the div. It displays too small for the area reserved. render (){ return ( <Doughnut data={this.state.chartData} options={{ padding:"0px", responsive:false, maintainAspectRatio:false, defaultFontSize:"14px", width:"400", height:"400", legend:{ display:false, }, plugins:{ datalabels: { color:'#000000', anchor: "start", align:"end", formatter: function(value, context)